/* ============================================================
   Alpi Diş Partner — Global Styles
   Custom CSS · Mobile-first · Premium Minimal
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────── */
:root {
    /* Brand */
    --primary:        #0066CC;
    --primary-dark:   #004C99;
    --primary-light:  #E8F2FF;
    --accent:         #00B894;
    --accent-dark:    #00997A;

    /* Neutrals */
    --white:          #FFFFFF;
    --gray-50:        #F8F9FA;
    --gray-100:       #F1F3F5;
    --gray-200:       #E9ECEF;
    --gray-300:       #DEE2E6;
    --gray-400:       #CED4DA;
    --gray-500:       #ADB5BD;
    --gray-600:       #868E96;
    --gray-700:       #495057;
    --gray-800:       #343A40;
    --gray-900:       #212529;

    /* Status Colors */
    --success:        #00B894;
    --warning:        #FDCB6E;
    --danger:         #E74C3C;
    --info:           #0984E3;

    /* Typography */
    --font-family:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

    /* Sizing */
    --sidebar-width:  260px;
    --topbar-height:  64px;
    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      16px;
    --radius-full:    9999px;

    /* Shadows */
    --shadow-xs:      0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:      0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:      0 10px 25px rgba(0,0,0,0.08);
    --shadow-xl:      0 20px 50px rgba(0,0,0,0.12);

    /* Transitions */
    --transition:     all 0.2s ease;
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ── Typography ────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; color: var(--gray-900); line-height: 1.3; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
.text-muted { color: var(--gray-600); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

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

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.app-content {
    flex: 1;
    padding: 1.5rem;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    gap: 0.5rem;
}
.sidebar-brand img { height: 32px; width: auto; }
.sidebar-brand .brand-text { white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0; }

.nav-section {
    padding: 0.5rem 1.25rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    transition: var(--transition);
    border-radius: 0;
    margin: 1px 0.5rem;
    border-radius: var(--radius-sm);
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.65;
    flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: var(--white);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.8125rem;
    color: var(--gray-500);
}

/* ── Topbar ────────────────────────────────────────────── */
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--gray-900); }

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-700);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}
.topbar-user:hover { background: var(--gray-100); }
.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}
.topbar-user-info { display: flex; flex-direction: column; }
.topbar-user-name { font-size: 0.8125rem; font-weight: 500; color: var(--gray-800); }
.topbar-user-role { font-size: 0.6875rem; color: var(--gray-500); }

/* Notification bell */
.topbar-notif {
    position: relative;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    transition: var(--transition);
}
.topbar-notif:hover { color: var(--gray-900); }
.topbar-notif .notif-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--white);
}

/* ── Dropdown ──────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding: 0.5rem 0;
    margin-top: 0.25rem;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    transition: var(--transition);
}
.dropdown-item:hover { background: var(--gray-100); color: var(--gray-900); }
.dropdown-divider { border-top: 1px solid var(--gray-200); margin: 0.25rem 0; }

/* ── Page Header ───────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; }
.page-header .breadcrumb {
    font-size: 0.8125rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.25rem;
}
.page-header .breadcrumb a { color: var(--gray-500); }
.page-header .breadcrumb a:hover { color: var(--primary); }

/* ── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    transition: var(--transition);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.card-header h3 { font-size: 1rem; margin: 0; }
.card-body { padding: 1.25rem; }
.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ── Stat Cards (Dashboard) ────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    box-shadow: var(--shadow-xs);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-card .stat-info { flex: 1; }
.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}
.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}
.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }
.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #E6F9F2; color: var(--success); }
.stat-icon.yellow { background: #FFF8E1; color: #F39C12; }
.stat-icon.red { background: #FDEDEC; color: var(--danger); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.5;
}
.btn:focus { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--white); }

.btn-secondary { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: var(--accent-dark); color: var(--white); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #C0392B; color: var(--white); }

.btn-warning { background: var(--warning); color: var(--gray-900); }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--white); }

.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); }

.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}
.form-label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control.error { border-color: var(--danger); }

textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23495057' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
}
.form-hint {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.form-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.form-switch input { opacity: 0; width: 0; height: 0; }
.form-switch .slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 22px;
    cursor: pointer;
    transition: var(--transition);
}
.form-switch .slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: var(--transition);
}
.form-switch input:checked + .slider { background: var(--primary); }
.form-switch input:checked + .slider::before { transform: translateX(18px); }

/* ── Tables ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}
.table th {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--gray-600);
    background: var(--gray-50);
    white-space: nowrap;
}
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: 0.375rem; white-space: nowrap; }

/* ── Badges / Status ───────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #E6F9F2; color: #00805E; }
.badge-warning { background: #FFF8E1; color: #A67C00; }
.badge-danger { background: #FDEDEC; color: #C0392B; }
.badge-info { background: #E8F2FF; color: #0066CC; }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }
.badge-purple { background: #F3E8FF; color: #7C3AED; }

/* Specific referral statuses */
.status-new_lead { background: #E8F2FF; color: #0066CC; }
.status-contacted { background: #E8F2FF; color: #0984E3; }
.status-unreachable { background: var(--gray-200); color: var(--gray-700); }
.status-appointment_scheduled { background: #F3E8FF; color: #7C3AED; }
.status-visited_clinic { background: #E6F9F2; color: #00805E; }
.status-no_show { background: #FDEDEC; color: #C0392B; }
.status-treatment_planned { background: #FFF8E1; color: #A67C00; }
.status-treatment_accepted { background: #E6F9F2; color: #00805E; }
.status-treatment_rejected { background: #FDEDEC; color: #C0392B; }
.status-payment_received { background: #E6F9F2; color: #006B50; }
.status-provision_waiting { background: #FFF8E1; color: #A67C00; }
.status-commission_ready { background: #E6F9F2; color: #00805E; }
.status-commission_paid { background: #00B894; color: #FFFFFF; }

/* Partner statuses */
.partner-pending { background: #FFF8E1; color: #A67C00; }
.partner-active { background: #E6F9F2; color: #00805E; }
.partner-suspended { background: #FDEDEC; color: #C0392B; }
.partner-rejected { background: var(--gray-200); color: var(--gray-700); }

/* ── Alerts / Flash Messages ───────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.alert-success { background: #E6F9F2; color: #00805E; border: 1px solid #B2E6D4; }
.alert-error { background: #FDEDEC; color: #C0392B; border: 1px solid #F5C6CB; }
.alert-warning { background: #FFF8E1; color: #856404; border: 1px solid #FCEFC7; }
.alert-info { background: #E8F2FF; color: #0066CC; border: 1px solid #B8D4F0; }
.alert .alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.125rem;
    color: inherit;
    opacity: 0.5;
    padding: 0;
    line-height: 1;
}
.alert .alert-close:hover { opacity: 1; }

/* ── Pagination ────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
    margin-top: 1rem;
}
.pagination a, .pagination span {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    transition: var(--transition);
}
.pagination a:hover { background: var(--gray-100); }
.pagination .active span {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}
.pagination .disabled span { opacity: 0.4; cursor: not-allowed; }

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    gap: 0;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tab-item {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
}
.tab-item:hover { color: var(--gray-800); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { margin: 0; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--gray-500);
    padding: 0.25rem;
}
.modal-body { padding: 1.25rem; }
.modal-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ── Empty State ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gray-500);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 1rem; opacity: 0.3; }
.empty-state h3 { color: var(--gray-700); margin-bottom: 0.25rem; }
.empty-state p { margin-bottom: 1rem; }

/* ── Avatar ────────────────────────────────────────────── */
.avatar {
    width: 40px; height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.25rem; }

/* ── Utility ───────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.p-0 { padding: 0; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.hidden { display: none; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ── Filters Bar ───────────────────────────────────────── */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filters-bar .form-control { max-width: 200px; }
.search-input { position: relative; }
.search-input input { padding-left: 2.25rem; }
.search-input svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--gray-400);
}

/* ── Loading Spinner ───────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login Page ────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    padding: 1rem;
}
.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}
.login-card .login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-card .login-logo h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-top: 0.5rem;
}
.login-card .login-logo p { color: var(--gray-500); font-size: 0.875rem; }

/* ── Partner Panel ─────────────────────────────────────── */
.panel-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.panel-topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 90;
}
.panel-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.panel-nav {
    display: flex;
    gap: 0.25rem;
}
.panel-nav .nav-link {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.panel-nav .nav-link:hover { background: var(--gray-100); color: var(--gray-800); }
.panel-nav .nav-link.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }

.panel-mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 0.5rem;
    z-index: 100;
}
.panel-mobile-nav .mobile-nav-items {
    display: flex;
    justify-content: space-around;
}
.panel-mobile-nav .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    font-size: 0.625rem;
    color: var(--gray-500);
    padding: 0.25rem 0.5rem;
    text-decoration: none;
}
.panel-mobile-nav .mobile-nav-item.active { color: var(--primary); }

/* ── Referral Landing ──────────────────────────────────── */
.ref-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0066CC 0%, #004C99 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--white);
}
.ref-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 500px;
    color: var(--gray-800);
}

/* ── Timeline ──────────────────────────────────────────── */
.timeline { padding: 0; list-style: none; }
.timeline-item {
    display: flex;
    gap: 0.75rem;
    padding-bottom: 1rem;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 24px;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 1;
}
.timeline-content { flex: 1; }
.timeline-content .time { font-size: 0.75rem; color: var(--gray-500); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .btn-menu-toggle { display: flex; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; align-items: flex-start; }

    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar .form-control { max-width: 100%; }

    .topbar-user-info { display: none; }

    /* Panel mobile nav */
    .panel-nav { display: none; }
    .panel-mobile-nav { display: block; }
    .panel-content { padding-bottom: 5rem; }

    .table { font-size: 0.8125rem; }
    .table th, .table td { padding: 0.5rem 0.75rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .app-content { padding: 1rem; }
    .panel-content { padding: 1rem; padding-bottom: 5rem; }
    .login-card { padding: 1.5rem; }
    h1 { font-size: 1.375rem; }
}

/* ── Sidebar Overlay (mobile) ──────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ── Print ─────────────────────────────────────────────── */
@media print {
    .app-sidebar, .app-topbar, .panel-topbar, .panel-mobile-nav,
    .btn, .filters-bar, .pagination { display: none !important; }
    .app-main { margin-left: 0; }
    .app-content { padding: 0; }
}

/* ── Achievement Badges ────────────────────────────────── */
.achievement-badge {
    text-align: center;
    padding: 1rem 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}
.achievement-badge.earned {
    background: #FFF8E1;
    border-color: #FCEFC7;
}
.achievement-badge.locked {
    background: var(--gray-50);
    opacity: 0.5;
    filter: grayscale(0.8);
}
.achievement-badge .achievement-icon {
    font-size: 1.75rem;
    line-height: 1;
    margin-bottom: 0.375rem;
    color: var(--primary);
}
.achievement-badge.earned .achievement-icon {
    color: #D4A017;
}
.achievement-badge.locked .achievement-icon {
    color: var(--gray-500);
}
.achievement-badge .achievement-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.3;
}
.achievement-badge .achievement-date {
    font-size: 0.625rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}
.achievement-badge.earned:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* ── Tabler Icon Helpers ───────────────────────────────── */
.ti { vertical-align: -2px; }
.ti-sm { font-size: 1rem; }
.ti-md { font-size: 1.25rem; }
.ti-lg { font-size: 1.5rem; }
.ti-xl { font-size: 2rem; }
.ti-2xl { font-size: 2.5rem; }

/* ── Funnel Container ──────────────────────────────────── */
.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.funnel-step {
    margin-bottom: 0.25rem;
}
.funnel-step-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

/* ── Priority Badges ───────────────────────────────────── */
.priority-urgent { background: #FDEDEC; color: #C0392B; }
.priority-high { background: #FFF8E1; color: #A67C00; }
.priority-normal { background: #E8F2FF; color: #0066CC; }
.priority-low { background: var(--gray-200); color: var(--gray-700); }

/* ── Call Center Process Page ────────────────────────────── */
.process-header {
    display: flex; align-items: center; gap: 1rem;
    background: var(--white); padding: 1.25rem 1.5rem;
    border-radius: 8px; box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem; border: 1px solid var(--gray-200);
}
.process-patient-info { flex: 1; }
.process-patient-info h2 { margin: 0 0 0.25rem; font-size: 1.25rem; }
.process-patient-info .meta { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.process-patient-info .meta-item { display: flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; color: var(--text-muted); }
.process-patient-info .meta-item i { font-size: 1rem; }

.process-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.call-btn {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.625rem 1.25rem; border-radius: 8px;
    font-size: 0.875rem; font-weight: 600; cursor: pointer;
    border: none; transition: all 0.15s ease;
    text-decoration: none;
}
.call-btn-phone { background: var(--success); color: #fff; }
.call-btn-phone:hover { background: #047857; }
.call-btn-whatsapp { background: #25D366; color: #fff; }
.call-btn-whatsapp:hover { background: #1da851; }

.call-log-item {
    display: flex; align-items: flex-start; gap: 0.75rem;
    padding: 0.75rem 0; border-bottom: 1px solid var(--gray-100);
}
.call-log-item:last-child { border-bottom: none; }
.call-log-icon { flex-shrink: 0; width: 28px; text-align: center; padding-top: 0.125rem; }
.call-log-content { flex: 1; }
.call-log-content .result { font-size: 0.875rem; font-weight: 500; }
.call-log-content .detail { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }
.call-log-content .note { font-size: 0.8125rem; color: var(--text); margin-top: 0.375rem; padding: 0.5rem; background: var(--gray-50); border-radius: 6px; }
.call-log-time { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

.status-flow {
    display: flex; align-items: center; gap: 0; overflow-x: auto;
    padding: 1rem 0; margin: 0 -0.25rem;
}
.status-flow-step {
    display: flex; flex-direction: column; align-items: center;
    padding: 0 0.5rem; min-width: 90px; position: relative;
}
.status-flow-step .dot {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; margin-bottom: 0.375rem;
    border: 2px solid var(--gray-300); background: var(--white); color: var(--gray-400);
    transition: all 0.2s;
}
.status-flow-step.active .dot { border-color: var(--primary); background: var(--primary); color: #fff; }
.status-flow-step.completed .dot { border-color: var(--success); background: var(--success); color: #fff; }
.status-flow-step.failed .dot { border-color: var(--danger); background: var(--danger); color: #fff; }
.status-flow-step .label { font-size: 0.6875rem; text-align: center; color: var(--text-muted); line-height: 1.2; }
.status-flow-step.active .label { color: var(--primary); font-weight: 600; }
.status-flow-step.completed .label { color: var(--success); }
.status-flow-connector {
    flex-shrink: 0; width: 32px; height: 2px; background: var(--gray-300); margin-bottom: 1.5rem;
}
.status-flow-connector.completed { background: var(--success); }

.quick-action-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
}
.quick-action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    padding: 1rem; border-radius: 8px; border: 1px solid var(--gray-200);
    background: var(--white); cursor: pointer; transition: all 0.15s;
    text-align: center; text-decoration: none; color: var(--text);
}
.quick-action-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.quick-action-btn i { font-size: 1.5rem; }
.quick-action-btn span { font-size: 0.75rem; font-weight: 500; }

/* ── QR Code Responsive ───────────────────────────────── */
@media (max-width: 768px) {
    .achievement-badge .achievement-icon { font-size: 1.5rem; }
    .achievement-badge { padding: 0.75rem 0.375rem; }
}

@media (max-width: 480px) {
    /* Stack QR code below link on mobile */
    [style*="grid-template-columns:1fr auto"] {
        grid-template-columns: 1fr !important;
    }
    /* Stack how it works steps */
    [style*="grid-template-columns:repeat(4"] {
        grid-template-columns: 1fr 1fr !important;
    }
    /* Stack quick actions on mobile */
    [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }
}
