/* ============================================================================
   app.css — theming + components for the new PHP app (pairs with flexgrid.css).
   ============================================================================ */

:root {
    --c-bg:        #f4f6f8;
    --c-surface:   #ffffff;
    --c-border:    #e2e6ea;
    --c-text:      #1f2933;
    --c-muted:     #6b7684;
    --c-primary:   #bf19d1;
    --c-primary-d: #9614a6;
    --c-accent:    #d70695;
    --c-danger:    #dc3545;
    --c-success:   #2e9e5b;
    --c-warn:      #e0a800;
    --radius:      10px;
    --shadow:      0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
    --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

html, body { margin: 0; padding: 0; }
/* The hidden attribute must always win, even over elements that set display. */
[hidden] { display: none !important; }
body {
    font-family: var(--font);
    color: var(--c-text);
    background: var(--c-bg);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--c-primary-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; }

/* ── App shell / content width ─────────────────────────────────────────────── */
.app-main {
    width: 100%;
    max-width: 1320px;                 /* comfortable reading width for forms/lists */
    margin: 1.5rem auto;
    padding-inline: clamp(1rem, 2.5vw, 2rem);
}
/* Wide pages (Kanban board) use the full browser width on big screens. */
.app-main.is-wide {
    max-width: 2400px;
}

/* ── Top navigation ──────────────────────────────────────────────────────── */
.app-nav {
    background: linear-gradient(90deg, #101828, #1d2939);
    color: #fff;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-nav .nav-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 58px;
    width: 100%;
    max-width: 2400px;
    margin-inline: auto;
    padding-inline: clamp(1rem, 2.5vw, 2rem);
}
.app-nav .brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.app-nav .brand img { height: 30px; width: auto; display: block; }

.app-nav .nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1 1 auto;
    min-width: 0;
}
.app-nav .nav-links {
    display: flex;
    align-items: center;
    gap: .2rem;
    flex-wrap: wrap;
    flex: 1 1 auto;
}
.app-nav .nav-right {
    display: flex;
    align-items: center;
    gap: .7rem;
    flex: 0 0 auto;
}
.app-nav a.navlink {
    color: #cdd5df;
    padding: .4rem .7rem;
    border-radius: 6px;
    white-space: nowrap;
    font-size: .92rem;
}
.app-nav a.navlink:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.app-nav a.navlink.active { background: var(--c-primary); color: #fff; }
.app-nav .nav-user { color: #cdd5df; white-space: nowrap; }
.app-nav .badge-warn {
    background: var(--c-danger); color: #fff; border-radius: 999px;
    padding: .1rem .5rem; font-size: .75rem; margin-left: .3rem;
}
.app-nav .role-chip {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
    background: rgba(255,255,255,.12); color: #e5e9f0;
    padding: .15rem .55rem; border-radius: 999px; white-space: nowrap;
}

/* Burger (hidden on desktop) */
.nav-burger {
    display: none;
    margin-left: auto;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px; height: 40px;
    padding: 8px 9px;
    cursor: pointer;
    border-radius: 8px;
}
.nav-burger:hover { background: rgba(255,255,255,.08); }
.nav-burger span {
    display: block; height: 2px; width: 100%;
    background: #e5e9f0; border-radius: 2px; transition: .2s;
}

/* Tablet / mobile: collapse the menu behind the burger */
@media (max-width: 991.98px) {
    .nav-burger { display: flex; }
    .app-nav .nav-menu {
        position: absolute;
        top: 58px; left: 0; right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: #1d2939;
        border-top: 1px solid rgba(255,255,255,.08);
        box-shadow: var(--shadow);
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
    }
    .nav-toggle-cb:checked ~ .nav-menu { max-height: 80vh; overflow-y: auto; padding: .5rem 0; }
    .app-nav .nav-links { flex-direction: column; align-items: stretch; gap: 0; padding: 0 .5rem; }
    .app-nav .nav-right {
        flex-direction: row; flex-wrap: wrap; gap: .6rem;
        padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.08); margin-top: .5rem;
    }
    .app-nav a.navlink { padding: .7rem 1rem; border-radius: 0; }
    /* Burger → X when open */
    .nav-toggle-cb:checked ~ .nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .nav-toggle-cb:checked ~ .nav-burger span:nth-child(2) { opacity: 0; }
    .nav-toggle-cb:checked ~ .nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ── Cards / panels ──────────────────────────────────────────────────────── */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.card h2 { font-size: 1.05rem; }
/* Flush table cards: flexgrid.css loads before this file, so its .fg-p-0
   utility loses to .card's padding — restate it here so tables sit edge-to-edge
   in their card on every page (companies/domains/schedule/staff/quotes/tasks). */
.card.fg-p-0 { padding: 0; overflow-x: auto; }
.card .muted { color: var(--c-muted); }

.stat {
    text-align: center;
}
.stat .num { font-size: 2rem; font-weight: 700; color: var(--c-primary-d); }
.stat .label { color: var(--c-muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .4px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid transparent; border-radius: 8px;
    padding: .55rem 1.1rem; font-size: .95rem; font-weight: 600;
    cursor: pointer; background: #e9edf1; color: var(--c-text);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.form-control {
    width: 100%; padding: .6rem .75rem; font-size: 1rem;
    border: 1px solid var(--c-border); border-radius: 8px; background: #fff;
}
.form-control:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(191,25,209,.18); }

/* ── Alerts / flash ──────────────────────────────────────────────────────── */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-danger  { background: #fdecea; color: #922; border-color: #f5c6cb; }
.alert-success { background: #e7f6ec; color: #1c6b3c; border-color: #b7e2c6; }
.alert-info    { background: #e8f4fb; color: #1a5f86; border-color: #bfe0f2; }

/* ── Auth screens ────────────────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #101828 0%, #1d2939 55%, #bf19d1 200%);
    padding: 1rem;
}
.auth-box { width: 100%; max-width: 380px; }
.auth-logo { display: block; width: 220px; max-width: 70%; height: auto; margin: 0 auto 1.75rem; }
.auth-card {
    background: var(--c-surface); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.35);
    padding: 2.25rem; width: 100%;
}
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-card .sub { text-align: center; color: var(--c-muted); margin-bottom: 1.5rem; font-size: .9rem; }

.muted { color: var(--c-muted); }
.text-center { text-align: center; }

/* Dashboard server alert banner */
.dash-alert { border-left: 4px solid var(--c-border); }
.dash-alert-icon { font-size: 1.3rem; line-height: 1; }
.dash-alert-on { border-left-color: var(--c-danger); background: #fdf4f4; }
.dash-alert-on .dash-alert-icon { color: var(--c-danger); }
.dash-alert-ok { border-left-color: var(--c-success); }
.dash-alert-ok .dash-alert-icon { color: var(--c-success); }

/* ── Searchable company picker (assets/js/company-select.js) ─────────────── */
.company-select { position: relative; display: inline-block; min-width: 220px; }
.fg-col-6 > .company-select, .fg-col-12 > .company-select, .ts-fields .company-select { display: block; min-width: 0; }
.ts-fields .company-select > input.form-control { margin-top: .25rem; }
.company-select > input.form-control { width: 100%; padding-right: 2rem; cursor: pointer;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7684' d='M1.6 4.6a.75.75 0 0 1 1.06 0L8 9.94l5.34-5.34a.75.75 0 1 1 1.06 1.06l-5.87 5.87a.75.75 0 0 1-1.06 0L1.6 5.66a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E") no-repeat right .65rem center; }
.company-select > input.form-control:focus { cursor: text; }
.company-select > select { display: none !important; }
.company-select-list {   /* position:fixed — top/left/max-height are set by the script */
    position: fixed; z-index: 1000; max-width: 360px; overflow-y: auto; margin: 0; padding: .25rem 0; list-style: none;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(16,24,40,.12);
}
.company-select-list li { padding: .4rem .75rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-select-list li.is-pinned { font-weight: 600; border-bottom: 1px solid var(--c-border); }
.company-select-list li.is-selected { color: var(--c-primary); font-weight: 600; }
.company-select-list li.is-active { background: rgba(191,25,209,.1); }
.company-select-list li.is-empty { color: var(--c-muted); cursor: default; font-style: italic; border: 0; font-weight: 400; }
