/* Scientific Calculator Specific Styles */
.scientific-calculator {
    background-color: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 10px 20px var(--shadow-color);
    padding: 1.5rem;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

/* Enhanced Display */
.calculator-display {
    margin-bottom: 1rem;
}

.expression-display {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem 0.5rem 0 0;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-height: 1.5rem;
    text-align: right;
    opacity: 0.7;
    font-family: 'Courier New', monospace;
}

.calculator-display input {
    width: 100%;
    padding: 1rem;
    font-size: 1.8rem;
    text-align: right;
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 0 0 0.5rem 0.5rem;
    border-top: none;
    outline: none;
    font-family: 'Courier New', monospace;
}

/* Mode Toggle Buttons */
.mode-toggles {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.mode-btn, .shift-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.mode-btn.active, .shift-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.mode-btn:hover, .shift-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Scientific Calculator Grid */
.scientific-keys {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Button Styles */
.scientific-keys button {
    padding: 0.8rem 0.4rem;
    font-size: 0.9rem;
    border: none;
    border-radius: 0.375rem;
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    font-weight: 500;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scientific-keys button:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.scientific-keys button:active {
    transform: scale(0.95);
}

/* Specific Button Types */
.key-function {
    background-color: #f3f4f6 !important;
    color: var(--primary-color) !important;
    font-weight: 600;
}

.key-function:hover {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.key-operator {
    background-color: #fbbf24 !important;
    color: white !important;
    font-weight: bold;
}

.key-operator:hover {
    background-color: #f59e0b !important;
}

.key-memory {
    background-color: #8b5cf6 !important;
    color: white !important;
    font-weight: 600;
}

.key-memory:hover {
    background-color: #7c3aed !important;
}

.key-equals {
    background-color: var(--primary-color) !important;
    color: white !important;
    grid-column: span 1;
    font-weight: bold;
    font-size: 1.2rem;
}

.key-equals:hover {
    background-color: var(--secondary-color) !important;
}

.key-clear, .key-backspace {
    background-color: #ef4444 !important;
    color: white !important;
    font-weight: 600;
}

.key-clear:hover, .key-backspace:hover {
    background-color: #dc2626 !important;
}

.key-number {
    background-color: var(--bg-color) !important;
    color: var(--text-color) !important;
    font-weight: 600;
    font-size: 1.1rem;
}

.key-number:hover {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.key-decimal {
    background-color: var(--bg-color) !important;
    color: var(--text-color) !important;
    font-weight: 600;
    font-size: 1.2rem;
}

.key-decimal:hover {
    background-color: var(--primary-color) !important;
    color: white !important;
}

.zero {
    grid-column: span 2;
}

/* History Panel */
.history-panel {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.history-panel h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: var(--text-color);
}

.history-list {
    margin-bottom: 0.5rem;
}

.history-item {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    cursor: pointer;
}

.history-item:hover {
    background-color: var(--card-bg);
}

.history-item:last-child {
    border-bottom: none;
}

.clear-history {
    width: 100%;
    padding: 0.5rem;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
}

.clear-history:hover {
    background-color: #dc2626;
}

/* Error State */
.error {
    color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

[data-theme="dark"] .error {
    background-color: #450a0a !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .scientific-calculator {
        padding: 1rem;
        max-width: 100%;
    }

    .scientific-keys {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.4rem;
    }

    .scientific-keys button {
        padding: 0.6rem 0.2rem;
        font-size: 0.8rem;
        min-height: 2.5rem;
    }

    .calculator-display input {
        font-size: 1.5rem;
        padding: 0.8rem;
    }

    .expression-display {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    .mode-toggles {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .mode-btn, .shift-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .scientific-keys {
        grid-template-columns: repeat(4, 1fr);
    }

    .scientific-keys button {
        padding: 0.5rem 0.1rem;
        font-size: 0.7rem;
        min-height: 2.2rem;
    }

    .calculator-display input {
        font-size: 1.3rem;
        padding: 0.6rem;
    }
}

/* Focus States for Accessibility */
.scientific-keys button:focus,
.mode-btn:focus,
.shift-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.calculator-display input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color);
}

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

.scientific-keys button:active {
    animation: buttonPress 0.1s ease-in-out;
}

/* Special Function Indicators */
.key-function[data-function="sin"],
.key-function[data-function="cos"],
.key-function[data-function="tan"] {
    background-color: #10b981 !important;
    color: white !important;
}

.key-function[data-function="sin"]:hover,
.key-function[data-function="cos"]:hover,
.key-function[data-function="tan"]:hover {
    background-color: #059669 !important;
}

.key-function[data-function="log"],
.key-function[data-function="ln"],
.key-function[data-function="log2"] {
    background-color: #3b82f6 !important;
    color: white !important;
}

.key-function[data-function="log"]:hover,
.key-function[data-function="ln"]:hover,
.key-function[data-function="log2"]:hover {
    background-color: #2563eb !important;
}
