/**
 * Gradia POS — Shift & Cash Count CSS
 * Full redesign: denomination cards, shift history cards,
 * shift monitor panel, all mobile-first.
 */

/* ================================================================
   SHARED MODAL SHELL
   ================================================================ */
.p9sh-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
}
.p9sh-overlay.visible {
    opacity: 1;
    pointer-events: all;
}
@media (min-width: 641px) {
    .p9sh-overlay { align-items: center; padding: 24px; }
}

.p9sh-sheet {
    background: var(--p9-card, #fff);
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -6px 40px rgba(0,0,0,.22);
    transform: translateY(24px);
    transition: transform .24s cubic-bezier(.32,.72,0,1);
}
.p9sh-overlay.visible .p9sh-sheet {
    transform: translateY(0);
}
@media (min-width: 641px) {
    .p9sh-sheet {
        border-radius: 24px;
        max-width: 560px;
        box-shadow: 0 20px 70px rgba(0,0,0,.22);
        transform: scale(.97) translateY(0);
    }
    .p9sh-overlay.visible .p9sh-sheet {
        transform: scale(1) translateY(0);
    }
}

.p9sh-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--p9-border, rgba(0,0,0,.08));
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
@media (min-width: 641px) { .p9sh-header { padding: 18px 24px; } }

.p9sh-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.p9sh-header-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--p9-accent-1, #008cff) 0%, #000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.p9sh-header-icon svg { color: #fff; }

.p9sh-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--p9-text, #0f172a);
    line-height: 1.2;
}

.p9sh-subtitle {
    font-size: 11.5px;
    color: var(--p9-muted, #64748b);
    margin-top: 1px;
}

.p9sh-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--p9-surface, #f1f5f9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--p9-muted, #64748b);
    font-size: 17px;
    line-height: 1;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.p9sh-close-btn:hover { background: #fee2e2; color: #ef4444; }

.p9sh-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 20px;
}
@media (min-width: 641px) { .p9sh-body { padding: 20px 24px; } }

.p9sh-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--p9-border, rgba(0,0,0,.08));
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    background: var(--p9-card, #fff);
}
@media (min-width: 641px) { .p9sh-footer { padding: 16px 24px; } }

/* ================================================================
   DENOMINATION CARDS
   ================================================================ */

.p9sh-denom-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 4px;
}

/* Use auto-fill with min card width so the grid never overflows
   the modal regardless of screen or modal size */
@supports (grid-template-columns: repeat(auto-fill, minmax(120px, 1fr))) {
    .p9sh-denom-cards {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

.p9sh-denom-card {
    background: var(--p9-surface, #f8fafc);
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.07));
    border-radius: 14px;
    padding: 12px 10px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: border-color .15s, box-shadow .15s;
}
.p9sh-denom-card:focus-within {
    border-color: var(--p9-accent-1, #008cff);
    box-shadow: 0 0 0 3px rgba(0,140,255,.1);
}

.p9sh-denom-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--p9-text, #0f172a);
    white-space: nowrap;
}

.p9sh-denom-badge .coin-icon { font-size: 15px; }
.p9sh-denom-badge .note-icon { font-size: 14px; }

.p9sh-denom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
}

.p9sh-denom-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.1));
    background: var(--p9-card, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    color: var(--p9-text, #0f172a);
    flex-shrink: 0;
    transition: all .12s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.p9sh-denom-btn.minus:hover { border-color: #ef4444; color: #ef4444; background: #fef2f2; }
.p9sh-denom-btn.plus:hover  { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
.p9sh-denom-btn:active { transform: scale(.93); }

.p9sh-qty-input {
    width: 44px;
    text-align: center;
    padding: 5px 4px;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.1));
    border-radius: 9px;
    background: var(--p9-card, #fff);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    color: var(--p9-text, #0f172a);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}
.p9sh-qty-input::-webkit-outer-spin-button,
.p9sh-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.p9sh-qty-input:focus {
    border-color: var(--p9-accent-1, #008cff);
}

.p9sh-denom-sub {
    font-size: 11px;
    font-weight: 700;
    color: var(--p9-accent-1, #008cff);
    min-height: 16px;
    text-align: center;
}

/* Total strip */
.p9sh-total-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--p9-surface, #f8fafc);
    border-radius: 14px;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.07));
    margin-top: 14px;
}
.p9sh-total-label { font-size: 13px; font-weight: 600; color: var(--p9-muted, #64748b); }
.p9sh-total-val   { font-size: 22px; font-weight: 800; color: var(--p9-text, #0f172a); letter-spacing: -.5px; }

/* ================================================================
   SHIFT SUMMARY
   ================================================================ */
.p9sh-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.p9sh-stat-card {
    background: var(--p9-surface, #f8fafc);
    border: 1px solid var(--p9-border, rgba(0,0,0,.07));
    border-radius: 12px;
    padding: 12px 14px;
}
.p9sh-stat-card.full  { grid-column: 1 / -1; }
.p9sh-stat-label { font-size: 11px; font-weight: 600; color: var(--p9-muted, #64748b); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 3px; }
.p9sh-stat-val   { font-size: 17px; font-weight: 800; color: var(--p9-text, #0f172a); }

.p9sh-variance-card {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-radius: 12px;
    border: 1.5px solid;
}
.p9sh-variance-card.exact  { background: rgba(22,163,74,.07);  border-color: rgba(22,163,74,.25); }
.p9sh-variance-card.short  { background: rgba(239,68,68,.07);  border-color: rgba(239,68,68,.25); }
.p9sh-variance-card.over   { background: rgba(245,158,11,.07); border-color: rgba(245,158,11,.25); }
.p9sh-variance-card.none   { background: var(--p9-surface,#f8fafc); border-color: var(--p9-border,rgba(0,0,0,.07)); }

.p9sh-variance-label { font-size: 12px; font-weight: 700; color: var(--p9-muted, #64748b); }
.p9sh-variance-val   { font-size: 17px; font-weight: 800; }
.p9sh-variance-val.exact  { color: #16a34a; }
.p9sh-variance-val.short  { color: #ef4444; }
.p9sh-variance-val.over   { color: #d97706; }
.p9sh-variance-val.none   { color: var(--p9-muted, #64748b); }

.p9sh-divider { border: none; border-top: 1.5px dashed var(--p9-border, rgba(0,0,0,.1)); margin: 14px 0; }

/* ================================================================
   SHIFT HISTORY CARDS
   ================================================================ */
.p9sh-history-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.p9sh-hist-card {
    background: var(--p9-surface, #f8fafc);
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.07));
    border-radius: 16px;
    padding: 14px 16px;
    transition: border-color .15s;
}
.p9sh-hist-card:hover { border-color: var(--p9-accent-1, #008cff); }

.p9sh-hist-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 10px;
}

.p9sh-hist-staff {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.p9sh-hist-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p9-accent-1, #008cff) 0%, #000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.p9sh-hist-name { font-size: 13px; font-weight: 700; color: var(--p9-text, #0f172a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p9sh-hist-role { font-size: 11px; color: var(--p9-muted, #64748b); margin-top: 1px; }

.p9sh-hist-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}
.p9sh-hist-status.open   { background: rgba(22,163,74,.12);  color: #15803d; }
.p9sh-hist-status.closed { background: rgba(100,116,139,.12); color: #475569; }

.p9sh-hist-bio-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    background: rgba(0,140,255,.1);
    color: #008cff;
    margin-left: 6px;
}

.p9sh-hist-times {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.p9sh-hist-time-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--p9-muted, #64748b);
}
.p9sh-hist-time-item svg { flex-shrink: 0; }
.p9sh-hist-time-val { font-weight: 600; color: var(--p9-text, #0f172a); }

.p9sh-hist-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.p9sh-hist-stat {
    background: var(--p9-card, #fff);
    border: 1px solid var(--p9-border, rgba(0,0,0,.07));
    border-radius: 10px;
    padding: 8px 10px;
    text-align: center;
}
.p9sh-hist-stat-label { font-size: 10px; font-weight: 600; color: var(--p9-muted, #64748b); text-transform: uppercase; letter-spacing: .2px; }
.p9sh-hist-stat-val   { font-size: 14px; font-weight: 800; color: var(--p9-text, #0f172a); margin-top: 2px; }

/* ================================================================
   SHIFT MONITOR PANEL
   ================================================================ */
.p9sh-monitor-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--p9-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin: 16px 0 10px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.p9sh-monitor-section-title:first-child { margin-top: 0; }

.p9sh-monitor-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #16a34a;
    animation: p9shLivePulse 1.5s ease-in-out infinite;
}
@keyframes p9shLivePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.7); }
}

.p9sh-monitor-card {
    background: var(--p9-surface, #f8fafc);
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.07));
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.p9sh-monitor-card.open-shift { border-color: rgba(22,163,74,.3); background: rgba(22,163,74,.04); }

.p9sh-monitor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--p9-accent-1, #008cff) 0%, #000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.p9sh-monitor-info { flex: 1; min-width: 0; }
.p9sh-monitor-name { font-size: 13px; font-weight: 700; color: var(--p9-text, #0f172a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p9sh-monitor-meta { font-size: 11px; color: var(--p9-muted, #64748b); margin-top: 2px; }

.p9sh-monitor-duration {
    text-align: right;
    flex-shrink: 0;
}
.p9sh-monitor-dur-val   { font-size: 14px; font-weight: 800; color: var(--p9-text, #0f172a); }
.p9sh-monitor-dur-label { font-size: 10px; color: var(--p9-muted, #64748b); }

/* ================================================================
   FILTERS & TABS (history page)
   ================================================================ */
.p9sh-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.p9sh-filter-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.1));
    background: var(--p9-surface, #f8fafc);
    font-size: 12px;
    font-weight: 600;
    color: var(--p9-muted, #64748b);
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
    white-space: nowrap;
}
.p9sh-filter-btn.active,
.p9sh-filter-btn:hover {
    border-color: var(--p9-accent-1, #008cff);
    color: var(--p9-accent-1, #008cff);
    background: rgba(0,140,255,.06);
}

/* ================================================================
   SHARED STATES
   ================================================================ */
.p9sh-loading {
    text-align: center;
    padding: 28px 16px;
    color: var(--p9-muted, #64748b);
    font-size: 13px;
}
.p9sh-empty {
    text-align: center;
    padding: 36px 16px;
    color: var(--p9-muted, #64748b);
    font-size: 13px;
}
.p9sh-empty-icon { font-size: 32px; margin-bottom: 10px; }
.p9sh-error { color: #ef4444; font-size: 13px; padding: 12px; text-align: center; }

/* ================================================================
   ACTION BUTTONS
   ================================================================ */
.p9sh-btn-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--p9-muted, #64748b);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.p9sh-btn-primary {
    flex: 1;
    min-height: 48px;
    padding: 0 20px;
    background: linear-gradient(135deg, var(--p9-accent-1, #008cff) 0%, #000 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: opacity .15s;
    box-shadow: 0 3px 12px rgba(0,140,255,.25);
}
.p9sh-btn-primary:hover:not(:disabled) { opacity: .86; }
.p9sh-btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; box-shadow: none; }
.p9sh-btn-primary.danger   { background: #dc2626; box-shadow: 0 3px 12px rgba(220,38,38,.25); }
.p9sh-btn-secondary {
    min-height: 48px;
    padding: 0 18px;
    background: none;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.12));
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    color: var(--p9-muted, #64748b);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color .15s;
}
.p9sh-btn-secondary:hover { border-color: #94a3b8; }

/* Shift open / clock-in buttons */
#p9x-shift-btn,
#p9sh-open-count-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid var(--p9-border, rgba(0,0,0,.1));
    border-radius: 999px;
    background: var(--p9-card, #fff);
    color: var(--p9-text, #0f172a);
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all .14s;
}
#p9x-shift-btn:hover,
#p9sh-open-count-btn:hover { border-color: var(--p9-accent-1, #008cff); color: var(--p9-accent-1, #008cff); }

/* Toast */
.p9sh-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1e293b;
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    z-index: 99999;
    opacity: 0;
    transition: opacity .25s, transform .25s;
    pointer-events: none;
    white-space: nowrap;
    max-width: calc(100vw - 32px);
    text-align: center;
}
.p9sh-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================================================================
   DARK MODE
   ================================================================ */
body.gradia-pos-dark .p9sh-sheet            { background: #0f172a !important; }
body.gradia-pos-dark .p9sh-header,
body.gradia-pos-dark .p9sh-footer           { border-color: rgba(255,255,255,.1) !important; background: #0f172a !important; }
body.gradia-pos-dark .p9sh-title            { color: #e2e8f0; }
body.gradia-pos-dark .p9sh-denom-card       { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); }
body.gradia-pos-dark .p9sh-denom-badge      { color: #e2e8f0; }
body.gradia-pos-dark .p9sh-denom-btn,
body.gradia-pos-dark .p9sh-qty-input        { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.14); color: #e2e8f0; }
body.gradia-pos-dark .p9sh-total-strip      { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); }
body.gradia-pos-dark .p9sh-total-val        { color: #e2e8f0; }
body.gradia-pos-dark .p9sh-stat-card        { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.08); }
body.gradia-pos-dark .p9sh-stat-val         { color: #e2e8f0; }
body.gradia-pos-dark .p9sh-hist-card,
body.gradia-pos-dark .p9sh-monitor-card     { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); }
body.gradia-pos-dark .p9sh-hist-stat        { background: rgba(255,255,255,.04); }
body.gradia-pos-dark .p9sh-hist-stat-val    { color: #e2e8f0; }
body.gradia-pos-dark .p9sh-hist-name,
body.gradia-pos-dark .p9sh-monitor-name     { color: #e2e8f0; }

/* Ghost shift card */
.p9sh-monitor-card.ghost-shift {
    border-color: rgba(217,119,6,.3);
    background: rgba(217,119,6,.04);
}
body.gradia-pos-dark .p9sh-monitor-card.ghost-shift {
    border-color: rgba(251,191,36,.25);
    background: rgba(251,191,36,.04);
}
