/* ===== CSS Variables ===== */
:root {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --display-bg: #0f3460;
    --display-text: #ffffff;
    --display-previous: #94a3b8;
    
    --btn-number: #e8e8e8;
    --btn-number-text: #1a1a2e;
    --btn-operator: #00adb5;
    --btn-operator-text: #ffffff;
    --btn-function: #7b68ee;
    --btn-function-text: #ffffff;
    --btn-equals: linear-gradient(135deg, #00d9a3, #00b894);
    --btn-equals-text: #ffffff;
    --btn-clear: #ef4444;
    --btn-clear-text: #ffffff;
    --btn-delete: #f59e0b;
    --btn-delete-text: #ffffff;
    
    --shadow-light: rgba(255, 255, 255, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.3);
}

/* ===== Global Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ===== Calculator Container ===== */
.calculator-container {
    perspective: 1000px;
}

.calculator {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 
        20px 20px 60px var(--shadow-dark),
        -20px -20px 60px var(--shadow-light);
    max-width: 450px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== Display Section ===== */
.display-section {
    background: var(--display-bg);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 25px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: 
        inset 5px 5px 15px rgba(0, 0, 0, 0.3),
        inset -5px -5px 15px rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.previous-operand {
    color: var(--display-previous);
    font-size: 1.2rem;
    font-weight: 400;
    min-height: 1.5rem;
    text-align: right;
    word-wrap: break-word;
    word-break: break-all;
    margin-bottom: 5px;
    opacity: 0.7;
}

.current-operand {
    color: var(--display-text);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: right;
    word-wrap: break-word;
    word-break: break-all;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

/* ===== Button Grid ===== */
.button-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

/* ===== Button Base Styles ===== */
.btn {
    border: none;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 
        5px 5px 15px var(--shadow-dark),
        -5px -5px 15px var(--shadow-light);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 
        7px 7px 20px var(--shadow-dark),
        -7px -7px 20px var(--shadow-light);
}

.btn:active {
    transform: scale(0.95);
    box-shadow: 
        inset 3px 3px 10px var(--shadow-dark),
        inset -3px -3px 10px var(--shadow-light);
}

/* ===== Button Types ===== */
.btn-number {
    background: var(--btn-number);
    color: var(--btn-number-text);
}

.btn-operator {
    background: var(--btn-operator);
    color: var(--btn-operator-text);
    font-size: 1.5rem;
}

.btn-function {
    background: var(--btn-function);
    color: var(--btn-function-text);
    font-size: 1rem;
}

.btn-equals {
    background: var(--btn-equals);
    color: var(--btn-equals-text);
    grid-column: span 5;
    font-size: 1.8rem;
    font-weight: 700;
}

.btn-clear {
    background: var(--btn-clear);
    color: var(--btn-clear-text);
}

.btn-delete {
    background: var(--btn-delete);
    color: var(--btn-delete-text);
}

/* ===== Responsive Design ===== */
@media (max-width: 500px) {
    .calculator {
        padding: 20px;
        border-radius: 20px;
    }
    
    .display-section {
        padding: 20px;
        min-height: 100px;
    }
    
    .current-operand {
        font-size: 2rem;
    }
    
    .previous-operand {
        font-size: 1rem;
    }
    
    .btn {
        padding: 15px;
        font-size: 1rem;
        border-radius: 12px;
    }
    
    .btn-function {
        font-size: 0.85rem;
    }
    
    .btn-equals {
        font-size: 1.5rem;
    }
    
    .button-grid {
        gap: 8px;
    }
}

@media (max-width: 380px) {
    .button-grid {
        gap: 6px;
    }
    
    .btn {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .btn-function {
        font-size: 0.75rem;
        padding: 10px;
    }
}
