/* SmartCalc - Modern Calculator Stylesheet
 * Author: Anil Kumar Putta
 * Description: Clean, responsive design with dark theme
 */

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --calculator-bg: #0f3460;
    --display-bg: #0a2239;
    --display-text: #ffffff;
    --display-text-dim: rgba(255, 255, 255, 0.6);
    --btn-number: #2d2d44;
    --btn-operator: #ff6b35;
    --btn-clear: #e74c3c;
    --btn-delete: #f39c12;
    --btn-equals: #2ecc71;
    --btn-memory: #9b59b6;
    --btn-special: #3498db;
    --btn-hover: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.4);
    --transition: 0.3s ease;
}

/* Keyboard press visual feedback */
.btn:active {
    transform: translateY(1px) scale(0.98);
}

/* Light theme */
body.light-theme {
    --bg-gradient-start: #f0f0f0;
    --bg-gradient-end: #e0e0e0;
    --calculator-bg: #ffffff;
    --display-bg: #f5f5f5;
    --display-text: #2c3e50;
    --display-text-dim: rgba(44, 62, 80, 0.6);
    --btn-number: #ecf0f1;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.25);
}

body {
    font-family: 'Roboto', 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: 1rem;
    transition: background var(--transition);
}

/* Controls */
.controls {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.5rem;
    z-index: 1000;
}

.control-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: var(--calculator-bg);
    color: var(--display-text);
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-hover);
}

.control-btn:active {
    transform: scale(0.95);
}

/* History Sidebar */
.history-sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    background: var(--calculator-bg);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    padding: 2rem 1.5rem;
    overflow-y: auto;
    transition: right var(--transition);
    z-index: 999;
}

.history-sidebar.active {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--display-bg);
}

.history-header h3 {
    color: var(--display-text);
    font-size: 1.5rem;
    margin: 0;
}

.clear-history-btn {
    background: var(--btn-clear);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.clear-history-btn:hover {
    background: #c0392b;
    transform: scale(1.05);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-empty {
    color: var(--display-text-dim);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.history-item {
    background: var(--display-bg);
    padding: 1rem;
    border-radius: 8px;
    color: var(--display-text);
    cursor: pointer;
    transition: all 0.2s;
    animation: slideIn 0.3s ease;
}

.history-item:hover {
    background: var(--btn-number);
    transform: translateX(-5px);
}

.history-item .expression {
    font-size: 0.9rem;
    color: var(--display-text-dim);
    margin-bottom: 0.25rem;
}

.history-item .result {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: 'Roboto Mono', monospace;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Container */
.container {
    width: 100%;
    max-width: 400px;
}

/* Calculator */
.calculator {
    background: var(--calculator-bg);
    border-radius: 15px;
    box-shadow: var(--shadow);
    padding: 2rem;
    transition: box-shadow 0.3s ease;
}

.calculator:hover {
    box-shadow: var(--shadow-hover);
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: var(--display-bg);
    border-radius: 10px;
    padding: 0.5rem;
}

.mode-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--display-text-dim);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mode-btn.active {
    background: var(--btn-operator);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Base Display for Programmer Mode */
.base-display {
    background: var(--display-bg);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    font-family: 'Roboto Mono', monospace;
}

.base-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.base-row:last-child {
    border-bottom: none;
}

.base-label {
    font-weight: 700;
    color: var(--btn-operator);
    font-size: 0.9rem;
    min-width: 50px;
}

.base-value {
    color: var(--display-text);
    font-size: 1rem;
    word-break: break-all;
}

/* Mode Indicator */
.mode-indicator {
    font-size: 0.75rem;
    color: var(--display-text-dim);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Display */
.display {
    background: var(--display-bg);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    word-wrap: break-word;
    word-break: break-all;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
    padding: 0.25rem;
}

.copy-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

.copy-btn.copied {
    animation: copyPulse 0.6s ease;
}

@keyframes copyPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.previous-operand {
    font-family: 'Roboto Mono', monospace;
    color: var(--display-text-dim);
    font-size: 1.2rem;
    min-height: 1.5rem;
    opacity: 0.8;
}

.current-operand {
    font-family: 'Roboto Mono', monospace;
    color: var(--display-text);
    font-size: 2.5rem;
    font-weight: 700;
    min-height: 3rem;
    transition: font-size 0.2s ease;
}

/* Auto-resize for long numbers */
.current-operand.small {
    font-size: 2rem;
}

.current-operand.smaller {
    font-size: 1.5rem;
}

/* Buttons Grid */
.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

/* Button Styles */
.btn {
    font-family: 'Roboto', sans-serif;
    font-size: 1.5rem;
    padding: 1.5rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: var(--btn-number);
    color: var(--display-text);
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:focus {
    outline: 3px solid var(--btn-operator);
    outline-offset: 2px;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

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

/* Ripple effect */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn.ripple::after {
    width: 300px;
    height: 300px;
}

/* Button Types */
.btn-number {
    background: var(--btn-number);
}

.btn-number:hover {
    background: #3d3d54;
}

.btn-operator {
    background: var(--btn-operator);
}

.btn-operator:hover {
    background: #ff7f4f;
}

.btn-clear {
    background: var(--btn-clear);
}

.btn-clear:hover {
    background: #ed5f4f;
}

.btn-delete {
    background: var(--btn-delete);
}

.btn-delete:hover {
    background: #f5aa26;
}

.btn-equals {
    background: var(--btn-equals);
}

.btn-equals:hover {
    background: #3fdb81;
}

.btn-memory {
    background: var(--btn-memory);
    font-size: 1.2rem;
}

.btn-memory:hover {
    background: #8e44ad;
}

.btn-special {
    background: var(--btn-special);
}

.btn-special:hover {
    background: #2980b9;
}

.btn-scientific {
    background: #16a085;
    font-size: 1.1rem;
}

.btn-scientific:hover {
    background: #1abc9c;
}

.btn-programmer {
    background: #e67e22;
    font-size: 1.1rem;
}

.btn-programmer:hover {
    background: #f39c12;
}

.btn-bitwise {
    background: #d35400;
    font-size: 1rem;
}

.btn-bitwise:hover {
    background: #e67e22;
}

.btn-zero {
    grid-column: span 1;
}

/* Result pulse animation */
@keyframes resultPulse {
    0%, 100% {
        transform: scale(1);
        color: var(--display-text);
    }
    50% {
        transform: scale(1.05);
        color: var(--btn-equals);
    }
}

.current-operand.pulse {
    animation: resultPulse 0.5s ease;
}

/* Responsive Design */
@media (max-width: 500px) {
    .controls {
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .history-sidebar {
        width: 100%;
        right: -100%;
    }
    
    .container {
        max-width: 90vw;
    }
    
    .calculator {
        padding: 1.5rem;
    }
    
    .display {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .previous-operand {
        font-size: 1rem;
    }
    
    .current-operand {
        font-size: 2rem;
    }
    
    .current-operand.small {
        font-size: 1.5rem;
    }
    
    .current-operand.smaller {
        font-size: 1.2rem;
    }
    
    .btn {
        font-size: 1.25rem;
        padding: 1.25rem;
        min-height: 60px;
    }
    
    .btn-memory {
        font-size: 1rem;
    }
    
    .buttons {
        gap: 0.5rem;
    }
}

@media (max-width: 350px) {
    .current-operand {
        font-size: 1.75rem;
    }
    
    .btn {
        font-size: 1.1rem;
        padding: 1rem;
    }
}

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

.btn.pressed {
    animation: buttonPress 0.2s ease;
}

/* Error state */
.display.error .current-operand {
    color: var(--btn-clear);
}
