/* 
   CALCULATOR - EXPERT WEB TOOLS
   Theme: 2025 Glassmorphism
*/

@font-face { font-family: 'Inter'; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Roboto Mono'; src: url('/fonts/roboto-mono-v31-latin-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
    --bg-dark: #0a0a0f;
    --primary-accent: #3b82f6;
    --secondary-accent: #8b5cf6;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --card-bg: rgba(25, 25, 35, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --input-bg: rgba(0, 0, 0, 0.3);
    
    --btn-num: rgba(255, 255, 255, 0.05);
    --btn-fn: rgba(255, 255, 255, 0.02);
    --btn-op: rgba(59, 130, 246, 0.15);
    --btn-danger: rgba(239, 68, 68, 0.15);
    
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-code: 'Roboto Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background-color: var(--bg-dark); color: var(--text-main); font-family: var(--font-body); min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; }

.background-glow {
    position: fixed; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.08) 0%, rgba(10, 10, 15, 0) 50%);
    z-index: -1; pointer-events: none;
}

/* Header */
.tool-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 5%; max-width: 1400px; margin: 0 auto; width: 100%; }
.back-btn { color: var(--text-muted); text-decoration: none; display: flex; align-items: center; gap: 8px; transition: color 0.3s; }
.back-btn:hover { color: var(--primary-accent); }
.logo { font-family: var(--font-heading); font-size: 1.2rem; }
.logo span { color: var(--primary-accent); }

/* Main Layout */
.main-content { flex-grow: 1; padding: 2rem 5%; max-width: 1200px; margin: 0 auto; width: 100%; display: flex; justify-content: center; }
.tool-container { width: 100%; }

.calc-layout {
    display: grid;
    grid-template-columns: 1fr 300px; /* Calculator | History */
    gap: 2rem;
    align-items: start;
}

/* Calculator Card */
.calculator-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 20px; padding: 1.5rem; backdrop-filter: blur(10px);
    box-shadow: 0 15px 50px rgba(0,0,0,0.4);
}

/* Display Screen */
.display-screen {
    background: var(--input-bg); border: 1px solid var(--card-border);
    border-radius: 12px; padding: 1rem 1.5rem; margin-bottom: 1.5rem;
    text-align: right; min-height: 130px; display: flex; flex-direction: column;
    justify-content: flex-end; position: relative;
}

.status-bar {
    position: absolute; top: 10px; left: 15px;
    display: flex; gap: 8px;
}
.mode-badge {
    font-size: 0.75rem; color: var(--text-muted);
    background: transparent; border: none; cursor: pointer; opacity: 0.5;
    font-weight: 700; padding: 2px 0;
}
.mode-badge.active { color: var(--primary-accent); opacity: 1; }

.calc-history {
    font-family: var(--font-code); color: var(--text-muted); font-size: 1rem;
    min-height: 1.5rem; margin-bottom: 5px; opacity: 0.7; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.calc-input {
    width: 100%; background: transparent; border: none; color: #fff;
    font-family: var(--font-heading); font-size: 2.5rem; text-align: right;
    outline: none; padding: 0; margin: 0;
}

/* Keypad Grid */
.keypad-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

/* Buttons */
.btn {
    border: none; border-radius: 12px; padding: 15px 0;
    font-size: 1.1rem; font-family: var(--font-body); font-weight: 500;
    cursor: pointer; transition: all 0.1s; user-select: none;
    display: flex; align-items: center; justify-content: center;
}
.btn:active { transform: scale(0.95); }

.btn.num { background: var(--btn-num); color: #fff; font-weight: 600; font-size: 1.25rem; }
.btn.num:hover { background: rgba(255,255,255,0.1); }

.btn.fn { background: var(--btn-fn); color: var(--secondary-accent); font-size: 1rem; }
.btn.fn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.btn.op { background: var(--btn-op); color: var(--primary-accent); font-size: 1.3rem; }
.btn.op:hover { background: rgba(59, 130, 246, 0.3); }

.btn.danger { background: var(--btn-danger); color: #ef4444; }
.btn.danger:hover { background: rgba(239, 68, 68, 0.3); }

.btn.equals {
    background: var(--primary-accent); color: #fff;
    grid-column: span 1; grid-row: span 2; height: 100%;
}
.btn.equals:hover { background: #2563eb; }

/* Zero spans 2 columns on bottom row */
.zero-btn { grid-column: span 2; }

/* History Panel */
.history-panel {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 20px; padding: 1.5rem; height: 100%; max-height: 700px;
    display: flex; flex-direction: column;
}
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; border-bottom: 1px solid var(--card-border); padding-bottom: 10px; }
.history-header h3 { font-size: 1rem; color: var(--text-muted); text-transform: uppercase; margin: 0; }
.history-header button { background: none; border: none; color: var(--text-muted); cursor: pointer; }
.history-header button:hover { color: #ef4444; }

.history-list { overflow-y: auto; flex-grow: 1; display: flex; flex-direction: column; gap: 10px; }
.hist-item {
    background: rgba(255,255,255,0.03); padding: 10px; border-radius: 8px;
    cursor: pointer; text-align: right; border: 1px solid transparent;
}
.hist-item:hover { border-color: var(--card-border); background: rgba(255,255,255,0.05); }
.hist-eq { display: block; font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-code); margin-bottom: 4px; }
.hist-res { display: block; font-size: 1.1rem; color: #fff; font-weight: bold; }
.empty-state { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-top: 2rem; font-style: italic; }

/* RESPONSIVENESS */
@media (max-width: 900px) {
    .calc-layout { grid-template-columns: 1fr; }
    .history-panel { max-height: 250px; order: 2; }
}

@media (max-width: 500px) {
    .main-content { padding: 1rem; }
    .calculator-card { padding: 1rem; }
    .display-screen { padding: 1rem; min-height: 100px; }
    .calc-input { font-size: 2rem; }
    
    .keypad-grid { gap: 8px; }
    .btn { padding: 12px 0; font-size: 1rem; border-radius: 8px; }
    .btn.num { font-size: 1.2rem; }
}