/*
    STORM :: base

    Reset, layout scaffolding and the primitives shared across every system:
    buttons, inputs, tables, cards, toasts and modals. System specific styles
    override these rather than redefining them.
*/

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    font-size: var(--text-base);
    /* The page floats over the game, so nothing paints a background except
       the active system's own root element. */
    background: transparent;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

#app[hidden] { display: none !important; }

#app {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* A system that fills the screen, e.g. CAD, PNC, CRIMES, the portal. */
.system-full {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* A system that floats as a window, e.g. the MDT. */
.system-window {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.scroll { overflow-y: auto; overflow-x: hidden; }

/* Scrollbars styled once, inherited everywhere. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, .08); }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .28); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .42); }

.dark-scroll::-webkit-scrollbar-track { background: rgba(255, 255, 255, .06); }
.dark-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); }

/* ---------------------------------------------------------------------- */
/* Typography                                                              */
/* ---------------------------------------------------------------------- */

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; }

p { margin: 0 0 var(--space-3); line-height: 1.55; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; cursor: pointer; }

.muted { opacity: .68; }
.tiny { font-size: var(--text-xs); }
.small { font-size: var(--text-sm); }
.bold { font-weight: 700; }
.upper { text-transform: uppercase; letter-spacing: .04em; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }

.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.row { display: flex; align-items: center; gap: var(--space-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { margin-left: auto; }

.empty {
    padding: var(--space-6);
    text-align: center;
    opacity: .6;
    font-style: italic;
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 9px 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--blue);
    color: #fff;
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: filter .12s ease, opacity .12s ease;
    white-space: nowrap;
}

.btn:hover { filter: brightness(1.12); }
.btn:active { filter: brightness(.92); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn svg { width: 15px; height: 15px; flex: none; }

.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-amber { background: var(--amber); }
.btn-grey { background: var(--grey); }
.btn-dark { background: #343a40; }
.btn-cyan { background: #0aa2c0; }

.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: var(--text-sm); }
.btn-lg { padding: 12px 22px; font-size: var(--text-md); }

.btn-outline {
    background: transparent;
    border: 1px solid currentColor;
}

/* An outlined action that sits inside a light card, as used on the crimes
   investigation team panel. */
.btn-ghost-green {
    background: #fff;
    color: #1a7f4b;
    border: 1px solid #63b98c;
}
.btn-ghost-green:hover { background: #f1fbf5; filter: none; }

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.field > label {
    font-size: var(--text-sm);
    font-weight: 700;
    opacity: .85;
}

.field .help {
    font-size: var(--text-xs);
    opacity: .62;
    line-height: 1.4;
}

.field .error { font-size: var(--text-xs); color: var(--red); font-weight: 600; }

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--mdt-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: #1f1f1f;
    font-family: inherit;
    font-size: var(--text-base);
    outline: none;
    user-select: text;
}

textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, .18);
}

input::placeholder, textarea::placeholder { color: #9aa0a6; }

.check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--text-base);
}
.check input { width: 16px; height: 16px; margin: 1px 0 0; flex: none; cursor: pointer; }

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
}

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }

.table th {
    text-align: left;
    padding: 9px 12px;
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    opacity: .7;
    border-bottom: 1px solid var(--mdt-border);
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: 0; }
.table .clickable { cursor: pointer; }
.table .clickable:hover td { background: rgba(13, 110, 253, .06); }

.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------------- */
/* Badges and pills                                                        */
/* ---------------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--grey);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}

.badge-green { background: var(--green); }
.badge-red { background: var(--red); }
.badge-amber { background: var(--amber); color: #1f1f1f; }
.badge-blue { background: var(--blue); }

/* PNC warning marker band. */
.markers { display: flex; flex-wrap: wrap; gap: 4px; }

.marker {
    padding: 3px 9px;
    border-radius: 2px;
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: .06em;
}

/* ---------------------------------------------------------------------- */
/* Toasts                                                                  */
/* ---------------------------------------------------------------------- */

.toasts {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
    max-width: 380px;
}

.toast {
    display: flex;
    gap: var(--space-3);
    padding: 12px 14px;
    border-left: 4px solid var(--blue);
    border-radius: var(--radius-sm);
    background: #1e1e1e;
    color: #f4f4f4;
    box-shadow: var(--shadow);
    animation: toast-in .18s ease-out;
}

.toast.is-leaving { animation: toast-out .18s ease-in forwards; }

.toast-success { border-left-color: var(--green-bright); }
.toast-warning { border-left-color: var(--yellow); }
.toast-error { border-left-color: var(--red); }

.toast-title { font-weight: 700; font-size: var(--text-base); margin-bottom: 2px; }
.toast-body { font-size: var(--text-sm); opacity: .85; line-height: 1.45; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateX(24px); }
}

/* ---------------------------------------------------------------------- */
/* Modals                                                                  */
/* ---------------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: rgba(0, 0, 0, .55);
    animation: fade-in .12s ease-out;
}

.modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    max-height: 86vh;
    border-radius: var(--radius);
    background: #fff;
    color: #1f1f1f;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-wide { max-width: 860px; }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 14px 18px;
    background: var(--mdt-chrome);
    color: #fff;
}

.modal-head h3 { font-size: var(--text-md); }

.modal-close {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}
.modal-close:hover { background: rgba(255, 255, 255, .2); }

.modal-body { padding: 18px; overflow-y: auto; }

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: 14px 18px;
    border-top: 1px solid var(--mdt-border);
    background: #fafafa;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------------------- */
/* Loading                                                                 */
/* ---------------------------------------------------------------------- */

.loading {
    display: grid;
    place-items: center;
    padding: var(--space-10);
    gap: var(--space-3);
    opacity: .7;
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
