/* Scientific Calculator Styles */
.scientific-calculator-container {
    max-width: 100%;
    margin: 5px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.calculator {
    background: linear-gradient(145deg, #ffffff, #f8fafc);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 10px;
    max-width: 480px;
    margin: 0 auto;
    border: 1px solid #e2e8f0;
}

.calculator-display {
    background: linear-gradient(145deg, #1e293b, #334155);
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.history {
    color: #94a3b8;
    font-size: 14px;
    min-height: 20px;
    text-align: right;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
}

#display {
    width: 100%;
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 20px;
    font-weight: 300;
    text-align: right;
    outline: none;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.button-row {
    display: contents;
}

.btn {
    height: 60px;
    border: none;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

/* Button Categories */
.btn.number {
    background: linear-gradient(145deg, #f8fafc, #e2e8f0);
    color: #1e293b;
}

.btn.number:hover {
    background: linear-gradient(145deg, #e2e8f0, #cbd5e1);
}

.btn.operator {
    background: linear-gradient(145deg, #3b82f6, #2563eb);
    color: white;
}

.btn.operator:hover {
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
}

.btn.function {
    background: linear-gradient(145deg, #10b981, #059669);
    color: white;
    font-size: 14px;
}

.btn.function:hover {
    background: linear-gradient(145deg, #059669, #047857);
}

.btn.equals {
    background: linear-gradient(145deg, #f59e0b, #d97706);
    color: white;
    grid-row: span 2;
}

.btn.equals:hover {
    background: linear-gradient(145deg, #d97706, #b45309);
}

.btn.clear {
    background: linear-gradient(145deg, #ef4444, #dc2626);
    color: white;
}

.btn.clear:hover {
    background: linear-gradient(145deg, #dc2626, #b91c1c);
}

.btn.memory {
    background: linear-gradient(145deg, #8b5cf6, #7c3aed);
    color: white;
    font-size: 14px;
}

.btn.memory:hover {
    background: linear-gradient(145deg, #7c3aed, #6d28d9);
}

/* Special button sizing */
.btn[colspan="2"] {
    grid-column: span 2;
}

/* Calculator History */
.calculator-history {
    background: #f8fafc;
    border-radius: 2px;
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.calculator-history h4 {
    margin: 0 0 2px 0;
    color: #374151;
    font-size: 16px;
    font-weight: 600;
}

#calculation-history {
    list-style: none;
    padding: 0;
    margin: 0 0 2px 0;
    max-height: 120px;
    overflow-y: auto;
}

#calculation-history li {
    padding: 6px 12px;
    background: white;
    margin-bottom: 4px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#calculation-history li:hover {
    background: #f3f4f6;
}

.clear-history {
    width: 100%;
    height: 36px;
    background: linear-gradient(145deg, #6b7280, #4b5563);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-history:hover {
    background: linear-gradient(145deg, #4b5563, #374151);
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .calculator {
        margin: 2px;
        padding: 5px;
        max-width: none;
    }
    
    .calculator-buttons {
        gap: 8px;
    }
    
    .btn {
        height: 50px;
        font-size: 10px;
    }
    
    #display {
        font-size: 14px;
    }
    
    .calculator-history {
        margin-top: 16px;
    }
}

@media (max-width: 480px) {
    .calculator {
        padding: 12px;
    }
    
    .calculator-buttons {
        gap: 6px;
    }
    
    .btn {
        height: 45px;
        font-size: 13px;
    }
    
    .btn.function {
        font-size: 12px;
    }
    
    #display {
        font-size: 10px;
    }
    
    .calculator-display {
        padding: 16px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .calculator {
        background: linear-gradient(145deg, #1f2937, #111827);
        border-color: #374151;
    }
    
    .calculator-history {
        background: #374151;
    }
    
    .calculator-history h4 {
        color: #f9fafb;
    }
    
    #calculation-history li {
        background: #4b5563;
        color: #f3f4f6;
        border-color: #6b7280;
    }
    
    #calculation-history li:hover {
        background: #6b7280;
    }
}

/* Animation for button press */
@keyframes buttonPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.btn:active {
    animation: buttonPress 0.1s ease;
}

/* Error state */
.calculator-display.error #display {
    color: #ef4444;
}

.calculator-display.error {
    border: 2px solid #ef4444;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}