/*
 * portal.css
 * Chena Innovations Portal
 * (C) 2026 Chena Innovations, LLC
 * Intellectual Property of Chena Innovations, LLC
 * Created by Billy Jack Wiglesworth on 04/16/2026.
 *
 * Self-hosted — no CDN dependencies. Fonts loaded from /fonts/.
 * Uses the same Barlow Condensed brand font from the main website
 * for headings, with a clean system font stack for body text.
 */

/* ── fonts ─────────────────────────────────────────────────────────────────── */

@font-face {
    font-family: 'Barlow Condensed';
    src: url('/fonts/BarlowCondensed-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ── reset + base ──────────────────────────────────────────────────────────── */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    color: #212529;
    background: #f8f9fa;
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: #0d6efd;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* ── color variables ───────────────────────────────────────────────────────── */

:root {
    --brand-dark: #1a1a2e;
    --brand-accent: #0d6efd;
    --brand-accent-hover: #0b5ed7;
    --brand-success: #28a745;
    --brand-danger: #dc3545;
    --brand-warning: #ffc107;
    --brand-muted: #6c757d;
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-light: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 4px;
}

/* ── typography ────────────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--text-primary);
}

h1 { font-size: 2rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }

/* ── layout: login page ────────────────────────────────────────────────────── */

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--brand-dark);
    padding: 2rem;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-card .logo {
    display: block;
    margin: 0 auto 1.5rem;
    max-width: 200px;
    height: auto;
}

.login-card h1 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ── layout: app shell (sidebar + main) ─────────────────────────────────── */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header .logo {
    max-width: 160px;
    height: auto;
    margin-bottom: 0.5rem;
}

.sidebar-header .user-name {
    font-size: 0.875rem;
    color: #185FA5;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.8);
    font-size: 0.9375rem;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-nav a .nav-icon {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-nav .nav-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.4);
    padding: 1.25rem 1.5rem 0.5rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
    color: rgba(255,255,255,0.6);
    font-size: 0.875rem;
    text-decoration: none;
}
.sidebar-footer a:hover {
    color: #fff;
}

/* ── main content area ─────────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    max-width: 1200px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* ── cards ──────────────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* ── tables ─────────────────────────────────────────────────────────────────── */

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border-color);
}

tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tbody tr:hover {
    background: #f8f9fa;
}

/* ── forms ──────────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* ── buttons ───────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--brand-accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--brand-accent-hover);
}

.btn-success {
    background: var(--brand-success);
    color: #fff;
}

.btn-danger {
    background: var(--brand-danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--brand-accent);
    border: 1px solid var(--brand-accent);
}
.btn-outline:hover {
    background: var(--brand-accent);
    color: #fff;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── status badges ─────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-draft      { background: #e9ecef; color: #495057; }
.badge-sent       { background: #cfe2ff; color: #084298; }
.badge-paid       { background: #d1e7dd; color: #0f5132; }
.badge-overdue    { background: #f8d7da; color: #842029; }
.badge-void       { background: #e9ecef; color: #6c757d; }
.badge-pending    { background: #fff3cd; color: #664d03; }
.badge-active     { background: #d1e7dd; color: #0f5132; }
.badge-suspended  { background: #f8d7da; color: #842029; }
.badge-open       { background: #cfe2ff; color: #084298; }
.badge-in_progress { background: #cfe2ff; color: #084298; }
.badge-finished    { background: #d4edda; color: #155724; }
.badge-billing_pending { background: #fff3cd; color: #664d03; }
.badge-waiting    { background: #e2e3e5; color: #41464b; }
.badge-resolved   { background: #d1e7dd; color: #0f5132; }
.badge-closed     { background: #e9ecef; color: #6c757d; }
.badge-succeeded  { background: #d1e7dd; color: #0f5132; }
.badge-failed     { background: #f8d7da; color: #842029; }
.badge-refunded   { background: #e2e3e5; color: #41464b; }

/* ── alerts ────────────────────────────────────────────────────────────────── */

.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
}

.alert-error {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

.alert-success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.alert-info {
    background: #cff4fc;
    color: #055160;
    border: 1px solid #b6effb;
}

/* ── loading spinner ───────────────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--border-color);
    border-top-color: var(--brand-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* ── empty state ───────────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ── detail page: key-value pairs ──────────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem 1.5rem;
    font-size: 0.9375rem;
}

.detail-grid dt {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding-top: 0.125rem;
}

.detail-grid dd {
    color: var(--text-primary);
}

/* ── ticket thread ─────────────────────────────────────────────────────────── */

.comment-thread {
    margin-top: 1.5rem;
}

.comment {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.comment:last-child {
    border-bottom: none;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.comment-avatar.staff {
    background: var(--brand-dark);
}

.comment-avatar.internal {
    background: var(--brand-warning);
    color: #212529;
}

.comment-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.comment-body {
    font-size: 0.9375rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── responsive: collapse sidebar on narrow screens ────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
}

/* ── profile page ──────────────────────────────────────────────────────────── */

.profile-name-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-control-disabled {
    background: #e9ecef;
}

.form-help-text {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

.section-heading {
    margin-top: 1.5rem;
}

.btn-save {
    margin-top: 1rem;
}

.staff-profile-note {
    margin-top: 1rem;
}