/*CSS SETUP*/
:root {
    /* Light Mode - Warm Theme */
    --bg-primary: linear-gradient(135deg, #ff9a56 0%, #ff6b6b 50%, #ee5a6f 100%);
    --bg-calculator: rgba(255, 255, 255, 0.95);
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --display-bg: #f8f9fa;
    --display-text: #2d3436;
    --preview-text: #95a5a6;
    
    --btn-number-bg: #ffffff;
    --btn-number-text: #2d3436;
    --btn-number-hover: #ff9a56;
    
    --btn-operator-bg: #ffe5d9;
    --btn-operator-text: #ff6b6b;
    --btn-operator-hover: #ff6b6b;
    
    --btn-equals-bg: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    --btn-equals-text: #ffffff;
    
    --btn-function-bg: #fff5f0;
    --btn-function-text: #ff6b6b;
    
    --shadow-sm: 0 2px 8px rgba(238, 90, 111, 0.1);
    --shadow-md: 0 4px 16px rgba(238, 90, 111, 0.15);
    --shadow-lg: 0 8px 32px rgba(238, 90, 111, 0.2);
    
    --shape-color-1: rgba(255, 154, 86, 0.3);
    --shape-color-2: rgba(255, 107, 107, 0.3);
    --shape-color-3: rgba(238, 90, 111, 0.3);
}

/* Dark Mode Theme */
[data-theme="dark"] {
    --bg-primary: linear-gradient(135deg, #2d3436 0%, #1e272e 50%, #0a0e27 100%);
    --bg-calculator: rgba(45, 52, 54, 0.95);
    --text-primary: #dfe6e9;
    --text-secondary: #b2bec3;
    --display-bg: #1e272e;
    --display-text: #dfe6e9;
    --preview-text: #636e72;
    
    --btn-number-bg: #2d3436;
    --btn-number-text: #dfe6e9;
    --btn-number-hover: #ff6b6b;
    
    --btn-operator-bg: #3d3838;
    --btn-operator-text: #ff9a56;
    --btn-operator-hover: #ff6b6b;
    
    --btn-equals-bg: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    --btn-equals-text: #ffffff;
    
    --btn-function-bg: #1e272e;
    --btn-function-text: #ff9a56;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    --shape-color-1: rgba(255, 154, 86, 0.1);
    --shape-color-2: rgba(255, 107, 107, 0.1);
    --shape-color-3: rgba(238, 90, 111, 0.1);
}

/*GLOBAL STYLES*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Exo 2', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    transition: background 0.4s ease;
}

/*Animated Background Elements*/
.bg-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.6;
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: var(--shape-color-1);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 400px;
    height: 400px;
    background: var(--shape-color-2);
    bottom: 10%;
    right: 10%;
    animation-delay: 5s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: var(--shape-color-3);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 10s;
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(50px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-50px, 50px) scale(0.9);
    }
}

/*Container and Calculator*/
.container {
    position: relative;
    z-index: 1;
    padding: 20px;
    animation: slideIn 0.6s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.calculator {
    background: var(--bg-calculator);
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.calculator:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 48px rgba(238, 90, 111, 0.25);
}

/*THEME*/
.theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-calculator);
    border: none;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 100;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover {
    transform: rotate(180deg) scale(1.1);
    box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
    transform: rotate(180deg) scale(0.95);
}

/*HEADER*/
.calculator-header {
    text-align: center;
    margin-bottom: 24px;
}

.calculator-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
    animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/*History Display*/
.history {
    background: var(--display-bg);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: right;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: background 0.3s ease;
}

/*DisPlay Screen*/
.display-container {
    background: var(--display-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: background 0.3s ease;
}

.display-preview {
    color: var(--preview-text);
    font-size: 18px;
    text-align: right;
    min-height: 28px;
    margin-bottom: 8px;
    font-weight: 300;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.display-main {
    color: var(--display-text);
    font-size: 42px;
    font-weight: 700;
    text-align: right;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.3s ease;
}

.display-main.error {
    color: #ff6b6b;
    font-size: 24px;
}

/*BUTTONS*/
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.btn {
    border: none;
    border-radius: 16px;
    padding: 24px;
    font-size: 20px;
    font-weight: 600;
    font-family: 'Exo 2', sans-serif;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.3s ease;
    box-shadow: var(--shadow-sm);
    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.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0) scale(0.95);
    box-shadow: var(--shadow-sm);
}

/* Number Buttons */
.btn-number {
    background: var(--btn-number-bg);
    color: var(--btn-number-text);
}

.btn-number:hover {
    background: var(--btn-number-hover);
    color: #ffffff;
}

/* Operator Buttons */
.btn-operator {
    background: var(--btn-operator-bg);
    color: var(--btn-operator-text);
    font-weight: 700;
}

.btn-operator:hover {
    background: var(--btn-operator-hover);
    color: #ffffff;
}

/* Equals Button */
.btn-equals {
    background: var(--btn-equals-bg);
    color: var(--btn-equals-text);
    font-size: 28px;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
}

.btn-equals:hover {
    box-shadow: 0 6px 24px rgba(255, 107, 107, 0.6);
}

/* Function Buttons (AC, DEL) */
.btn-function {
    background: var(--btn-function-bg);
    color: var(--btn-function-text);
    font-weight: 700;
}

.btn-function:hover {
    background: var(--btn-operator-hover);
    color: #ffffff;
}

/*FOOTER*/
.calculator-footer {
    margin-top: 24px;
    text-align: center;
}

.hint {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 300;
    animation: hintFade 4s ease-in-out infinite;
}

@keyframes hintFade {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

/*RESPONSIVE DESIGN*/
@media (max-width: 480px) {
    .calculator {
        padding: 24px;
        max-width: 100%;
    }
    
    .calculator-title {
        font-size: 24px;
    }
    
    .display-main {
        font-size: 36px;
    }
    
    .display-preview {
        font-size: 16px;
    }
    
    .btn {
        padding: 20px;
        font-size: 18px;
    }
    
    .btn-equals {
        font-size: 24px;
    }
    
    .buttons {
        gap: 10px;
    }
    
    .theme-toggle {
        width: 48px;
        height: 48px;
        top: 16px;
        right: 16px;
        font-size: 20px;
    }
}

@media (max-width: 360px) {
    .btn {
        padding: 16px;
        font-size: 16px;
    }
    
    .display-main {
        font-size: 32px;
    }
}