/*=============================================
  TI-84 Plus CE Calculator — Stylesheet
  A premium, realistic calculator skin
=============================================*/

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

/* --- Wrapper --- */
#ti84-calculator-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 10px;
    font-family: 'Inter', sans-serif;
}

/* --- Calculator Body --- */
.ti84-calculator {
    width: 340px;
    background: linear-gradient(165deg, #232323 0%, #181818 60%, #111 100%);
    border-radius: 28px 28px 22px 22px;
    padding: 24px 18px 22px 18px;
    box-shadow:
        0 20px 60px rgba(0,0,0,0.7),
        0 2px 8px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.07);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

/* --- Screen Bezel --- */
.ti84-screen-bezel {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 14px;
    padding: 10px 12px 8px;
    margin-bottom: 16px;
    border: 2px solid #0a0a15;
    box-shadow:
        inset 0 2px 10px rgba(0,0,0,0.6),
        0 1px 0 rgba(255,255,255,0.05);
}

.ti84-brand-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #5a7faa;
    text-align: center;
    margin-bottom: 6px;
    font-family: 'Inter', sans-serif;
}

.ti84-model-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: #4a6a8a;
    text-align: center;
    margin-top: 6px;
    font-family: 'Inter', sans-serif;
}

/* --- Screen --- */
.ti84-screen {
    background: #0a1628;
    border-radius: 8px;
    height: 170px;
    overflow: hidden;
    position: relative;
    border: 1px solid #060e1a;
    box-shadow: inset 0 2px 12px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
}

.ti84-screen-topbar {
    background: rgba(0, 0, 0, 0.4);
    color: #4dabf7;
    font-size: 9px;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 6px;
    display: flex;
    justify-content: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: pre;
}

.ti84-screen-topbar .ti84-status-item {
    font-weight: 600;
}

.ti84-screen-content {
    padding: 6px 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #c8e6ff;
    line-height: 1.6;
    box-sizing: border-box;
}

.ti84-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    scrollbar-width: none;
}

.ti84-history::-webkit-scrollbar {
    display: none;
}

.ti84-history-entry {
    margin-bottom: 2px;
}

.ti84-history-expr {
    color: #7ab0e0;
    text-align: right;
    font-size: 14px;
    word-break: break-all;
}

.ti84-history-result {
    color: #ffffff;
    text-align: right;
    font-size: 18px;
    font-weight: 600;
}

.ti84-history-error {
    color: #ff6b6b;
    text-align: right;
    font-size: 14px;
}

.ti84-input-line {
    text-align: right;
    min-height: 24px;
    font-size: 18px;
    color: #e0f0ff;
    word-break: break-all;
}

.ti84-cursor {
    animation: ti84blink 0.7s infinite;
    color: #4dabf7;
    font-size: 16px;
}

@keyframes ti84blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Menu Screen Styles --- */
#ti84MenuTabs {
    display: flex;
    background: #e0e0e0;
    color: black;
    font-size: 11px;
    border-bottom: 2px solid #1a2a4e;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
}

.ti84-menu-tab {
    padding: 4px 8px;
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s;
}

.ti84-menu-tab.active {
    background: #ffffff;
    color: #000000;
    font-weight: 800;
}

#ti84MenuList {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
}

.ti84-menu-item {
    padding: 3px 10px;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: #c8e6ff;
}

.ti84-menu-item.active {
    background: #1a4a8e; /* Dark blue selection like the screenshot */
    color: #ffffff;
}

.ti84-cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background-color: #4dabf7;
    margin: 0 1px;
    vertical-align: middle;
    animation: ti84blink 0.8s infinite;
}

/* --- Button Rows --- */
.ti84-btn-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    justify-content: center;
}

/* --- Buttons (Base) --- */
.ti84-btn {
    position: relative;
    border: none;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 4px 6px;
    flex: 1;
    min-width: 0;
    text-align: center;
    transition: all 0.08s ease;
    line-height: 1.2;
    text-transform: lowercase;
    outline: none;
}

.ti84-btn:active {
    transform: scale(0.93) translateY(1px);
}

/* --- Second (top) labels --- */
.ti84-second-label {
    display: block;
    font-size: 7.5px;
    font-weight: 600;
    color: #4dabf7;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
    text-transform: lowercase;
    pointer-events: none;
}

/* --- Alpha (side) labels --- */
.ti84-alpha-label {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 7px;
    font-weight: 700;
    color: #51cf66;
    pointer-events: none;
}

/* --- Graph Row Buttons --- */
.ti84-btn-graph {
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    color: #f0f0f0;
    font-size: 10px;
    padding: 6px 3px 5px;
    border-radius: 5px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.08);
}

.ti84-btn-graph:hover {
    background: linear-gradient(180deg, #444 0%, #333 100%);
}

.ti84-btn-graph:active {
    background: linear-gradient(180deg, #555 0%, #444 100%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* --- D-Pad --- */
.ti84-dpad-area {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.ti84-dpad {
    position: relative;
    width: 140px;
    height: 140px;
    background: #151515;
    border-radius: 50%;
    box-shadow: 
        0 4px 15px rgba(0,0,0,0.8),
        inset 0 2px 5px rgba(255,255,255,0.05);
}

.ti84-dpad-btn {
    position: absolute;
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    color: #f0f0f0;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    outline: none;
    z-index: 2;
}

.ti84-dpad-btn:hover {
    background: linear-gradient(180deg, #333 0%, #222 100%);
}

.ti84-dpad-up {
    top: 5px; left: 50%;
    transform: translateX(-50%);
    width: 48px; height: 42px;
    border-radius: 12px 12px 4px 4px;
    font-size: 18px;
    color: #aaa;
}

.ti84-dpad-down {
    bottom: 5px; left: 50%;
    transform: translateX(-50%);
    width: 48px; height: 42px;
    border-radius: 4px 4px 12px 12px;
    font-size: 18px;
    color: #aaa;
}

.ti84-dpad-left {
    left: 5px; top: 50%;
    transform: translateY(-50%);
    width: 42px; height: 48px;
    border-radius: 12px 4px 4px 12px;
}

.ti84-dpad-left::after {
    content: '◀';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #3b82f6;
    color: white;
    font-size: 10px;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.3);
}

.ti84-dpad-right {
    right: 5px; top: 50%;
    transform: translateY(-50%);
    width: 42px; height: 48px;
    border-radius: 4px 12px 12px 4px;
}

.ti84-dpad-right::after {
    content: '▶';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #3b82f6;
    color: white;
    font-size: 10px;
    border-radius: 4px;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.3);
}

.ti84-dpad-center {
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 58px; height: 58px;
    border-radius: 50%;
    background: #111;
    box-shadow:
        0 4px 10px rgba(0,0,0,0.6),
        inset 0 2px 4px rgba(255,255,255,0.05);
    z-index: 1;
}

/* --- 2nd Button --- */
.ti84-btn-second {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    font-weight: 700;
    text-transform: lowercase;
    box-shadow:
        0 2px 6px rgba(37,99,235,0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
}

.ti84-btn-second:hover {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
}

.ti84-btn-second:active {
    background: #1d4ed8;
}

.ti84-btn-second.active {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow:
        0 0 14px rgba(59,130,246,0.6),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* --- Alpha Button --- */
.ti84-btn-alpha {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    color: #fff;
    font-weight: 700;
    box-shadow:
        0 2px 6px rgba(22,163,74,0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
}

.ti84-btn-alpha:hover {
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
}

.ti84-btn-alpha:active {
    background: #15803d;
}

.ti84-btn-alpha.active {
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
    box-shadow:
        0 0 14px rgba(34,197,94,0.6),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* --- Mode / Del buttons --- */
.ti84-btn-mode {
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    color: #e0e0e0;
    box-shadow:
        0 3px 6px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 12px 4px 6px;
}

.ti84-btn-mode:hover {
    background: linear-gradient(180deg, #333 0%, #222 100%);
}

.ti84-btn-mode:active {
    transform: scale(0.95);
    background: #111;
}

.ti84-btn-mode .ti84-second-label {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 7px;
    font-weight: 700;
}

/* --- Dark function buttons (Math row) --- */
.ti84-btn-dark {
    background: linear-gradient(180deg, #252525 0%, #1a1a1a 100%);
    color: #ffffff;
    border-radius: 8px;
    padding: 12px 4px 6px;
    box-shadow:
        0 3px 6px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(255,255,255,0.08);
    font-size: 12px;
}

.ti84-btn-dark:hover {
    background: linear-gradient(180deg, #2d2d2d 0%, #222 100%);
}

.ti84-btn-dark:active {
    background: #111;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
    transform: scale(0.95) translateY(1px);
}

/* Adjust labels for math row Specifically */
.ti84-btn-dark .ti84-second-label {
    position: absolute;
    top: 3px;
    left: 4px;
    color: #4dabf7;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
}

.ti84-btn-dark .ti84-alpha-label {
    position: absolute;
    top: 3px;
    right: 4px;
    color: #51cf66;
    font-size: 8px;
    font-weight: 700;
}

/* --- Number buttons --- */
.ti84-btn-num {
    background: linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    box-shadow:
        0 2px 5px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.1);
}

.ti84-btn-num:hover {
    background: linear-gradient(180deg, #5a5a5a 0%, #4a4a4a 100%);
}

.ti84-btn-num:active {
    background: #666;
}

/* --- ON Button --- */
.ti84-btn-on {
    background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
    color: #e0e0e0;
    font-weight: 700;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.06);
}

.ti84-btn-on:hover {
    background: linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 100%);
}

/* --- Enter Button --- */
.ti84-btn-enter {
    background: linear-gradient(180deg, #3a3a3a 0%, #252525 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    box-shadow:
        0 3px 6px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.08);
}

.ti84-btn-enter:hover {
    background: linear-gradient(180deg, #4a4a4a 0%, #333 100%);
}

.ti84-btn-enter:active {
    background: #555;
}

/* ========================
   GRAPH MODAL
======================== */
.ti84-graph-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ti84-graph-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.ti84-graph-container {
    position: relative;
    background: #1a1a2e;
    border-radius: 16px;
    border: 1px solid #2a2a4e;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    width: 460px;
    max-width: 95vw;
    overflow: hidden;
}

.ti84-graph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(180deg, #232348 0%, #1a1a2e 100%);
    color: #c8e6ff;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid #2a2a4e;
}

.ti84-graph-close {
    background: rgba(255,255,255,0.08);
    border: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.ti84-graph-close:hover {
    background: rgba(255,80,80,0.2);
    color: #ff6b6b;
}

.ti84-graph-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-family: 'Inter', sans-serif;
}

.ti84-graph-body label {
    color: #7ab0e0;
    font-size: 16px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.ti84-graph-body input {
    background: #0a1628;
    border: 1px solid #2a3a5e;
    border-radius: 8px;
    padding: 10px 14px;
    color: #e0f0ff;
    font-size: 15px;
    font-family: 'JetBrains Mono', monospace;
    outline: none;
    transition: border-color 0.2s;
}

.ti84-graph-body input:focus {
    border-color: #4dabf7;
    box-shadow: 0 0 0 3px rgba(77,171,247,0.15);
}

.ti84-graph-plot-btn {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.ti84-graph-plot-btn:hover {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

#ti84GraphCanvas {
    background: #0a1628;
    border-radius: 8px;
    border: 1px solid #1a2a4e;
    width: 100%;
    height: auto;
}

/* --- Responsive --- */
@media (max-width: 420px) {
    .ti84-calculator {
        width: 98vw;
        padding: 16px 8px 14px;
        border-radius: 18px 18px 14px 14px;
    }

    .ti84-btn {
        font-size: 9.5px;
        padding: 7px 2px 5px;
    }

    .ti84-btn-num {
        font-size: 12px;
    }

    .ti84-screen {
        height: 140px;
    }

    .ti84-dpad {
        width: 100px;
        height: 100px;
    }

    .ti84-second-label {
        font-size: 6.5px;
    }

    .ti84-alpha-label {
        font-size: 6px;
    }
}
