/**
 * Premium UI Styles - بوصلة كلينك
 * Shared premium design system for all pages
 * Referenced by all redesigned pages to avoid duplication
 */

/* ═══════════════════════════════════════════
   CSS Variables
   ═══════════════════════════════════════════ */
:root {
    --brand-color: #004A8F;
    --clinic-color: #059669;
    --font-ar: 'Cairo', sans-serif;
    --font-en: 'Roboto', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}
* { font-family: 'Cairo', sans-serif; }

/* ═══════════════════════════════════════════
   Page Hero Banner
   ═══════════════════════════════════════════ */
.page-hero {
    background: linear-gradient(135deg, var(--sidebar-bg-end, #0f172a) 0%, var(--sidebar-bg-start, #1e3a5f) 50%, var(--primary, #059669) 100%);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    padding: 1.5rem 1.75rem;
}
@media (min-width: 768px) {
    .page-hero {
        padding: 2rem;
    }
}
.page-hero > * {
    position: relative;
    z-index: 1;
}
.page-hero {
    color: #fff !important;
}
.page-hero h1 {
    color: #fff !important;
    font-weight: 800 !important;
}
.page-hero :where(h2,h3,h4,h5,h6,p,span,small,b,strong,label,a) {
    color: rgba(255,255,255,0.92) !important;
}
.page-hero [class*="text-gray-"] {
    color: rgba(255,255,255,0.92) !important;
}
.page-hero .hero-stat-chip,
.page-hero .hero-stat-chip * {
    color: #fff !important;
}
.page-hero i[data-feather],
.page-hero svg,
.page-hero i.fa, .page-hero i.fas, .page-hero i.far, .page-hero i.fal, .page-hero i.fab {
    color: #fff !important;
    stroke: #fff !important;
}
.page-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(var(--primary-rgb, 5,150,105), 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(var(--primary-rgb, 5,150,105), 0.1) 0%, transparent 40%);
}
.page-hero::after {
    content: '';
    position: absolute;
    top: -30px; left: -30px;
    width: 200px; height: 200px;
    background: 
        linear-gradient(rgba(255,255,255,0.03) 2px, transparent 2px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 2px, transparent 2px);
    background-size: 30px 30px;
    transform: rotate(15deg);
}

/* Hero Stat Chips */
.hero-stat-chip {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 12px 20px;
    text-align: center;
    transition: transform 0.2s;
}
.hero-stat-chip:hover { transform: translateY(-2px); }
.hero-stat-chip .chip-val { 
    font-size: 1.75rem; font-weight: 800; color: #fff; line-height: 1; 
}
.hero-stat-chip .chip-label { 
    font-size: 0.7rem; color: rgba(255,255,255,0.88); margin-top: 4px; font-weight: 600; 
}

.page-hero p.text-white\/50,
.page-hero p.text-white\/60,
.page-hero p.text-white\/70,
.page-hero p.text-white\/75 {
    color: rgba(255,255,255,0.92) !important;
}

/* Hero-equivalent mapping for sensitive pages (dashboard/doctor/settings) */
.hero-equivalent {
    position: relative;
    overflow: hidden;
}
.hero-equivalent > * {
    position: relative;
    z-index: 1;
}
.hero-equivalent :where(h1,h2,h3,h4,p,span,small,b,strong,label,a) {
    color: rgba(255,255,255,0.92);
}
.hero-equivalent .text-white\/70,
.hero-equivalent .text-white\/80,
.hero-equivalent .text-white\/50 {
    color: rgba(255,255,255,0.92) !important;
}

/* Auto-align hero blocks that use: title row + description + stat chips */
.page-hero:has(> p):has(> .flex.flex-wrap > .hero-stat-chip),
.page-hero:has(> p):has(> div.flex.flex-wrap > .hero-stat-chip),
.page-hero:has(> p):has(> span.flex.flex-wrap > .hero-stat-chip) {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    grid-template-areas:
        "hero-head hero-stats"
        "hero-desc hero-stats";
    align-items: center;
    column-gap: 1rem;
    row-gap: 0.4rem;
}
.page-hero:has(> p):has(> .flex.flex-wrap > .hero-stat-chip) > :first-child,
.page-hero:has(> p):has(> div.flex.flex-wrap > .hero-stat-chip) > :first-child,
.page-hero:has(> p):has(> span.flex.flex-wrap > .hero-stat-chip) > :first-child {
    grid-area: hero-head;
    margin-bottom: 0 !important;
}
.page-hero:has(> p):has(> .flex.flex-wrap > .hero-stat-chip) > p:first-of-type,
.page-hero:has(> p):has(> div.flex.flex-wrap > .hero-stat-chip) > p:first-of-type,
.page-hero:has(> p):has(> span.flex.flex-wrap > .hero-stat-chip) > p:first-of-type {
    grid-area: hero-desc;
    margin: 0 !important;
}
.page-hero:has(> p):has(> .flex.flex-wrap > .hero-stat-chip) > .flex.flex-wrap,
.page-hero:has(> p):has(> div.flex.flex-wrap > .hero-stat-chip) > div.flex.flex-wrap,
.page-hero:has(> p):has(> span.flex.flex-wrap > .hero-stat-chip) > span.flex.flex-wrap {
    grid-area: hero-stats;
    justify-content: flex-start;
    align-self: center;
}
@media (max-width: 1024px) {
    .page-hero:has(> p):has(> .flex.flex-wrap > .hero-stat-chip),
    .page-hero:has(> p):has(> div.flex.flex-wrap > .hero-stat-chip),
    .page-hero:has(> p):has(> span.flex.flex-wrap > .hero-stat-chip) {
        grid-template-columns: 1fr;
        grid-template-areas:
            "hero-head"
            "hero-desc"
            "hero-stats";
    }
}

/* ═══════════════════════════════════════════
   Stat Tiles
   ═══════════════════════════════════════════ */
.stat-tile {
    background: #fff;
    border-radius: 18px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
    transition: all 0.25s ease;
}
.stat-tile:hover {
    box-shadow: 0 8px 25px rgba(var(--primary-rgb, 5,150,105), 0.1);
    transform: translateY(-3px);
}
.stat-tile::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 4px; height: 100%;
    background: var(--primary-gradient, linear-gradient(180deg, #059669, #047857));
    border-radius: 0 18px 18px 0;
}
.stat-tile .tile-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 5,150,105), 0.1), rgba(var(--primary-rgb, 5,150,105), 0.05));
    color: var(--primary, #059669);
    flex-shrink: 0;
}
.stat-tile .tile-num {
    font-size: 1.5rem; font-weight: 800;
    color: var(--primary-dark, #047857);
    line-height: 1;
}
.stat-tile .tile-label {
    font-size: 0.8rem; color: #9ca3af; font-weight: 600; margin-top: 2px;
}

/* Debt stat tile special styling */
.stat-tile.debt-tile::before {
    background: linear-gradient(180deg, #dc2626, #b91c1c);
}
.stat-tile.warning-tile::before {
    background: linear-gradient(180deg, #f59e0b, #d97706);
}
.stat-tile.info-tile::before {
    background: linear-gradient(180deg, #3b82f6, #2563eb);
}

/* ═══════════════════════════════════════════
   Command Bar (Search + Actions)
   ═══════════════════════════════════════════ */
.command-bar {
    background: #fff;
    border-radius: 18px;
    padding: 20px 24px;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.search-box {
    position: relative;
}
.search-box input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 2px solid #f1f5f9;
    border-radius: 14px;
    font-size: 0.9rem;
    background: #f8fafc;
    transition: all 0.2s;
    outline: none;
}
.search-box input:focus {
    border-color: var(--primary, #059669);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 5,150,105), 0.1);
    background: #fff;
}
.search-box .search-icon {
    position: absolute;
    right: 14px;
    top: 50%; transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
html[dir="ltr"] .search-box .search-icon {
    right: auto;
    left: 14px;
}
html[dir="ltr"] .search-box input {
    padding: 12px 16px 12px 44px;
}

/* Filter Select */
.filter-select {
    padding: 12px 16px;
    border: 2px solid #f1f5f9;
    border-radius: 14px;
    font-size: 0.85rem;
    background: #f8fafc;
    color: #475569;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
}
.filter-select:focus {
    border-color: var(--primary, #059669);
}

/* ═══════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════ */
.btn-primary-themed {
    background: var(--primary-gradient, linear-gradient(135deg, #059669, #047857));
    color: #fff;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(var(--primary-rgb, 5,150,105), 0.3);
    white-space: nowrap;
    font-size: 0.875rem;
}
.btn-primary-themed:hover {
    box-shadow: 0 6px 20px rgba(var(--primary-rgb, 5,150,105), 0.45);
    transform: translateY(-1px);
}
.btn-outline-themed {
    background: rgba(var(--primary-rgb, 5,150,105), 0.06);
    color: var(--primary-dark, #047857);
    font-weight: 700;
    padding: 12px 20px;
    border-radius: 14px;
    border: 2px solid rgba(var(--primary-rgb, 5,150,105), 0.15);
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 0.875rem;
}
.btn-outline-themed:hover {
    background: rgba(var(--primary-rgb, 5,150,105), 0.12);
    border-color: rgba(var(--primary-rgb, 5,150,105), 0.3);
}
.btn-danger-themed {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
    white-space: nowrap;
    font-size: 0.875rem;
}
.btn-danger-themed:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.45);
    transform: translateY(-1px);
}
.btn-warning-themed {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
    white-space: nowrap;
    font-size: 0.875rem;
}
.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
}

/* ═══════════════════════════════════════════
   Data Panel
   ═══════════════════════════════════════════ */
.data-panel {
    background: #fff;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.02);
    overflow: hidden;
}
.data-panel-head {
    padding: 20px 24px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
}
.data-panel-head .panel-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary-light, #d1fae5), var(--primary-lighter, #ecfdf5));
    color: var(--primary, #059669);
}
.data-panel-head h2 {
    font-size: 0.95rem; font-weight: 800; color: #1e293b;
}
.data-panel-head .count-badge {
    background: var(--primary-lighter, #ecfdf5);
    color: var(--primary-dark, #047857);
    padding: 4px 14px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 800;
    border: 1px solid rgba(var(--primary-rgb, 5,150,105), 0.1);
}

/* ═══════════════════════════════════════════
   Premium Table
   ═══════════════════════════════════════════ */
.premium-table {
    width: 100%;
    text-align: right;
    border-collapse: separate;
    border-spacing: 0;
}
html[dir="ltr"] .premium-table { text-align: left; }
.premium-table thead th {
    padding: 14px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #fafbfc;
    border-bottom: 1px solid #f1f5f9;
}
.premium-table tbody tr {
    transition: all 0.15s ease;
}
.premium-table tbody tr:hover {
    background: rgba(var(--primary-rgb, 5,150,105), 0.03);
}
.premium-table tbody td {
    padding: 14px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid #f8fafc;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════
   Action Buttons in Table
   ═══════════════════════════════════════════ */
.action-btn {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: #94a3b8;
}
.action-btn:hover {
    background: rgba(var(--primary-rgb, 5,150,105), 0.08);
    color: var(--primary, #059669);
}
.action-btn.danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* ═══════════════════════════════════════════
   Status & Alert Badges
   ═══════════════════════════════════════════ */
.status-badge {
    padding: 4px 14px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.status-active, .status-success, .status-completed, .status-paid { 
    background: rgba(var(--primary-rgb, 5,150,105), 0.08); 
    color: var(--primary, #059669); 
}
.status-inactive, .status-draft { background: #f3f4f6; color: #6b7280; }
.status-pending, .status-waiting { background: #fef3c7; color: #d97706; }
.status-danger, .status-cancelled, .status-overdue { background: #fef2f2; color: #dc2626; }
.status-info, .status-in-progress { background: #eff6ff; color: #3b82f6; }

.alert-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
}
.alert-allergy { background: #fef2f2; color: #dc2626; }
.alert-chronic { background: #fef3c7; color: #d97706; }
.alert-debt { background: #fee2e2; color: #b91c1c; }

/* ═══════════════════════════════════════════
   Tabs
   ═══════════════════════════════════════════ */
.tab-btn {
    border-bottom: 2px solid transparent;
    padding: 12px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    transition: all 0.2s;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab-btn.active {
    border-bottom-color: var(--primary, #059669);
    color: var(--primary, #059669);
    background: rgba(var(--primary-rgb, 5,150,105), 0.06);
    border-radius: 8px 8px 0 0;
}
.tab-btn:hover:not(.active) {
    color: #64748b;
}

/* ═══════════════════════════════════════════
   Modal Design
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    z-index: 1000;
    overflow-y: auto;
}
.modal-overlay.hidden {
    display: none !important;
}
.modal-header {
    background: var(--primary-gradient, linear-gradient(135deg, #059669, #047857));
    padding: 24px 28px;
    border-radius: 20px 20px 0 0;
}
.modal-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus {
    border-color: var(--primary, #059669) !important;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 5,150,105), 0.1) !important;
}

/* Confirm/Delete Modal with red header */
.modal-header.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.modal-header.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}
.modal-header.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* ═══════════════════════════════════════════
   Pagination
   ═══════════════════════════════════════════ */
.pagination-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid #e2e8f0;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    color: #64748b;
}
.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary, #059669);
    color: var(--primary, #059669);
    background: rgba(var(--primary-rgb, 5,150,105), 0.04);
}
.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ═══════════════════════════════════════════
   Toast Notification
   ═══════════════════════════════════════════ */
#notification-toast { 
    transition: all 0.5s ease-in-out; 
    transform: translateX(110%); 
    z-index: 60;
}
html[dir="rtl"] #notification-toast { transform: translateX(-110%); }
#notification-toast.show { transform: translateX(0); }

/* ═══════════════════════════════════════════
   Empty & Loading States
   ═══════════════════════════════════════════ */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px;
    color: #94a3b8;
}
.empty-state-icon {
    width: 80px; height: 80px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 5,150,105), 0.08), rgba(var(--primary-rgb, 5,150,105), 0.03));
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.empty-state-icon i { width: 36px; height: 36px; color: var(--primary-light, #d1fae5); }

.loader-sm {
    border: 2px solid #f3f3f3; 
    border-top: 2px solid var(--primary, #059669); 
    border-radius: 50%; 
    width: 16px; height: 16px; 
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════ */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-up {
    opacity: 0;
    animation: fadeSlideUp 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* ═══════════════════════════════════════════
   Scrollbar
   ═══════════════════════════════════════════ */
.custom-scroll::-webkit-scrollbar { width: 5px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ═══════════════════════════════════════════
   Form Labels & Inputs (Premium)
   ═══════════════════════════════════════════ */
.premium-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}
.premium-label i {
    width: 14px; height: 14px;
    display: inline-block;
    margin-left: 4px;
    color: var(--primary, #059669);
}
html[dir="ltr"] .premium-label i {
    margin-left: 0;
    margin-right: 4px;
}
.premium-input {
    width: 100%;
    padding: 12px 16px;
    background: #f9fafb;
    border: 2px solid #f3f4f6;
    border-radius: 12px;
    font-size: 0.875rem;
    transition: all 0.2s;
    outline: none;
}
.premium-input:focus {
    border-color: var(--primary, #059669);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 5,150,105), 0.1);
    background: #fff;
}

/* ═══════════════════════════════════════════
   Backward Compatibility
   ═══════════════════════════════════════════ */
.icon-btn { background: none; border: none; cursor: pointer; padding: 4px; color: #6b7280; border-radius: 99px; }
.icon-btn:hover { color: var(--primary, #059669); background-color: rgba(var(--primary-rgb, 5,150,105), 0.08); }
.clinic-bg { background-color: var(--primary, #059669); }
.clinic-text { color: var(--primary, #059669); }
.form-radio:checked { accent-color: var(--primary, #059669); }

/* ═══════════════════════════════════════════
   Avatar
   ═══════════════════════════════════════════ */
.avatar-circle {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.avatar-circle.male, .avatar-circle.blue {
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(99,102,241,0.1));
    color: #3b82f6;
}
.avatar-circle.female, .avatar-circle.pink {
    background: linear-gradient(135deg, rgba(236,72,153,0.1), rgba(168,85,247,0.1));
    color: #ec4899;
}
.avatar-circle.green {
    background: linear-gradient(135deg, rgba(var(--primary-rgb, 5,150,105),0.1), rgba(var(--primary-rgb, 5,150,105),0.05));
    color: var(--primary, #059669);
}

/* ═══════════════════════════════════════════
   Info Cards (key-value pairs)
   ═══════════════════════════════════════════ */
.info-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f8fafc;
}
.info-row:last-child { border-bottom: none; }
.info-row .info-label {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
}
.info-row .info-value {
    font-size: 0.875rem;
    color: #1e293b;
    font-weight: 700;
}

/* ═══════════════════════════════════════════
   Print
   ═══════════════════════════════════════════ */
@media print {
    .no-print { display: none !important; }
    .page-hero { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
