/* ==========================================================================
   Calculator popover. Plain CSS: the Tailwind utilities the markup used were
   never compiled into this app's bundle, which left every key in one column.
   !important where AdminLTE / app.css button and input rules would win.
   ========================================================================== */

/* ── Popover shell ─────────────────────────────────────────────────────── */
.popover:has(#calculator) {
    max-width: none;
    width: 296px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 18px 40px -12px rgba(15, 23, 42, .28), 0 2px 8px rgba(15, 23, 42, .08);
    overflow: hidden;
}
.popover:has(#calculator).bottom > .arrow:after { border-bottom-color: #fff; }
.popover:has(#calculator) .popover-content { padding: 0 !important; background: #fff; }

/* Prevent the global navbar/pos-header padding rule from adding unwanted space */
.navbar-custom-menu .popover-content, .pos-header .popover-content { padding: 4px 0; }

#calculator {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    background: #fff;
    font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    outline: none;
}

/* ── Head ──────────────────────────────────────────────────────────────── */
#calculator .calc-head { display: flex; align-items: center; justify-content: space-between; margin: -2px 0 10px; }
#calculator .calc-title { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #64748b; }
#calculator .calc-hist-btn {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
#calculator .calc-hist-btn:hover { background: #e0e7ff; color: #1d4ed8; }

/* ── Display ───────────────────────────────────────────────────────────── */
#calculator .calc-screen { margin: 0 0 10px; }
#calc-display {
    display: block;
    width: 100% !important;
    box-sizing: border-box !important;
    height: 56px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    color: #0f172a !important;
    font-family: inherit !important;
    font-size: 28px !important;
    font-weight: 700 !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
    text-align: right !important;
    box-shadow: none !important;
    outline: none !important;
}
#calc-display::placeholder { color: #cbd5e1; }

/* ── Keys: four across, five rows ──────────────────────────────────────── */
#calc-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
}
#calculator .calc-btn {
    width: 100% !important;
    height: 46px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid;
    place-items: center;
    border: 1px solid transparent !important;
    border-radius: 11px !important;
    font-family: inherit !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    cursor: pointer;
    box-shadow: none !important;
    transition: background .12s, border-color .12s, transform .08s;
}
#calculator .calc-btn:active { transform: scale(.95); }
#calculator .calc-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }

#calculator .calc-btn-num { background: #fff !important; border-color: #e2e8f0 !important; color: #0f172a !important; }
#calculator .calc-btn-num:hover { background: #f1f5f9 !important; }

#calculator .calc-btn-op { background: #eef4ff !important; color: #1d4ed8 !important; font-size: 20px !important; }
#calculator .calc-btn-op:hover { background: #dbe7ff !important; }

#calculator .calc-btn-ac { background: #fef2f2 !important; color: #dc2626 !important; font-size: 15px !important; font-weight: 700 !important; }
#calculator .calc-btn-ac:hover { background: #fee2e2 !important; }

#calculator .calc-btn-ce { background: #fffbeb !important; color: #b45309 !important; font-size: 15px !important; font-weight: 700 !important; }
#calculator .calc-btn-ce:hover { background: #fef3c7 !important; }

#calculator .calc-btn-eq { background: #16a34a !important; color: #fff !important; font-size: 22px !important; font-weight: 700 !important; }
#calculator .calc-btn-eq:hover { background: #15803d !important; }

/* ── History popup (HTML built in calculator.js — not in blade) ────────── */
#calc-hist-popup {
    display: none;
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.13), 0 2px 6px rgba(0,0,0,.07);
    padding: 8px;
}
.calc-hist-head {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 0 2px 6px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 5px;
}
#calc-hist-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 180px;
    overflow-y: auto;
}
.calc-hist-entry {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    padding: 5px 9px;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.calc-hist-entry:hover { background: #dbeafe; border-color: #bfdbfe; }
.calc-hist-expr {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.calc-hist-result {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    font-weight: 700;
    color: #1d4ed8;
    text-align: right;
}
.calc-hist-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    padding: 20px 0;
}
#calc-hist-clear {
    width: 100%;
    margin-top: 6px;
    padding: 5px;
    background: #fee2e2;
    border: none;
    border-radius: 6px;
    color: #dc2626;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
#calc-hist-clear:hover { background: #fecaca; }
