/* General body styling */
body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #2c3e50;
    font-family: system-ui, -apple-system, sans-serif;
    padding: 10px;
    transition: background-color 0.1s;
}

/* Light theme styles */
body.light-theme {
    background: #f0f2f5;
}

/* Calculator container styling */
.calculator {
    background: rgba(52, 73, 94, 0.95);
    border-radius: 20px;
    padding: 20px;
    width: 100%;
    max-width: 360px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transition: all 0.1s;
}

.calculator.light-theme {
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Responsive design for horizontal layout on larger screens */
@media screen and (min-width: 768px) {
    .calculator {
        max-width: 800px;
        display: grid;
        grid-template-columns: 300px 1fr;
        grid-gap: 20px;
        padding: 25px;
    }

    .history-panel {
        grid-row: 1 / span 4;
        margin-bottom: 0;
        max-height: none;
        height: 100%;
    }

    .display {
        grid-column: 2;
    }

    .memory-buttons {
        grid-column: 2;
    }

    .scientific-buttons {
        grid-column: 2;
        grid-template-columns: repeat(6, 1fr);
    }

    .buttons {
        grid-column: 2;
    }
}

/* Responsive design for vertical layout on smaller screens */
@media screen and (max-width: 767px) {
    .calculator {
        max-width: 360px;
        display: flex;
        flex-direction: column;
        padding: 15px;
    }

    .history-panel {
        max-height: 150px;
        margin-bottom: 15px;
    }

    .scientific-buttons {
        grid-template-columns: repeat(4, 1fr);
    }

    .buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Display section styles */
.display {
    background: rgba(44, 62, 80, 0.95);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
    direction: ltr;
    text-align: right;
    transition: all 0.1s;
}

.light-theme .display {
    background: #f8f9fa;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* History and result display styles */
#history {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    min-height: 20px;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.1s;
}

.light-theme #history {
    color: #6c757d;
}

#result {
    color: #fff;
    font-size: 32px;
    font-weight: 600;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: color 0.1s;
}

.light-theme #result {
    color: #2d3436;
}

#result::-webkit-scrollbar {
    display: none;
}

/* Button grids and layout */
.buttons,
.scientific-buttons,
.memory-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.memory-buttons,
.scientific-buttons {
    margin-bottom: 15px;
}

/* General button styles */
button {
    border: none;
    padding: 15px 10px;
    font-size: 18px;
    border-radius: 12px;
    cursor: pointer;
    background: rgba(52, 152, 219, 0.2);
    color: white;
    font-weight: 500;
    transition: all 0.1s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.light-theme button {
    background: #f1f3f5;
    color: #2d3436;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

button:active {
    transform: scale(0.97);
}

/* Operator and special button styles */
.operator {
    background: rgba(52, 152, 219, 0.3);
    font-weight: 600;
}

.light-theme .operator {
    background: #74b9ff;
    color: white;
}

.equals {
    background: #00b894;
    grid-column: span 2;
    color: white;
}

.light-theme .equals {
    background: #00b894;
}

.clear {
    background: #ff7675;
    color: white;
}

.light-theme .clear {
    background: #ff7675;
}

/* History panel styles */
.history-panel {
    background: rgba(44, 62, 80, 0.95);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
    max-height: 150px;
    overflow-y: auto;
    transition: all 0.1s;
}

.light-theme .history-panel {
    background: #f8f9fa;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: white;
    padding: 0 5px;
}

.light-theme .history-header {
    color: #2d3436;
}

.history-item {
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 5px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    transition: background-color 0.1s;
}

.light-theme .history-item {
    color: #2d3436;
    background: rgba(0, 0, 0, 0.02);
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.light-theme .history-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Theme toggle button styles */
.theme-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    z-index: 2;
    transition: transform 0.1s;
}

.scientific-buttons button {
    font-size: 16px;
    padding: 12px 8px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.light-theme .scientific-buttons button {
    background: #e8f0fe;
    color: #2d3436;
}

.memory-buttons button {
    font-size: 16px;
    background: rgba(52, 152, 219, 0.15);
}

.light-theme .memory-buttons button {
    background: #e3f2fd;
    color: #2d3436;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.light-theme ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

/* History button styles */
.history-btn {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
}

.light-theme .history-btn {
    background: #e0e0e0;
    color: #2d3436;
}

/* Responsive styles for small screens */
@media (max-width: 480px) {
    .calculator {
        padding: 15px;
    }

    button {
        padding: 12px 8px;
        font-size: 16px;
    }

    .scientific-buttons button {
        font-size: 14px;
        padding: 10px 6px;
        height: 35px;
    }

    #result {
        font-size: 28px;
    }

    .history-panel {
        max-height: 120px;
    }
}

/* Hover effects for desktop */
@media (hover: hover) {
    button:hover {
        opacity: 0.9;
    }

    .light-theme button:hover {
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    }
}

/* Active effects for touch devices */
@media (hover: none) {
    button:active {
        opacity: 0.8;
    }
}