/* MineVantage shared UI primitives — loaded on every page.
   Toasts, keyboard hints, autocomplete, skeleton loaders, drawer.
   Matches existing golden/brown palette; no theme switching. */

/* ----- Toast stack ----- */
.mv-toast-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100vw - 40px);
    width: 360px;
    pointer-events: none;
}

.mv-toast {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    padding: 14px 16px;
    font-size: 14px;
    color: #333;
    border-left: 4px solid #d4af37;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: mv-toast-in 0.22s ease-out;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mv-toast.mv-toast-out {
    opacity: 0;
    transform: translateX(20px);
}

.mv-toast-icon {
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1;
}

.mv-toast-body {
    flex: 1;
    line-height: 1.4;
    word-break: break-word;
}

.mv-toast-action {
    background: none;
    border: 1px solid #d4af37;
    color: #8b6914;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.mv-toast-action:hover { background: #fef5e7; }

.mv-toast-close {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.mv-toast-close:hover { color: #333; }

.mv-toast-success { border-left-color: #16a34a; }
.mv-toast-success .mv-toast-icon { color: #16a34a; }
.mv-toast-error   { border-left-color: #b91c1c; }
.mv-toast-error   .mv-toast-icon { color: #b91c1c; }
.mv-toast-info    { border-left-color: #d4af37; }
.mv-toast-info    .mv-toast-icon { color: #b8860b; }

@keyframes mv-toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@media (max-width: 600px) {
    .mv-toast-stack {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
    }
}

/* ----- Keyboard hint chip + shortcuts cheat-sheet ----- */
.mv-kbd {
    display: inline-block;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 11px;
    background: #f5f0e0;
    color: #5a4410;
    border: 1px solid #d4af37;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 1.4;
    white-space: nowrap;
}

.mv-shortcut-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.55);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.mv-shortcut-overlay.mv-show { display: flex; }

.mv-shortcut-card {
    background: #fff;
    border-radius: 12px;
    padding: 22px 24px;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    max-height: 80vh;
    overflow-y: auto;
}
.mv-shortcut-card h3 {
    font-size: 16px;
    color: #333;
    margin: 0 0 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mv-shortcut-card h3 button {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}
.mv-shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid #f0e6c8;
    font-size: 13px;
    color: #555;
}
.mv-shortcut-row:first-of-type { border-top: none; }
.mv-shortcut-keys { display: flex; gap: 4px; }

/* ----- Autocomplete dropdown (Phase 3) ----- */
.mv-autocomplete-wrap { position: relative; }
.mv-autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}
.mv-autocomplete-list.mv-show { display: block; }
.mv-autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
}
.mv-autocomplete-item:last-child { border-bottom: none; }
.mv-autocomplete-item:hover,
.mv-autocomplete-item.mv-active {
    background: #fef5e7;
    color: #8b6914;
}
.mv-autocomplete-item .mv-ac-count {
    font-size: 11px;
    color: #999;
    font-weight: 500;
}

/* ----- Recent-tickers chip row (Phase 3) ----- */
.mv-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.mv-chip {
    background: #fef5e7;
    color: #8b6914;
    border: 1px solid #d4af37;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}
.mv-chip:hover { background: #fce8b9; }
.mv-chip-label {
    color: #888;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    align-self: center;
    margin-right: 4px;
}

/* ----- History filter toolbar (Phase 3) ----- */
.mv-history-toolbar {
    background: rgba(255,255,255,0.92);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.mv-history-toolbar input[type="text"] {
    flex: 1;
    min-width: 140px;
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    -webkit-appearance: none;
}
.mv-history-toolbar input[type="text"]:focus {
    outline: none;
    border-color: #d4af37;
}
.mv-filter-pill {
    background: #fff;
    color: #777;
    border: 1px solid #e0e0e0;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.mv-filter-pill:hover { border-color: #d4af37; color: #8b6914; }
.mv-filter-pill.mv-active {
    background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
    color: #fff;
    border-color: transparent;
}

/* ----- Mini buttons used in cards (Phase 3) ----- */
.mv-mini-btn {
    display: inline-block;
    margin-top: 8px;
    margin-right: 6px;
    padding: 6px 12px;
    background: #fff;
    color: #8b6914;
    border: 1px solid #d4af37;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    font-family: inherit;
}
.mv-mini-btn:hover { background: #fef5e7; }

/* ----- Date-range picker (Phase 4) ----- */
.mv-date-range {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.mv-date-range input[type="date"] {
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #333;
}
.mv-date-range input[type="date"]:focus {
    outline: none;
    border-color: #d4af37;
}
.mv-quick-range {
    background: #fff;
    color: #777;
    border: 1px solid #e0e0e0;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
}
.mv-quick-range:hover { border-color: #d4af37; color: #8b6914; }
.mv-quick-range.mv-active {
    background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%);
    color: #fff;
    border-color: transparent;
}

/* ----- Failure drawer (Phase 4) ----- */
.mv-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.55);
    z-index: 9997;
    display: none;
}
.mv-drawer-overlay.mv-show { display: block; }
.mv-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(540px, 100vw);
    background: #fff;
    z-index: 9998;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -8px 0 24px rgba(0,0,0,0.18);
    overflow-y: auto;
    padding: 24px 26px;
}
.mv-drawer.mv-show { transform: translateX(0); }
.mv-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.mv-drawer-header h3 {
    font-size: 17px;
    color: #333;
    margin: 0;
}
.mv-drawer-close {
    background: none;
    border: none;
    color: #999;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.mv-drawer-row {
    padding: 8px 0;
    border-top: 1px solid #f0e6c8;
    font-size: 13px;
    color: #555;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.mv-drawer-row strong { color: #333; font-weight: 600; min-width: 90px; }
.mv-drawer-trace {
    background: #1a1a2e;
    color: #f5f0e0;
    border-radius: 8px;
    padding: 14px;
    margin-top: 14px;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow-y: auto;
}

/* ----- Skeleton shimmer (Phase 4) ----- */
.mv-skeleton {
    background: linear-gradient(90deg, #ede5cf 0%, #f6efd9 50%, #ede5cf 100%);
    background-size: 200% 100%;
    animation: mv-shimmer 1.4s linear infinite;
    border-radius: 6px;
    display: block;
}
@keyframes mv-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----- Reduced-motion guard ----- */
@media (prefers-reduced-motion: reduce) {
    .mv-toast { animation: none; }
    .mv-skeleton { animation: none; }
    .mv-drawer { transition: none; }
}

/* ===== Tiered report — section picker (app_index.html) ===== */
.mv-sections-picker {
    margin: 6px 0 14px;
    border: 1px solid #e0d8b0;
    border-radius: 8px;
    background: #fdfbf3;
}
.mv-sections-picker > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 600;
    color: #4c3c15;
    user-select: none;
}
.mv-sections-picker > summary::-webkit-details-marker { display: none; }
.mv-sections-picker > summary::before {
    content: "▸";
    color: #b8860b;
    font-size: 13px;
    transition: transform 0.15s ease;
    margin-right: 6px;
}
.mv-sections-picker[open] > summary::before { transform: rotate(90deg); }
.mv-sections-picker-summary-label { flex: 1; }
.mv-sections-picker-summary-status {
    font-size: 12px;
    font-weight: 500;
    color: #8b6914;
    background: #fffbea;
    border: 1px solid #ffe082;
    padding: 2px 8px;
    border-radius: 999px;
}
.mv-sections-picker-body {
    padding: 8px 14px 14px;
    border-top: 1px solid #ece2c1;
}
.mv-sections-master {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    color: #4c3c15;
}
.mv-sections-master:hover { background: #fffbea; }
.mv-sections-master input { width: auto; margin: 0; }
.mv-pack {
    margin-top: 6px;
}
.mv-pack-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    color: #4c3c15;
}
.mv-pack-header:hover { background: #fffbea; }
.mv-pack-header input { width: auto; margin: 0; }
.mv-pack-children {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px 12px;
    margin: 4px 0 6px 22px;
    padding-left: 8px;
    border-left: 2px solid #ece2c1;
}
.mv-section-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px;
    border-radius: 4px;
    font-weight: normal;
    color: #5d4a1a;
    cursor: pointer;
    font-size: 13px;
}
.mv-section-row:hover { background: #fffbea; }
.mv-section-row input { width: auto; margin: 0; }

/* ===== Tiered report — pack badges (admin_reports.html) ===== */
.mv-pack-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
.mv-pack-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    color: #fff;
    min-width: 36px;
    text-align: center;
}
.mv-pack-full {
    background: #2e7d32;
    border-color: #2e7d32;
}
.mv-pack-partial {
    background: #f9a825;
    border-color: #f57f17;
    color: #3e2723;
}
.mv-pack-skipped {
    background: #f5f1e0;
    border-color: #e0d8b0;
    color: #8a7a3a;
}
.mv-chip-full {
    background: #e8f5e9;
    border: 1px solid #2e7d32;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

/* ----- Professional Preamble Generator ----- */
.mv-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #d4af37;
    background: #fff;
    color: #8b6914;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-left: 6px;
}
.mv-btn-primary {
    background: linear-gradient(135deg, #d4af37 0%, #b8941f 100%);
    color: #fff;
    border-color: transparent;
}
.mv-btn-primary:hover { filter: brightness(1.05); }

.mv-preamble-panel {
    margin-top: 12px;
    padding: 14px 16px;
    background: #fffdf6;
    border: 1px solid #e6d28a;
    border-radius: 8px;
}
.mv-preamble-head {
    font-size: 14px;
    font-weight: 700;
    color: #8b6914;
    margin-bottom: 10px;
}
.mv-preamble-text {
    width: 100%;
    min-height: 320px;
    padding: 12px;
    border: 1px solid #d4af37;
    border-radius: 6px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 14px;
    line-height: 1.6;
    color: #2c2c2c;
    resize: vertical;
    box-sizing: border-box;
}
/* The editor scrolls on its own; the action bar below stays put so Save /
   Regenerate are always reachable while editing long sections. */
.mv-preamble-editor {
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 6px;
}
.mv-preamble-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e6d28a;
    background: inherit;
}
.mv-preamble-actions .mv-mini-btn { margin-top: 0; }

/* Inside the admin result modal: make the card a fixed-height flex column so
   only the editor scrolls and the action bar pins to the bottom. */
.mv-preamble-modal { display: flex; flex-direction: column; overflow: hidden; }
.mv-preamble-scrollwrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}
.mv-preamble-modal .mv-preamble-editor {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
}
.mv-preamble-modal .mv-preamble-actions { flex: 0 0 auto; }
.mv-preamble-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
}
