/* CSS variables for dual themes (Dark by default, Light togglable) */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --calc-bg: rgba(30, 41, 59, 0.45);
    --calc-border: rgba(255, 255, 255, 0.08);
    --calc-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --btn-num-bg: rgba(255, 255, 255, 0.04);
    --btn-num-hover: rgba(255, 255, 255, 0.09);
    --btn-num-color: #f8fafc;
    
    --btn-operator-bg: rgba(249, 115, 22, 0.15);
    --btn-operator-hover: rgba(249, 115, 22, 0.3);
    --btn-operator-color: #fb923c;
    
    --btn-action-bg: rgba(148, 163, 184, 0.08);
    --btn-action-hover: rgba(148, 163, 184, 0.18);
    --btn-action-color: #cbd5e1;
    
    --btn-equals-bg: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --btn-equals-hover: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
    --btn-equals-color: #ffffff;
    --btn-equals-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
    
    --display-bg: rgba(15, 23, 42, 0.6);
    --display-border: rgba(255, 255, 255, 0.05);
    
    --circle-1: linear-gradient(135deg, #ea580c 0%, #f43f5e 100%);
    --circle-2: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    --calc-bg: rgba(255, 255, 255, 0.45);
    --calc-border: rgba(255, 255, 255, 0.4);
    --calc-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    
    --btn-num-bg: rgba(255, 255, 255, 0.6);
    --btn-num-hover: rgba(255, 255, 255, 0.85);
    --btn-num-color: #0f172a;
    
    --btn-operator-bg: rgba(249, 115, 22, 0.12);
    --btn-operator-hover: rgba(249, 115, 22, 0.25);
    --btn-operator-color: #ea580c;
    
    --btn-action-bg: rgba(71, 85, 105, 0.08);
    --btn-action-hover: rgba(71, 85, 105, 0.18);
    --btn-action-color: #334155;
    
    --btn-equals-bg: linear-gradient(135deg, #ea580c 0%, #d97706 100%);
    --btn-equals-hover: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --btn-equals-color: #ffffff;
    --btn-equals-shadow: 0 4px 15px rgba(234, 88, 12, 0.3);
    
    --display-bg: rgba(255, 255, 255, 0.65);
    --display-border: rgba(255, 255, 255, 0.5);
    
    --circle-1: linear-gradient(135deg, #fb923c 0%, #f43f5e 100%);
    --circle-2: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    user-select: none;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-gradient);
    overflow: hidden;
    position: relative;
    padding: 20px;
}

/* Background decorative blurring circles */
.background-decorations {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
}

.circle-1 {
    width: 300px;
    height: 300px;
    background: var(--circle-1);
    top: 15%;
    left: 15%;
    animation: floating-1 12s infinite alternate ease-in-out;
}

.circle-2 {
    width: 350px;
    height: 350px;
    background: var(--circle-2);
    bottom: 15%;
    right: 15%;
    animation: floating-2 15s infinite alternate ease-in-out;
}

@keyframes floating-1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, -40px) scale(1.1); }
}

@keyframes floating-2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-50px, 30px) scale(0.9); }
}

/* Calculator Container */
.calculator-container {
    width: 100%;
    max-width: 380px;
    background: var(--calc-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--calc-border);
    border-radius: 30px;
    padding: 25px;
    box-shadow: var(--calc-shadow);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    justify-content: flex-end;
}

#theme-btn {
    background: var(--btn-action-bg);
    border: 1px solid var(--calc-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    outline: none;
    transition: transform 0.2s ease, background 0.2s ease;
}

#theme-btn:hover {
    background: var(--btn-action-hover);
    transform: scale(1.08);
}

#theme-btn:active {
    transform: scale(0.95);
}

/* Screen / Display Display Layout */
.display {
    background: var(--display-bg);
    border: 1px solid var(--display-border);
    border-radius: 20px;
    padding: 20px;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 6px;
    overflow: hidden;
    word-wrap: break-word;
    word-break: break-all;
}

.history-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    min-height: 22px;
    width: 100%;
    text-align: right;
    font-family: 'Share Tech Mono', monospace;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.history-text::-webkit-scrollbar {
    display: none; /* Safari & Chrome */
}

.current-text {
    font-size: 2.2rem;
    font-weight: 500;
    color: var(--text-primary);
    width: 100%;
    text-align: right;
    font-family: 'Share Tech Mono', monospace;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.current-text::-webkit-scrollbar {
    display: none;
}

/* Button Grid layout */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.btn {
    aspect-ratio: 1;
    border: none;
    border-radius: 20px;
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Active touch ripple emulation */
.btn::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn:active::after {
    width: 150%;
    height: 150%;
}

.btn:active {
    transform: scale(0.92);
}

/* Number Button style */
.btn-number {
    background: var(--btn-num-bg);
    color: var(--btn-num-color);
    border: 1px solid var(--calc-border);
}

.btn-number:hover {
    background: var(--btn-num-hover);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

/* Operator Button style */
.btn-operator {
    background: var(--btn-operator-bg);
    color: var(--btn-operator-color);
    font-size: 1.4rem;
}

.btn-operator:hover {
    background: var(--btn-operator-hover);
}

/* Action Button style (AC, backspace, %, +/-) */
.btn-action {
    background: var(--btn-action-bg);
    color: var(--btn-action-color);
}

.btn-action:hover {
    background: var(--btn-action-hover);
}

/* Equal Button style */
.btn-equals {
    background: var(--btn-equals-bg);
    color: var(--btn-equals-color);
    font-size: 1.5rem;
    box-shadow: var(--btn-equals-shadow);
}

.btn-equals:hover {
    background: var(--btn-equals-hover);
    transform: translateY(-1px);
    box-shadow: var(--btn-equals-shadow), 0 5px 15px rgba(249, 115, 22, 0.2);
}

.btn-equals:active {
    transform: scale(0.95);
}

/* Footer style */
.footer {
    margin-top: 25px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    z-index: 10;
    text-align: center;
    opacity: 0.8;
}

.footer i {
    animation: beat 0.8s infinite alternate;
}

@keyframes beat {
    to { transform: scale(1.15); }
}

/* Responsive adjustments */
@media (max-height: 650px) {
    .calculator-container {
        padding: 15px;
        gap: 12px;
    }
    .display {
        min-height: 85px;
        padding: 12px;
    }
    .current-text {
        font-size: 1.8rem;
    }
    .btn {
        font-size: 1.15rem;
        border-radius: 15px;
    }
    .buttons {
        gap: 8px;
    }
    .footer {
        margin-top: 15px;
    }
}
