/* ================================================================
   GCA CRM — Global Stylesheet
   Healthcare palette: blues, greens, soft whites
   ================================================================ */

:root {
    --primary:         #1a6fa8;
    --primary-dark:    #145a87;
    --primary-soft:    #e8f3fb;
    --secondary:       #27a469;
    --secondary-soft:  #e6f7ef;
    --accent:          #f59e0b;
    --accent-soft:     #fef3c7;
    --danger:          #dc2626;
    --danger-soft:     #fef2f2;
    --purple:          #7c3aed;
    --purple-soft:     #f5f3ff;
    --teal:            #0891b2;
    --teal-soft:       #ecfeff;

    --ink:             #1a1f2e;
    --ink-2:           #374151;
    --muted:           #6b7280;
    --line:            #e5e7eb;
    --bg:              #ffffff;
    --bg-soft:         #f8fafc;
    --bg-sidebar:      #1a2744;
    --sidebar-text:    #cbd5e1;
    --sidebar-active:  #ffffff;
    --sidebar-hover:   rgba(255,255,255,.08);

    --shadow-sm:       0 1px 3px rgba(0,0,0,.08);
    --shadow:          0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:       0 8px 32px rgba(0,0,0,.14);

    --sidebar-w:       260px;
    --topbar-h:        60px;
    --radius:          8px;
    --radius-lg:       12px;
    --transition:      .18s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-soft);
    color: var(--ink);
    line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ── */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition);
}
.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.10);
}
.sidebar-logo .app-title {
    color: var(--sidebar-active);
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -.01em;
}
.sidebar-logo .agency-name {
    color: var(--sidebar-active);
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .6;
    display: block;
    margin-top: 2px;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
    color: var(--sidebar-text);
    font-size: .70rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .10em;
    padding: 16px 20px 4px;
    opacity: .5;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    font-size: .90rem;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-active);
    text-decoration: none;
}
.nav-item.active {
    background: rgba(255,255,255,.12);
    color: var(--sidebar-active);
    border-left-color: var(--primary);
    font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-group { display: flex; flex-direction: column; }
.nav-sub-item {
    padding-left: 36px;
    font-size: .84rem;
    border-left: none;
    position: relative;
}
.nav-sub-item::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 1px;
    background: rgba(255,255,255,.25);
}
.nav-sub-item svg { width: 15px; height: 15px; }
.nav-sub-item.active::before { background: var(--primary); }
.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.10);
}
.sidebar-user .user-name { color: var(--sidebar-active); font-size: .88rem; font-weight: 600; }
.sidebar-user .user-role { color: var(--sidebar-text); font-size: .78rem; opacity: .7; }
.sidebar-user .logout-link {
    color: var(--sidebar-text);
    font-size: .80rem;
    opacity: .6;
    margin-top: 4px;
    display: inline-block;
}
.sidebar-user .logout-link:hover { opacity: 1; color: var(--danger); text-decoration: none; }

/* Topbar */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--ink-2); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.notif-bell {
    position: relative;
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    cursor: pointer;
    color: var(--muted);
    transition: background var(--transition);
}
.notif-bell:hover { background: var(--primary-soft); color: var(--primary); }
.notif-badge {
    position: absolute;
    top: -3px; right: -3px;
    background: var(--danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    display: none;
}
.notif-badge.show { display: block; }
.notif-dropdown {
    position: absolute;
    top: calc(var(--topbar-h) - 4px);
    right: 24px;
    width: 340px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    display: none;
    overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-header { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: .88rem; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    display: block;
    color: var(--ink);
    transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-soft); text-decoration: none; }
.notif-item.unread { background: var(--primary-soft); }
.notif-item .notif-title { font-weight: 600; font-size: .88rem; }
.notif-item .notif-body  { font-size: .80rem; color: var(--muted); margin-top: 2px; }
.notif-item .notif-time  { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--muted); font-size: .88rem; }

/* Main content */
.main-content {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
    flex: 1;
}
.page-body { padding: 28px 28px; max-width: 1280px; }

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 1.50rem; font-weight: 700; color: var(--ink); }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ── Cards ── */
.card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h2, .card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}
.card-body { padding: 20px; }
.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    background: var(--bg-soft);
    font-size: .84rem;
    color: var(--muted);
}

/* ── Stat cards (dashboard) ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--ink); line-height: 1; }
.stat-label { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    background: none;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--bg); color: var(--ink-2); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg-soft); text-decoration: none; }
.btn-success   { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-success:hover { background: #1e9057; border-color: #1e9057; text-decoration: none; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: #b91c1c; text-decoration: none; color: #fff; }
.btn-sm        { padding: 5px 11px; font-size: .80rem; }
.btn-lg        { padding: 11px 22px; font-size: .95rem; }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); text-decoration: none; }
.btn:disabled  { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Badges / Pills ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-primary   { background: var(--primary-soft);   color: var(--primary); }
.badge-success   { background: var(--secondary-soft); color: var(--secondary); }
.badge-warning   { background: var(--accent-soft);    color: #b45309; }
.badge-danger    { background: var(--danger-soft);    color: var(--danger); }
.badge-purple    { background: var(--purple-soft);    color: var(--purple); }
.badge-muted     { background: var(--bg-soft);        color: var(--muted); border: 1px solid var(--line); }
.badge-teal      { background: var(--teal-soft);      color: var(--teal); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    border-bottom: 2px solid var(--line);
    background: var(--bg-soft);
    white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-soft); }
.table-actions { display: flex; gap: 6px; align-items: center; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }
label { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
label .required { color: var(--danger); margin-left: 2px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=number], input[type=search],
select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: .88rem;
    color: var(--ink);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,111,168,.12);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; min-height: 90px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; padding-right: 32px; }
.form-hint { font-size: .78rem; color: var(--muted); }
.form-error { font-size: .78rem; color: var(--danger); }

/* Checkboxes and radios */
.check-group { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check-item  { display: flex; align-items: center; gap: 6px; font-size: .88rem; cursor: pointer; }
.check-item input[type=checkbox], .check-item input[type=radio] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* Section dividers in forms */
.form-section { margin: 24px 0 8px; }
.form-section-title {
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--primary);
    padding-bottom: 6px;
    border-bottom: 2px solid var(--primary-soft);
    margin-bottom: 12px;
}

/* ── Flash messages ── */
.flash-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash {
    padding: 11px 16px;
    border-radius: var(--radius);
    font-size: .88rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid;
}
.flash svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.flash.success { background: var(--secondary-soft); color: #166534; border-color: #86efac; }
.flash.error   { background: var(--danger-soft);    color: #991b1b; border-color: #fca5a5; }
.flash.info    { background: var(--primary-soft);   color: #1e3a5f; border-color: #93c5fd; }
.flash.warning { background: var(--accent-soft);    color: #92400e; border-color: #fcd34d; }

/* ── Pipeline badge helper ── */
.pipeline-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
}

/* ── Search bar ── */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }

/* ── Filters row ── */
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters-row select, .filters-row input { width: auto; min-width: 150px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
    min-width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: .84rem;
    color: var(--ink-2);
    background: var(--bg);
    text-decoration: none;
    transition: all var(--transition);
    padding: 0 10px;
}
.page-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.page-btn:disabled, .page-btn.disabled { opacity: .4; pointer-events: none; }
.page-info { font-size: .82rem; color: var(--muted); margin-left: 8px; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 2px solid var(--line); gap: 0; margin-bottom: 24px; }
.tab-btn {
    padding: 10px 20px;
    font-size: .88rem;
    font-weight: 500;
    color: var(--muted);
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    cursor: pointer;
    margin-bottom: -2px;
    transition: all var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.active) { color: var(--ink-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Alerts ── */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: .88rem;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-warning { background: var(--accent-soft);    border-color: #fcd34d; color: #92400e; }
.alert-danger  { background: var(--danger-soft);    border-color: #fca5a5; color: #991b1b; }
.alert-info    { background: var(--primary-soft);   border-color: #93c5fd; color: #1e3a5f; }
.alert-success { background: var(--secondary-soft); border-color: #86efac; color: #166534; }

/* ── Misc utilities ── */
.text-muted    { color: var(--muted); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--secondary); }
.text-primary  { color: var(--primary); }
.text-sm       { font-size: .82rem; }
.text-xs       { font-size: .74rem; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.mt-4          { margin-top: 4px; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mt-24         { margin-top: 24px; }
.mb-16         { margin-bottom: 16px; }
.mb-24         { margin-bottom: 24px; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.spacer        { flex: 1; }
.divider       { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.empty-state   { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state svg { width: 48px; height: 48px; opacity: .3; margin-bottom: 12px; }
.empty-state p   { font-size: .92rem; }

/* ── Login page ── */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2744 0%, #1a6fa8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 1.6rem; font-weight: 800; color: var(--primary); letter-spacing: -.01em; }
.login-logo .agency-name { display: block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .10em; color: var(--muted); margin-top: 4px; }
.login-card .btn-primary { width: 100%; justify-content: center; margin-top: 8px; }

/* Password input with toggle button */
#password { padding-right: 44px !important; }
#pw-toggle { z-index: 1; }

/* ── Hamburger for mobile ── */
.sidebar-toggle {
    display: none;
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-soft);
    cursor: pointer;
    color: var(--ink-2);
}
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 190;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .topbar { left: 0; }
    .sidebar-toggle { display: flex; }
    .form-grid, .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .page-body { padding: 16px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .filters-row { flex-direction: column; }
    .filters-row select, .filters-row input { width: 100%; }
    .topbar-title { font-size: .88rem; }
    /* Dashboard & member view 2-col → stack on mobile */
    [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
    [style*="grid-template-columns:2fr 1fr"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 20px; }
}

/* ── Focus-visible ring (keyboard accessibility) ─────────────── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
/* Suppress focus ring for mouse users while keeping it for keyboard */
:focus:not(:focus-visible) { outline: none; }

/* ── Utility animations ─────────────────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
