/* =========================================
   RESET
========================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


/* =========================================
   ROOT VARIABLES
========================================= */

:root {

    --background-start: #141e30;

    --background-end: #243b55;

    --calculator-background:
        rgba(255, 255, 255, 0.10);

    --display-background:
        rgba(0, 0, 0, 0.30);

    --button-background:
        rgba(255, 255, 255, 0.10);

    --button-hover:
        rgba(255, 255, 255, 0.20);

    --text-primary: #ffffff;

    --text-secondary:
        rgba(255, 255, 255, 0.55);

    --operator: #ff9f0a;

    --equal: #00a86b;

    --border:
        rgba(255, 255, 255, 0.12);

}


/* =========================================
   LIGHT THEME
========================================= */

body.light-theme {

    --background-start: #dfe9f3;

    --background-end: #ffffff;

    --calculator-background:
        rgba(255, 255, 255, 0.75);

    --display-background:
        rgba(255, 255, 255, 0.65);

    --button-background:
        rgba(0, 0, 0, 0.07);

    --button-hover:
        rgba(0, 0, 0, 0.14);

    --text-primary: #151515;

    --text-secondary:
        rgba(0, 0, 0, 0.55);

    --border:
        rgba(0, 0, 0, 0.10);

}


/* =========================================
   BODY
========================================= */

body {

    min-height: 100vh;

    display: flex;

    justify-content: center;

    align-items: center;

    padding: 20px;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    background:
        linear-gradient(
            135deg,
            var(--background-start),
            var(--background-end)
        );

    color: var(--text-primary);

    transition:
        background 0.3s ease;

}


/* =========================================
   CALCULATOR
========================================= */

.calculator {

    width: 100%;

    max-width: 390px;

    padding: 24px;

    border-radius: 30px;

    background:
        var(--calculator-background);

    backdrop-filter:
        blur(20px);

    -webkit-backdrop-filter:
        blur(20px);

    border:
        1px solid var(--border);

    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.40);

}


/* =========================================
   HEADER
========================================= */

.calculator-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 20px;

}


.header-content h1 {

    font-size: 25px;

    margin-bottom: 5px;

}


.header-content p {

    font-size: 13px;

    color: var(--text-secondary);

}


/* =========================================
   THEME BUTTON
========================================= */

.theme-button {

    width: 44px;

    height: 44px;

    border: none;

    border-radius: 50%;

    background:
        var(--button-background);

    color:
        var(--text-primary);

    font-size: 18px;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        background 0.2s ease;

}


.theme-button:hover {

    background:
        var(--button-hover);

    transform:
        rotate(15deg);

}


/* =========================================
   DISPLAY
========================================= */

.display {

    width: 100%;

    min-height: 140px;

    padding: 22px;

    margin-bottom: 20px;

    display: flex;

    flex-direction: column;

    justify-content: flex-end;

    align-items: flex-end;

    border-radius: 22px;

    background:
        var(--display-background);

    overflow: hidden;

}


/* =========================================
   PREVIOUS DISPLAY
========================================= */

.previous-display {

    width: 100%;

    min-height: 26px;

    margin-bottom: 8px;

    text-align: right;

    font-size: 17px;

    color:
        var(--text-secondary);

}


/* =========================================
   CURRENT DISPLAY
========================================= */

.current-display {

    width: 100%;

    text-align: right;

    font-size: 44px;

    font-weight: 700;

    color:
        var(--text-primary);

    white-space: nowrap;

    overflow-x: auto;

    scrollbar-width: none;

}


.current-display::-webkit-scrollbar {

    display: none;

}


/* =========================================
   BUTTON GRID
========================================= */

.buttons {

    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 12px;

}


/* =========================================
   GENERAL BUTTON
========================================= */

.button {

    height: 65px;

    border: none;

    border-radius: 19px;

    font-size: 21px;

    font-weight: 600;

    color:
        var(--text-primary);

    background:
        var(--button-background);

    cursor: pointer;

    user-select: none;

    transition:
        transform 0.12s ease,
        background 0.15s ease;

}


.button:hover {

    background:
        var(--button-hover);

}


.button:active {

    transform:
        scale(0.92);

}


/* =========================================
   SPECIAL BUTTONS
========================================= */

.button-special {

    background:
        rgba(255, 255, 255, 0.20);

}


.button-special:hover {

    background:
        rgba(255, 255, 255, 0.30);

}


/* =========================================
   OPERATOR BUTTON
========================================= */

.button-operator {

    background:
        var(--operator);

    color: white;

}


.button-operator:hover {

    filter:
        brightness(1.12);

}


/* =========================================
   EQUAL BUTTON
========================================= */

.button-equal {

    background:
        var(--equal);

    color: white;

}


.button-equal:hover {

    filter:
        brightness(1.12);

}


/* =========================================
   ZERO BUTTON
========================================= */

.button-zero {

    grid-column:
        span 2;

}


/* =========================================
   FOOTER
========================================= */

.calculator-footer {

    margin-top: 18px;

    text-align: center;

}


.calculator-footer p {

    font-size: 12px;

    color:
        var(--text-secondary);

}


/* =========================================
   MOBILE RESPONSIVE
========================================= */

@media (max-width: 420px) {

    body {

        padding: 12px;

    }


    .calculator {

        padding: 18px;

        border-radius: 25px;

    }


    .display {

        min-height: 125px;

        padding: 18px;

    }


    .current-display {

        font-size: 36px;

    }


    .button {

        height: 60px;

        border-radius: 16px;

        font-size: 19px;

    }


    .buttons {

        gap: 9px;

    }

}


/* =========================================
   VERY SMALL SCREEN
========================================= */

@media (max-width: 320px) {

    .calculator {

        padding: 14px;

    }


    .button {

        height: 55px;

        font-size: 17px;

    }


    .current-display {

        font-size: 31px;

    }

}
/* =========================================
   HISTORY
========================================= */

.history {

    margin-top: 22px;

    padding-top: 18px;

    border-top:
        1px solid var(--border);

}


/* =========================================
   HISTORY HEADER
========================================= */

.history-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 12px;

}


.history-header h2 {

    font-size: 17px;

    color:
        var(--text-primary);

}


/* =========================================
   CLEAR HISTORY BUTTON
========================================= */

.clear-history-button {

    border: none;

    background: transparent;

    color:
        #ff6b6b;

    font-size: 13px;

    cursor: pointer;

}


.clear-history-button:hover {

    text-decoration: underline;

}


/* =========================================
   HISTORY LIST
========================================= */

.history-list {

    max-height: 180px;

    overflow-y: auto;

    display: flex;

    flex-direction: column;

    gap: 8px;

}


/* =========================================
   HISTORY ITEM
========================================= */

.history-item {

    padding: 12px 14px;

    border-radius: 12px;

    background:
        var(--button-background);

    color:
        var(--text-primary);

    font-size: 14px;

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 10px;

    cursor: pointer;

    transition:
        background 0.15s ease;

}


.history-item:hover {

    background:
        var(--button-hover);

}


.history-expression {

    color:
        var(--text-secondary);

}


.history-result {

    font-weight: 700;

}


/* =========================================
   EMPTY HISTORY
========================================= */

.empty-history {

    text-align: center;

    padding: 15px;

    font-size: 13px;

    color:
        var(--text-secondary);

}