@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Inter:wght@300;400;600;700&display=swap');

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cyber Theme (Default) */
    --bg-primary: #0a0e27;
    --bg-secondary: #151932;
    --bg-tertiary: #1e2542;
    --accent-primary: #00ff88;
    --accent-secondary: #00d4ff;
    --accent-danger: #ff4757;
    --text-primary: #ffffff;
    --text-secondary: #a0a8c0;
    --border-color: rgba(0, 255, 136, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-neon: 0 0 20px rgba(0, 255, 136, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    margin-bottom: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 28px;
    color: var(--accent-primary);
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.icon-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(0, 255, 136, 0.1);
    transform: translateY(-2px);
}

.icon-btn.danger:hover {
    border-color: var(--accent-danger);
    background: rgba(255, 71, 87, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: start;
}

/* Calculator Section */
.calculator-card {
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 30px;
    max-width: 600px;
}

/* Mode Switcher */
.mode-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    padding: 6px;
    background: var(--bg-tertiary);
    border-radius: 12px;
}

.mode-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

/* Display */
.display-container {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.display-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 136, 0.05), transparent);
    animation: scan 3s linear infinite;
}

@keyframes scan {
    0%, 100% { left: -100%; }
    50% { left: 100%; }
}

.display-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.mode-indicator {
    color: var(--accent-primary);
}

.memory-indicator {
    color: var(--accent-secondary);
}

.expression-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    color: var(--text-secondary);
    min-height: 30px;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.result-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    min-height: 60px;
    display: flex;
    align-items: center;
    word-wrap: break-word;
}

.error-display {
    color: var(--accent-danger);
    font-size: 14px;
    margin-top: 10px;
    font-weight: 600;
}

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

.calc-btn {
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.calc-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(0, 255, 136, 0.2) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
    border-radius: 50%;
}

.calc-btn:hover::before {
    width: 200px;
    height: 200px;
}

.calc-btn:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
}

.calc-btn:active {
    transform: translateY(0);
}

.calc-btn.operator {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.3);
    color: var(--accent-secondary);
}

.calc-btn.function {
    background: rgba(255, 71, 87, 0.1);
    border-color: rgba(255, 71, 87, 0.3);
    color: var(--accent-danger);
    font-size: 16px;
}

.calc-btn.equals {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    font-size: 24px;
    font-weight: 700;
}

.calc-btn.zero {
    grid-column: span 2;
}

/* History Panel */
.history-panel {
    width: 350px;
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    padding: 25px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-primary);
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.history-item {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    border-left: 3px solid var(--accent-primary);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background: rgba(0, 255, 136, 0.1);
    transform: translateX(5px);
}

.history-expression {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.history-result {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Footer */
.app-footer {
    margin-top: 30px;
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.app-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.app-footer a:hover {
    text-decoration: underline;
}

.version {
    margin-top: 5px;
    font-size: 12px;
    opacity: 0.7;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.modal-header h3 {
    font-size: 20px;
    color: var(--accent-primary);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.theme-card {
    padding: 15px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.theme-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-3px);
}

.theme-preview {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.cyber-preview {
    background: linear-gradient(135deg, #0a0e27, #00ff88);
}

.dark-preview {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.light-preview {
    background: linear-gradient(135deg, #f0f0f0, #ffffff);
}

.nord-preview {
    background: linear-gradient(135deg, #2e3440, #88c0d0);
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .history-panel {
        width: 100%;
    }

    .calculator-card {
        padding: 20px;
    }

    .result-display {
        font-size: 36px;
    }

    .buttons-grid {
        gap: 8px;
    }

    .calc-btn {
        padding: 15px;
        font-size: 18px;
    }
}

/* Scrollbar */
.history-panel::-webkit-scrollbar {
    width: 8px;
}

.history-panel::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.history-panel::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.history-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 136, 0.8);
}
