/* ============================================================
   Phoenix PMS - Theme
   Brand: #6C7AE0 (periwinkle from logo)
   Mobile-first, responsive, no framework
   ============================================================ */

:root {
    --brand:        #6C7AE0;
    --brand-dark:   #5764C9;
    --brand-light:  #8B96E8;
    --brand-pale:   #EEF0FB;
    --brand-paler:  #F6F7FC;
    --ink:          #1F2347;
    --ink-soft:     #4A4F6E;
    --muted:        #8B90A8;
    --line:         #E3E6F3;
    --line-strong:  #C9CFE5;
    --bg:           #FFFFFF;
    --surface:      #F6F7FC;
    --success:      #1FAB6D;
    --success-bg:   #E2F6EC;
    --warning:      #C28200;
    --warning-bg:   #FFF4DB;
    --danger:       #D23E48;
    --danger-bg:    #FCE6E8;
    --info:         #6C7AE0;
    --info-bg:      #EEF0FB;
    --shadow-sm:    0 1px 2px rgba(31,35,71,.06), 0 1px 3px rgba(31,35,71,.04);
    --shadow:       0 4px 12px rgba(31,35,71,.08), 0 1px 3px rgba(31,35,71,.04);
    --shadow-lg:    0 12px 32px rgba(31,35,71,.12), 0 4px 8px rgba(31,35,71,.06);
    --radius:       8px;
    --radius-lg:    12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

h1, h2, h3, h4 { color: var(--ink); margin: 0 0 12px 0; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

/* ===== App Layout ===== */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
}
.topbar {
    grid-area: topbar;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar .topbar-title { font-weight: 600; font-size: 15px; color: var(--ink); }
.topbar .topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar .user-pill {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 12px; border-radius: 100px;
    background: var(--brand-pale);
    color: var(--ink);
    font-size: 13px;
}
.topbar .user-pill .avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--brand); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 12px;
}
.topbar .user-pill .role { color: var(--muted); font-size: 11px; }

.sidebar {
    grid-area: sidebar;
    background: linear-gradient(180deg, #1F2347 0%, #2A2F5C 100%);
    color: #DDE0F0;
    padding: 0;
    overflow-y: auto;
    position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand img { width: 38px; height: auto; filter: brightness(0) invert(1); }
.sidebar .brand .name { font-weight: 600; color: white; font-size: 15px; }
.sidebar .brand .tag  { color: rgba(255,255,255,.5); font-size: 11px; }
.sidebar .nav { padding: 8px 0; }
.sidebar .nav-section {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: rgba(255,255,255,.35); padding: 14px 20px 6px;
}
.sidebar .nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: #DDE0F0; text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 13px;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.05); color: white; text-decoration: none; }
.sidebar .nav-link.active {
    background: rgba(108,122,224,.18);
    border-left-color: var(--brand);
    color: white;
}
.sidebar .nav-link .icon { width: 18px; text-align: center; opacity: .8; }
.sidebar .company-pill {
    margin: 12px 16px; padding: 8px 12px;
    background: rgba(255,255,255,.06);
    border-radius: var(--radius);
    font-size: 12px; color: rgba(255,255,255,.7);
}
.sidebar .company-pill .label { font-size: 10px; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: 1px; }
.sidebar .company-pill .name { color: white; font-weight: 600; margin-top: 2px; }

.main {
    grid-area: main;
    padding: 20px;
    overflow-x: auto;
}
.main-inner { max-width: 1280px; margin: 0 auto; }

/* ===== Page header ===== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-header .actions { display: flex; gap: 8px; }

/* ===== Card ===== */
.card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.card-title {
    font-size: 14px; font-weight: 600; color: var(--ink);
    margin: 0 0 16px 0; padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: center;
}

/* ===== Stat cards ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg); border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: 18px;
    box-shadow: var(--shadow-sm);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--brand);
}
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--ink); margin-top: 6px; }
.stat-card .delta { font-size: 12px; color: var(--success); margin-top: 4px; }
.stat-card .delta.down { color: var(--danger); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 13px; font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .15s ease;
    background: var(--bg); color: var(--ink);
    border-color: var(--line);
}
.btn:hover { text-decoration: none; border-color: var(--line-strong); background: var(--brand-paler); }
.btn-primary {
    background: var(--brand); color: white; border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: white; }
.btn-outline { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: var(--brand-pale); color: var(--brand-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b53038; border-color: #b53038; color: white; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--brand-pale); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.form-row.cols-1 { grid-template-columns: 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--ink-soft); margin-bottom: 4px;
}
.form-group .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--ink);
    background: var(--bg);
    font-family: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(108,122,224,.18);
}
textarea.form-control { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.required { color: var(--danger); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
table.data {
    width: 100%; border-collapse: collapse; font-size: 13px;
    background: var(--bg);
}
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th {
    background: var(--brand-paler);
    color: var(--ink-soft);
    font-weight: 600; font-size: 11px; text-transform: uppercase;
    letter-spacing: .5px; white-space: nowrap;
}
table.data tbody tr:hover { background: var(--brand-paler); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .actions { white-space: nowrap; }
table.data .actions a { margin-right: 8px; }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    background: var(--brand-pale); color: var(--brand-dark);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-muted   { background: var(--surface);    color: var(--muted); }

/* ===== Alerts ===== */
.alert {
    padding: 12px 40px 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    position: relative;
    border: 1px solid transparent;
}
.alert-info     { background: var(--info-bg);    color: var(--brand-dark); border-color: var(--brand-pale); }
.alert-success  { background: var(--success-bg); color: var(--success);    border-color: #C7EBD9; }
.alert-warning  { background: var(--warning-bg); color: var(--warning);    border-color: #FAE3A8; }
.alert-error    { background: var(--danger-bg);  color: var(--danger);     border-color: #F5C2C7; }
.alert-close {
    position: absolute; top: 6px; right: 8px;
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: inherit; opacity: .5;
}
.alert-close:hover { opacity: 1; }

/* ===== Login layout ===== */
.auth-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #6C7AE0 0%, #5764C9 50%, #1F2347 100%);
}
.auth-card {
    background: var(--bg); width: 100%; max-width: 420px;
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.auth-card .auth-logo { text-align: center; margin-bottom: 22px; }
.auth-card .auth-logo img { max-width: 110px; height: auto; }
.auth-card .auth-title { text-align: center; margin: 0 0 4px; font-size: 20px; }
.auth-card .auth-tag   { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }

/* ===== Misc utilities ===== */
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.empty-state {
    text-align: center; padding: 48px 16px;
    color: var(--muted); font-size: 14px;
}
.empty-state .big-icon {
    font-size: 42px; margin-bottom: 8px; color: var(--brand-light);
}

/* ===== Responsive ===== */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; font-size: 22px; color: var(--ink); }

@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: 56px 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    .sidebar {
        position: fixed; top: 0; left: -260px; width: 240px; height: 100vh;
        z-index: 50; transition: left .25s ease; box-shadow: var(--shadow-lg);
    }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-block; }
    .form-row { grid-template-columns: 1fr; }
    .form-row.cols-3 { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .main { padding: 12px; }
}

.backdrop {
    display: none; position: fixed; inset: 0; background: rgba(31,35,71,.4); z-index: 40;
}
.backdrop.show { display: block; }

@media print {
    .sidebar, .topbar, .actions, .btn, .menu-toggle { display: none !important; }
    .app { grid-template-columns: 1fr; grid-template-areas: "main"; }
    .main { padding: 0; }
    .card { border: none; box-shadow: none; }
}
