/* ══════════════════════════════════════════════════════
   MDB — Shared Site Styles
   ══════════════════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Body ── */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
}

/* ── Typography ── */
h1 { font-size: 1.5rem; color: #f8fafc; }
h2 { font-size: 1.1rem; color: #f8fafc; }
.subtitle { color: #94a3b8; font-size: .9rem; margin-bottom: 1.5rem; }

/* ── Forms ── */
label { display: block; margin-bottom: .2rem; font-size: .85rem; color: #94a3b8; }
input, select, textarea {
    width: 100%; padding: .5rem .7rem; margin-bottom: .8rem;
    border: 1px solid #334155; border-radius: .5rem;
    background: #0f172a; color: #e2e8f0; font-size: .9rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #3b82f6; }
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }
textarea { resize: vertical; min-height: 4rem; }

/* Validation states */
input.touched:required:invalid, select.touched:required:invalid, textarea.touched:required:invalid {
    border-color: #ef4444; box-shadow: 0 0 0 1px rgba(239,68,68,.25);
}
input.has-error, select.has-error, textarea.has-error {
    border-color: #ef4444; box-shadow: 0 0 0 1px rgba(239,68,68,.25);
}
input.verified, select.verified { border-color: #22c55e; box-shadow: 0 0 0 1px rgba(34,197,94,.25); }
input.unverified, select.unverified { border-color: #eab308; box-shadow: 0 0 0 1px rgba(234,179,8,.25); }
.field-error { color: #fca5a5; font-size: .75rem; margin-top: .15rem; }
.field-hint { font-size: .75rem; color: #64748b; margin-top: -.5rem; margin-bottom: .5rem; }

/* ── Toggle Switch ── */
.toggle-switch { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; user-select: none; }
.toggle-switch input { display: none; }
.toggle-slider { position: relative; width: 34px; height: 18px; background: #334155; border-radius: 9px; transition: background .2s; flex-shrink: 0; }
.toggle-slider::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; background: #64748b; border-radius: 50%; transition: transform .2s, background .2s; }
.toggle-switch input:checked + .toggle-slider { background: #3b82f6; }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(16px); background: #fff; }

/* ── MDB Modal (shared prompt/confirm/alert replacement) ── */
.mdb-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 10500;
    display: flex; align-items: center; justify-content: center;
}
.mdb-modal {
    background: #1e293b; border: 1px solid #475569; border-radius: .75rem;
    padding: 1.5rem; width: 380px; max-width: 90vw;
    display: flex; flex-direction: column; gap: .8rem;
}
.mdb-modal h3 { color: #f8fafc; font-size: 1rem; margin: 0; }
.mdb-modal p { color: #94a3b8; font-size: .85rem; margin: 0; white-space: pre-line; }
.mdb-modal input[type=text], .mdb-modal input[type=number] {
    width: 100%; padding: .45rem .6rem; border-radius: .4rem; border: 1px solid #475569;
    background: #0f172a; color: #f8fafc; font-size: .9rem; box-sizing: border-box;
}
.mdb-modal .mdb-modal-btns { display: flex; gap: .5rem; justify-content: flex-end; }
.mdb-modal .mdb-modal-btns button {
    padding: .4rem 1rem; border-radius: .4rem; font-size: .82rem; font-weight: 600;
    border: none; cursor: pointer; color: #fff; transition: all .15s;
}
.mdb-modal .btn-cancel { background: #475569; }
.mdb-modal .btn-cancel:hover { background: #64748b; }
.mdb-modal .btn-ok { background: #16a34a; }
.mdb-modal .btn-ok:hover { background: #15803d; }
.mdb-modal .btn-danger { background: #dc2626; }
.mdb-modal .btn-danger:hover { background: #b91c1c; }

/* ── Card ── */
.card {
    padding: 2rem; background: #1e293b; border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0,0,0,.25);
}

/* ── Buttons ── */
.btn {
    display: inline-block; padding: .7rem 1.5rem; border: none; border-radius: .5rem;
    background: #3b82f6; color: #fff; font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: background .2s; text-align: center;
}
.btn:hover { background: #2563eb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-green { background: #22c55e; }
.btn-green:hover { background: #16a34a; }
.btn-red { background: #dc2626; }
.btn-red:hover { background: #b91c1c; }
.btn-outline { background: transparent; border: 1px solid #334155; color: #94a3b8; }
.btn-outline:hover { background: #334155; color: #e2e8f0; }
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #334155; color: #e2e8f0; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: #991b1b; }
.btn-success { background: #065f46; color: #6ee7b7; }
.btn-success:hover { background: #047857; }
.btn-warning { background: #92400e; color: #fde68a; }
.btn-warning:hover { background: #b45309; }
.btn-sm { padding: .45rem 1rem; font-size: .85rem; }
.btn-row { display: flex; gap: .5rem; margin-top: 1rem; }

/* ── Password strength bar ── */
.pw-strength-bar { height: 4px; border-radius: 2px; background: #1e293b; margin-top: .3rem; margin-bottom: .2rem; overflow: hidden; transition: opacity .2s; }
.pw-strength-bar .pw-fill { height: 100%; border-radius: 2px; transition: width .25s, background .25s; width: 0; }
.pw-strength-label { font-size: .72rem; margin-top: .1rem; transition: color .25s; }

/* ── Messages ── */
.msg { padding: .6rem; border-radius: .5rem; font-size: .85rem; }
.msg.error { background: #7f1d1d; color: #fca5a5; }
.msg.ok { background: #14532d; color: #86efac; }
.msg.success { background: #14532d; color: #86efac; }
.msg.warn { background: #713f12; color: #fde68a; }

/* ── Toast notifications (global) ── */
.mdb-toast-wrap {
    position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 10100;
    display: flex; flex-direction: column-reverse; gap: .5rem;
    max-width: min(440px, calc(100vw - 2rem)); pointer-events: none;
}
.mdb-toast {
    display: flex; align-items: flex-start; gap: .5rem;
    padding: .65rem .85rem; border-radius: .5rem; font-size: .85rem; line-height: 1.4;
    box-shadow: 0 4px 18px rgba(0,0,0,.45);
    pointer-events: auto; cursor: pointer; word-break: break-word;
    transform: translateX(120%); opacity: 0;
    transition: transform .3s ease, opacity .3s ease;
}
.mdb-toast-in  { transform: translateX(0); opacity: 1; }
.mdb-toast-out { transform: translateX(120%); opacity: 0; }
.mdb-toast-error   { background: #7f1d1d; color: #fca5a5; border-left: 3px solid #ef4444; }
.mdb-toast-success { background: #14532d; color: #86efac; border-left: 3px solid #22c55e; }
.mdb-toast-warn    { background: #713f12; color: #fde68a; border-left: 3px solid #f59e0b; }
.mdb-toast-info    { background: #1e3a5f; color: #93c5fd; border-left: 3px solid #3b82f6; }
.mdb-toast-icon { flex-shrink: 0; font-size: 1.05rem; line-height: 1; margin-top: .1rem; }
.mdb-toast-msg  { flex: 1; user-select: text; }
.mdb-toast-btn  {
    flex-shrink: 0; background: none; border: none; color: inherit;
    opacity: .5; cursor: pointer; font-size: 1.1rem; padding: 0 .15rem; line-height: 1;
}
.mdb-toast-btn:hover { opacity: 1; }
.mdb-toast-x { font-size: 1.25rem; margin-left: .1rem; }

/* ── Layout ── */
.row { display: flex; gap: .8rem; }
.row > * { flex: 1; }
.row-3-1 > :first-child { flex: 3; }
.row-3-1 > :last-child { flex: 1; }
.row-1-3 > :first-child { flex: 1; }
.row-1-3 > :last-child { flex: 3; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { text-align: left; padding: .5rem .6rem; color: #94a3b8; border-bottom: 1px solid #334155; font-weight: 600; white-space: nowrap; }
td { padding: .5rem .6rem; border-bottom: 1px solid #1e293b44; vertical-align: middle; }
tr:hover td { background: #172033; }

/* ── Utilities ── */
.hidden { display: none !important; }
.back-link {
    display: inline-flex; align-items: center; gap: .3rem;
    background: #14532d; color: #fff; padding: .35rem .9rem; border-radius: 999px;
    font-size: .82rem; font-weight: 600; border: none;
    cursor: pointer; font-family: inherit; text-decoration: none;
    margin: 0 auto 1rem; width: fit-content; transition: background .15s;
}
.back-link:hover { background: #166534; color: #fff; text-decoration: none; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.checkbox-row input { width: auto; margin: 0; }
.info-box {
    background: #0f172a; border: 1px solid #334155; border-radius: .5rem;
    padding: .8rem 1rem; margin-bottom: 1rem; font-size: .85rem; color: #94a3b8;
}
.divider { display: flex; align-items: center; gap: .8rem; margin: 1.2rem 0; color: #64748b; font-size: .8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #334155; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: mdb-spin .6s linear infinite; vertical-align: middle; }
@keyframes mdb-spin { to { transform: rotate(360deg); } }
.ts { color: #64748b; font-size: .78rem; white-space: nowrap; }

/* ── Autocomplete ── */
.ac-wrap { position: relative; }
.ac-list {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
    max-height: 220px; overflow-y: auto; background: #1e293b;
    border: 1px solid #3b82f6; border-radius: 0 0 .5rem .5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.ac-item { padding: .4rem .7rem; cursor: pointer; font-size: .85rem; color: #e2e8f0; }
.ac-item:hover, .ac-item.ac-active { background: #334155; }
.ac-item.ac-more { color: #64748b; font-style: italic; cursor: default; }

/* ── Confirm dialog ── */
.confirm-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,.55); z-index: 10500; display: none;
    align-items: center; justify-content: center;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
    background: #1e293b; border: 1px solid #334155; border-radius: .75rem;
    padding: 1.5rem; max-width: 440px; width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,.5); text-align: center;
    max-height: 85vh; overflow-y: auto;
}
.confirm-box p { margin-bottom: 1rem; font-size: .9rem; white-space: pre-line; text-align: left; }
.confirm-box .confirm-actions { display: flex; gap: .6rem; justify-content: center; }

/* ── Status pills ── */
.status-bar { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1.5rem; }
.status-pill { padding: .3rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.status-pill.ok { background: #14532d; color: #86efac; }
.status-pill.pending { background: #422006; color: #fbbf24; }

/* ── Detail modal (shared pattern) ── */
.detail-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,.5); z-index: 10500; display: none;
    align-items: center; justify-content: center;
}
.detail-modal.open { display: flex; }
.detail-modal .modal-box {
    background: #1e293b; border: 1px solid #334155; border-radius: .75rem;
    padding: 1.5rem; max-width: min(90vw, 800px); width: 90%;
    max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.detail-modal .modal-close {
    float: right; background: none; border: none;
    color: #64748b; font-size: 1.2rem; cursor: pointer; padding: .2rem .5rem;
}
.detail-modal .modal-close:hover { color: #e2e8f0; }

/* ── Pagination ── */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 1rem; font-size: .85rem; color: #94a3b8;
}
.pagination button {
    padding: .35rem .7rem; border: 1px solid #334155; border-radius: .4rem;
    background: #0f172a; color: #e2e8f0; font-size: .8rem; cursor: pointer;
}
.pagination button:hover { border-color: #3b82f6; }
.pagination button:disabled { opacity: .3; cursor: not-allowed; }

/* ── Filter bars ── */
.filters {
    display: flex; gap: .8rem; align-items: center; flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filters select, .filters input {
    padding: .4rem .6rem; border-radius: .4rem; border: 1px solid #334155;
    background: #0f172a; color: #e2e8f0; font-size: .85rem;
}
.filters select:focus, .filters input:focus { outline: none; border-color: #3b82f6; }
.filters label { font-size: .8rem; color: #94a3b8; }
