/* =============================================================
   Bryte Design System — Corporate Clean Theme
   All reusable component classes live here.
   Page-specific overrides go in styles.css.
   ============================================================= */

/* ─── CSS Custom Properties ─────────────────────────────────── */
:root {
    /* Brand colors */
    --bryte-primary:        #1e3a5f;
    --bryte-primary-hover:  #2d5a8e;
    --bryte-accent:         #3b82f6;

    /* Semantic colors */
    --bryte-success:        #059669;
    --bryte-warning:        #f59e0b;
    --bryte-danger:         #ef4444;
    --bryte-info:           #0891b2;
    --bryte-pending:        #7c3aed;

    /* Surface / layout */
    --bryte-bg:             #f8fafc;
    --bryte-card:           #ffffff;
    --bryte-border:         #e2e8f0;

    /* Text */
    --bryte-text:           #1e293b;
    --bryte-text-secondary: #64748b;
    --bryte-text-muted:     #94a3b8;

    /* Shape */
    --bryte-radius:         8px;
    --bryte-radius-sm:      6px;

    /* Elevation */
    --bryte-shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --bryte-shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --bryte-shadow-lg:      0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.05);
}

/* ─── Base / Reset ───────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--bryte-text);
    background: var(--bryte-bg);
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--bryte-primary);
    margin-top: 0;
}

a {
    color: var(--bryte-accent);
    text-decoration: none;
}

a:hover {
    color: var(--bryte-primary-hover);
    text-decoration: underline;
}

/* ─── Shell Header ───────────────────────────────────────────── */
.bryte-header {
    background: var(--bryte-primary);
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: var(--bryte-shadow-md);
}

.bryte-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bryte-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Brand */
.bryte-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #ffffff;
}

.bryte-header-brand:hover {
    color: rgba(255,255,255,.85);
    text-decoration: none;
}

.bryte-header-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.bryte-header-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}

/* ─── App Switcher ───────────────────────────────────────────── */
.bryte-app-switcher {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 32px;
}

.bryte-app-switcher a {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    transition: all .15s ease;
    border: 1px solid transparent;
}

.bryte-app-switcher a:hover {
    color: rgba(255,255,255,.9);
    background: rgba(255,255,255,.1);
    text-decoration: none;
}

.bryte-app-switcher a.active {
    color: #ffffff;
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.3);
    opacity: 1;
}

/* ─── Header Icon Buttons ────────────────────────────────────── */
.bryte-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: rgba(255,255,255,.75);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    text-decoration: none;
    font-size: 16px;
}

.bryte-icon-btn:hover {
    background: rgba(255,255,255,.15);
    color: #ffffff;
    text-decoration: none;
}

/* Avatar */
.bryte-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bryte-accent);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid rgba(255,255,255,.3);
    cursor: pointer;
    user-select: none;
}

/* ─── Desktop User Button ───────────────────────────────────── */
.bryte-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 4px 14px 4px 4px;
    cursor: pointer;
    color: #fff;
    font-size: 13px;
    transition: background-color 0.2s;
}

.bryte-user-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.bryte-user-btn .bryte-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    font-size: 11px;
}

.bryte-user-name {
    font-weight: 500;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Mobile Offcanvas Drawer ───────────────────────────────── */
.bryte-offcanvas {
    max-width: 300px;
}

.bryte-drawer-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--bryte-border);
}

.bryte-drawer-section:last-child {
    border-bottom: none;
}

.bryte-drawer-label {
    padding: 8px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bryte-text-muted);
    font-weight: 600;
}

.bryte-drawer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 14px;
    color: var(--bryte-text);
    text-decoration: none;
    transition: background-color 0.15s;
}

.bryte-drawer-item:hover {
    background-color: var(--bryte-bg);
    color: var(--bryte-text);
}

.bryte-drawer-item.active {
    color: var(--bryte-accent);
    font-weight: 600;
}

.bryte-drawer-item i {
    width: 18px;
    text-align: center;
    color: var(--bryte-text-secondary);
    font-size: 14px;
}

/* ─── Dropdown Menus ─────────────────────────────────────────── */
.bryte-dropdown-wrapper {
    position: relative;
}

.bryte-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    background: var(--bryte-card);
    border: 1px solid var(--bryte-border);
    border-radius: var(--bryte-radius);
    box-shadow: var(--bryte-shadow-lg);
    display: none;
    z-index: 1100;
    padding: 4px 0;
}

.bryte-dropdown.show {
    display: block;
}

.bryte-dropdown-header {
    padding: 8px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--bryte-text-muted);
}

.bryte-dropdown-label {
    padding: 6px 14px 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--bryte-text-muted);
}

.bryte-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--bryte-text);
    text-decoration: none;
    transition: background .1s ease;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.bryte-dropdown-item:hover {
    background: var(--bryte-bg);
    color: var(--bryte-primary);
    text-decoration: none;
}

.bryte-dropdown-divider {
    height: 1px;
    background: var(--bryte-border);
    margin: 4px 0;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.bryte-card {
    background: var(--bryte-card);
    border: 1px solid var(--bryte-border);
    border-radius: var(--bryte-radius);
    box-shadow: var(--bryte-shadow);
    overflow: hidden;
}

.bryte-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--bryte-border);
    background: var(--bryte-bg);
}

.bryte-card-header h2,
.bryte-card-header h3,
.bryte-card-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--bryte-primary);
}

.bryte-card-body {
    padding: 20px;
}

/* ─── Tables ─────────────────────────────────────────────────── */
.bryte-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.bryte-table thead th {
    background: var(--bryte-bg);
    color: var(--bryte-text-secondary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 14px;
    border-bottom: 2px solid var(--bryte-border);
    white-space: nowrap;
}

.bryte-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--bryte-border);
    vertical-align: middle;
    color: var(--bryte-text);
}

.bryte-table tbody tr:last-child td {
    border-bottom: none;
}

.bryte-table tbody tr:hover td {
    background: #f1f5f9;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-bryte-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--bryte-primary);
    color: #ffffff;
    border: 1px solid var(--bryte-primary);
    border-radius: var(--bryte-radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, box-shadow .15s ease;
    line-height: 1.4;
}

.btn-bryte-primary:hover {
    background: var(--bryte-primary-hover);
    border-color: var(--bryte-primary-hover);
    color: #ffffff;
    text-decoration: none;
    box-shadow: var(--bryte-shadow-md);
}

.btn-bryte-primary:active {
    background: var(--bryte-primary);
    box-shadow: none;
}

.btn-bryte-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: transparent;
    color: var(--bryte-primary);
    border: 1px solid var(--bryte-border);
    border-radius: var(--bryte-radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease;
    line-height: 1.4;
}

.btn-bryte-outline:hover {
    background: var(--bryte-bg);
    border-color: var(--bryte-primary);
    color: var(--bryte-primary);
    text-decoration: none;
}

/* ─── Status Badges ──────────────────────────────────────────── */
.bryte-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
}

.bryte-badge-success {
    background: #d1fae5;
    color: #065f46;
}

.bryte-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.bryte-badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.bryte-badge-info {
    background: #e0f2fe;
    color: #0c4a6e;
}

.bryte-badge-pending {
    background: #ede9fe;
    color: #4c1d95;
}

/* ─── Forms ──────────────────────────────────────────────────── */
.bryte-form-control {
    display: block;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--bryte-text);
    background: var(--bryte-card);
    border: 1px solid var(--bryte-border);
    border-radius: var(--bryte-radius-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
    appearance: none;
}

.bryte-form-control:focus {
    outline: none;
    border-color: var(--bryte-accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.bryte-form-control::placeholder {
    color: var(--bryte-text-muted);
}

/* ─── Page Layout ────────────────────────────────────────────── */
.bryte-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

.bryte-page-wide {
    max-width: 100%;
    margin: 0;
    padding: 24px 20px 40px;
}

.bryte-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.bryte-page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--bryte-primary);
    margin: 0 0 2px;
    line-height: 1.3;
}

.bryte-page-subtitle {
    font-size: 13px;
    color: var(--bryte-text-secondary);
    margin: 0;
}

/* ─── Summary / Stats Bar ────────────────────────────────────── */
.bryte-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.bryte-summary-stat {
    background: var(--bryte-card);
    border: 1px solid var(--bryte-border);
    border-radius: var(--bryte-radius);
    padding: 14px 20px;
    flex: 1;
    min-width: 120px;
    box-shadow: var(--bryte-shadow);
}

.bryte-summary-stat .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--bryte-primary);
    line-height: 1.2;
}

.bryte-summary-stat .stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--bryte-text-muted);
    margin-top: 2px;
}

/* ─── Visitor Rows ───────────────────────────────────────────── */
.bryte-visitor-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--bryte-border);
}

.bryte-visitor-row:last-child {
    border-bottom: none;
}

.bryte-visitor-photo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bryte-border);
    flex-shrink: 0;
}

.bryte-visitor-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--bryte-text);
    margin: 0 0 2px;
}

.bryte-visitor-note {
    font-size: 12px;
    color: var(--bryte-text-muted);
}

.bryte-visitor-meta {
    font-size: 13px;
    color: var(--bryte-text-secondary);
    margin: 0;
}

.bryte-visitor-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.bryte-visitor-actions button,
.bryte-visitor-actions .btn-bryte-primary,
.bryte-visitor-actions .btn-bryte-outline,
.bryte-visitor-actions .mark-attendance-btn {
    min-height: 38px;
    min-width: 140px;
    text-align: center;
}

/* ─── Pagination ─────────────────────────────────────────────── */
.bryte-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0 0;
}

.bryte-pagination a,
.bryte-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--bryte-radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--bryte-text-secondary);
    border: 1px solid var(--bryte-border);
    background: var(--bryte-card);
    text-decoration: none;
    transition: all .15s ease;
    cursor: pointer;
}

.bryte-pagination a:hover {
    background: var(--bryte-bg);
    border-color: var(--bryte-primary);
    color: var(--bryte-primary);
    text-decoration: none;
}

.bryte-pagination a.active,
.bryte-pagination span.active {
    background: var(--bryte-primary);
    border-color: var(--bryte-primary);
    color: #ffffff;
}

.bryte-pagination span.disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}

/* ─── HTMX Transitions ───────────────────────────────────────── */
.htmx-swapping {
    opacity: 0;
    transition: opacity .3s ease-out;
}

.htmx-settling {
    transition: opacity .3s ease-in;
}

.htmx-request .htmx-indicator .spinner-border {
    display: inline-block !important;
}

.htmx-request .htmx-indicator .btn-text {
    display: none;
}

/* ─── Mobile / Responsive ────────────────────────────────────── */
.bryte-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    background: none;
    padding: 4px;
}

.bryte-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: rgba(255,255,255,.8);
    border-radius: 2px;
    transition: all .2s ease;
}

/* (mobile menu replaced by Bootstrap offcanvas — see .bryte-offcanvas / .bryte-drawer-*) */

@media (max-width: 768px) {
    /* --- Header --- */
    .bryte-hamburger {
        display: flex;
    }

    .bryte-app-switcher {
        display: none;
    }

    .bryte-header {
        padding: 0 12px;
        height: 48px;
    }

    .bryte-header-title {
        font-size: 14px;
    }

    .bryte-header-logo {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    /* --- Page layout --- */
    .bryte-page {
        padding: 12px 10px 32px;
    }

    .bryte-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .bryte-page-title {
        font-size: 18px;
    }

    /* --- Cards --- */
    .bryte-card {
        border-radius: var(--bryte-radius-sm);
    }

    .bryte-card-header {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .bryte-card-body {
        padding: 12px 14px;
    }

    /* --- Visitor rows (attendance list) — card layout on mobile --- */
    .bryte-visitor-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 16px 14px;
        gap: 8px;
        border-bottom: 1px solid var(--bryte-border);
    }

    .bryte-visitor-photo {
        width: 72px;
        height: 72px;
        margin-right: 0;
        margin-bottom: 4px;
    }

    .bryte-visitor-name {
        font-size: 16px;
        font-weight: 600;
    }

    .bryte-visitor-meta {
        display: none;
    }

    .bryte-visitor-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 4px;
    }

    .bryte-visitor-actions button,
    .bryte-visitor-actions .btn-bryte-primary,
    .bryte-visitor-actions .btn-bryte-outline,
    .bryte-visitor-actions .mark-attendance-btn {
        font-size: 14px;
        padding: 10px 14px;
        min-height: 44px;
        text-align: center;
        width: 100%;
        border-radius: var(--bryte-radius-sm);
    }

    /* --- Summary --- */
    .bryte-summary {
        flex-wrap: wrap;
        gap: 6px;
    }

    .bryte-summary-stat {
        font-size: 12px;
        padding: 3px 10px;
    }

    /* --- Tables (card-style on mobile) --- */
    .bryte-table,
    .bryte-table tbody {
        display: block;
        width: 100%;
    }

    .bryte-table thead {
        display: none;
    }

    .bryte-table tbody tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid var(--bryte-border);
        border-radius: var(--bryte-radius);
        overflow: hidden;
    }

    /* Stack the label above a left-aligned value. Right-aligning values
       (space-between) hides them entirely in windows narrower than the
       browser's ~500px minimum layout width (e.g. Windows snap clips the
       right side of the page instead of reflowing it). */
    .bryte-table tbody td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 8px 12px;
        border-bottom: 1px solid #f1f5f9;
    }

    .bryte-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--bryte-text-muted);
        white-space: nowrap;
    }

    .bryte-table tbody td:last-child {
        border-bottom: none;
    }

    /* --- Buttons --- */
    .btn-bryte-primary,
    .btn-bryte-outline {
        font-size: 12px;
        padding: 6px 12px;
    }

    /* --- Badges --- */
    .bryte-badge {
        font-size: 10px;
        padding: 2px 8px;
    }

    /* --- Dropdowns --- */
    .bryte-dropdown {
        right: -8px;
        min-width: 180px;
    }

    /* --- Pagination --- */
    .bryte-pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .bryte-pagination a,
    .bryte-pagination span {
        font-size: 12px;
        padding: 4px 8px;
    }

    /* --- Forms --- */
    .bryte-form-control {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    /* --- Reimbursement form line items --- */
    .line-item-card {
        padding: 12px;
    }

    /* --- Touch targets --- */
    .bryte-icon-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .bryte-avatar {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }

    .bryte-hamburger {
        min-width: 44px;
        min-height: 44px;
    }

    /* --- Font sizes --- */
    body {
        font-size: 15px;
    }

    .bryte-visitor-name {
        font-size: 15px;
        font-weight: 600;
    }

    /* --- Simplified pagination --- */
    .bryte-pagination a:not(:first-child):not(:last-child):not(.active) {
        display: none;
    }

    /* --- Utility: hide on mobile --- */
    .bryte-hide-mobile {
        display: none !important;
    }
}
