/* ═══════════════════════════════════════════════════════════════
   Admin Panel Theme — مركز القدس للبيطرة
   Professional Veterinary Management System
   Version 2.0 — Cairo Font + Navy/Gold Design System
   ═══════════════════════════════════════════════════════════════ */

/* ─── Google Fonts: Cairo ─── */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Inter:wght@400;500;600&display=swap');

/* ═══ 1. CSS Variables ═══ */
:root {
    /* Brand Palette */
    --bq-navy:        #0D2137;
    --bq-navy-mid:    #0A2D4A;
    --bq-navy-light:  #164E74;
    --bq-sky:         #0EA5E9;
    --bq-sky-dark:    #0284C7;
    --bq-emerald:     #059669;
    --bq-gold:        #D4AF37;
    --bq-gold-light:  #F0CC5A;

    /* Sidebar */
    --sidebar-bg-top:    #0D2137;
    --sidebar-bg-bottom: #0A2D4A;
    --sidebar-border:    rgba(212, 175, 55, 0.12);
    --sidebar-text:      #94A3B8;
    --sidebar-text-hover:#E2E8F0;
    --sidebar-active-bg: rgba(14, 165, 233, 0.12);
    --sidebar-active-text:#38BDF8;
    --sidebar-group-text: rgba(212, 175, 55, 0.6);

    /* Surface */
    --surface-bg:    #F1F5F9;
    --surface-card:  #FFFFFF;
    --surface-border:#E2E8F0;

    /* Typography */
    --font-arabic: 'Cairo', 'Segoe UI', system-ui, sans-serif;
    --font-latin:  'Inter', system-ui, sans-serif;
}

/* ═══ 2. Global Font & Direction ═══ */
body,
[class*="fi-"],
.fi-sidebar,
.fi-topbar,
.fi-main,
.fi-header,
.fi-section,
.fi-modal,
.fi-dropdown {
    font-family: var(--font-arabic) !important;
    direction: rtl;
}

/* Numbers & LTR values stay LTR */
.fi-ta-cell [dir="ltr"],
input[type="number"],
input[type="tel"],
.ltr { direction: ltr; font-family: var(--font-latin) !important; }

/* ═══ 3. Sidebar ═══ */
.fi-sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg-top) 0%, var(--sidebar-bg-bottom) 100%) !important;
    border-left: 1px solid var(--sidebar-border) !important;
    border-right: none !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25) !important;
}

/* Sidebar header */
.fi-sidebar-header {
    background: transparent !important;
    border-bottom: 1px solid var(--sidebar-border) !important;
    padding: 1.25rem 1rem !important;
}

/* Gold accent line below logo */
.fi-sidebar-header::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--bq-gold), transparent);
    margin-top: 0.75rem;
    opacity: 0.4;
}

/* Navigation group labels */
.fi-sidebar-group-label {
    color: rgba(212, 175, 55, 0.85) !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    padding: 1rem 0.75rem 0.35rem !important;
}

/* Nav item buttons */
.fi-sidebar-item-button {
    border-radius: 8px !important;
    margin: 1px 0.5rem !important;
    padding: 0.55rem 0.9rem !important;
    color: var(--sidebar-text) !important;
    transition: all 0.18s ease !important;
    font-weight: 500 !important;
    font-size: 0.88rem !important;
}

.fi-sidebar-item-button:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: var(--sidebar-text-hover) !important;
}

/* Active nav item */
.fi-sidebar-item-button.fi-active,
.fi-sidebar-item-button[aria-current="page"] {
    background: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    box-shadow: inset 3px 0 0 var(--bq-sky) !important;
    font-weight: 700 !important;
}

[dir="rtl"] .fi-sidebar-item-button.fi-active,
[dir="rtl"] .fi-sidebar-item-button[aria-current="page"] {
    box-shadow: inset -3px 0 0 var(--bq-sky) !important;
}

/* Nav icons */
.fi-sidebar-item-icon {
    color: var(--sidebar-text) !important;
    opacity: 0.7;
    transition: all 0.18s ease !important;
}

.fi-sidebar-item-button:hover .fi-sidebar-item-icon,
.fi-sidebar-item-button.fi-active .fi-sidebar-item-icon {
    color: var(--bq-sky) !important;
    opacity: 1;
}

/* Collapse button */
.fi-sidebar-close-overlay-btn,
.fi-sidebar-collapse-btn {
    color: var(--sidebar-text) !important;
}

/* ═══ 4. Topbar ═══ */
.fi-topbar {
    background: #FFFFFF !important;
    border-bottom: 1px solid var(--surface-border) !important;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06) !important;
}

/* Search bar */
.fi-global-search-field input {
    background: var(--surface-bg) !important;
    border-radius: 8px !important;
    border: 1px solid var(--surface-border) !important;
    font-family: var(--font-arabic) !important;
    font-size: 0.875rem !important;
}

.fi-global-search-field input:focus {
    border-color: var(--bq-sky) !important;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15) !important;
}

/* User menu button */
.fi-user-menu-button {
    border-radius: 8px !important;
    transition: background 0.15s !important;
}

/* ═══ 5. Page Header ═══ */
.fi-header {
    padding-bottom: 1rem !important;
}

.fi-header-heading {
    font-family: var(--font-arabic) !important;
    font-weight: 800 !important;
    font-size: 1.45rem !important;
    color: var(--bq-navy) !important;
    line-height: 1.3 !important;
}

.fi-header-subheading {
    color: #64748B !important;
    font-size: 0.875rem !important;
    margin-top: 0.2rem !important;
}

/* Breadcrumbs */
.fi-breadcrumbs {
    font-size: 0.8rem !important;
    color: #94A3B8 !important;
}

/* ═══ 6. Stats Overview Widget ═══ */
.fi-wi-stats-overview {
    gap: 1rem !important;
}

.fi-wi-stats-overview-stat {
    border-radius: 14px !important;
    border: 1px solid var(--surface-border) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    background: #FFFFFF !important;
    padding: 1.25rem 1.5rem !important;
    transition: box-shadow 0.2s, transform 0.2s !important;
    overflow: hidden;
    position: relative;
}

.fi-wi-stats-overview-stat::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 4px;
    height: 100%;
    background: var(--bq-sky);
    opacity: 0.7;
}

.fi-wi-stats-overview-stat:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10) !important;
    transform: translateY(-2px) !important;
}

.fi-wi-stats-overview-stat-label {
    font-size: 0.78rem !important;
    font-weight: 600 !important;
    color: #64748B !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
}

.fi-wi-stats-overview-stat-value {
    font-size: 2rem !important;
    font-weight: 800 !important;
    color: var(--bq-navy) !important;
    line-height: 1.2 !important;
    margin: 0.3rem 0 !important;
    font-family: var(--font-arabic) !important;
}

.fi-wi-stats-overview-stat-description {
    font-size: 0.78rem !important;
    color: #94A3B8 !important;
}

/* ═══ 7. Cards / Sections ═══ */
.fi-section {
    border-radius: 12px !important;
    border: 1px solid var(--surface-border) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) !important;
    background: #FFFFFF !important;
}

.fi-section-header {
    border-bottom: 1px solid var(--surface-border) !important;
    padding: 1rem 1.25rem !important;
}

.fi-section-header-heading {
    font-weight: 700 !important;
    font-size: 0.95rem !important;
    color: var(--bq-navy) !important;
}

.fi-section-content {
    padding: 1.25rem !important;
}

/* ═══ 8. Tables ═══ */
.fi-ta-header {
    border-bottom: 2px solid var(--surface-border) !important;
}

.fi-ta-header-cell {
    background: #F8FAFC !important;
    color: #475569 !important;
    font-weight: 700 !important;
    font-size: 0.78rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    padding: 0.75rem 1rem !important;
    font-family: var(--font-arabic) !important;
}

.fi-ta-row {
    transition: background 0.12s !important;
}

.fi-ta-row:hover .fi-ta-cell {
    background: #F0F9FF !important;
}

.fi-ta-cell {
    padding: 0.75rem 1rem !important;
    color: #334155 !important;
    font-size: 0.875rem !important;
    border-bottom: 1px solid #F1F5F9 !important;
}

/* Empty state */
.fi-ta-empty-state {
    padding: 3rem 1rem !important;
    color: #94A3B8 !important;
}

.fi-ta-empty-state-icon {
    color: #CBD5E1 !important;
    width: 3rem !important;
    height: 3rem !important;
}

/* ═══ 9. Buttons ═══ */
/* Primary */
.fi-btn-color-primary {
    background: linear-gradient(135deg, var(--bq-navy-mid), var(--bq-navy-light)) !important;
    border-color: transparent !important;
    color: #FFFFFF !important;
    font-weight: 700 !important;
    font-family: var(--font-arabic) !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(10, 45, 74, 0.25) !important;
    transition: all 0.18s ease !important;
}

.fi-btn-color-primary:hover {
    background: linear-gradient(135deg, var(--bq-navy-light), var(--bq-sky-dark)) !important;
    box-shadow: 0 4px 12px rgba(10, 45, 74, 0.35) !important;
    transform: translateY(-1px) !important;
}

/* Success */
.fi-btn-color-success {
    background: linear-gradient(135deg, var(--bq-emerald), #10B981) !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    font-family: var(--font-arabic) !important;
}

/* Danger */
.fi-btn-color-danger {
    font-weight: 700 !important;
    border-radius: 8px !important;
    font-family: var(--font-arabic) !important;
}

/* Gray / secondary */
.fi-btn-color-gray {
    font-weight: 600 !important;
    border-radius: 8px !important;
    font-family: var(--font-arabic) !important;
}

/* All buttons */
.fi-btn {
    font-family: var(--font-arabic) !important;
    transition: all 0.18s ease !important;
}

/* ═══ 10. Form Inputs ═══ */
.fi-input,
.fi-select-input,
.fi-textarea {
    font-family: var(--font-arabic) !important;
    border-radius: 8px !important;
    border-color: var(--surface-border) !important;
    font-size: 0.9rem !important;
    transition: border-color 0.15s, box-shadow 0.15s !important;
}

.fi-input:focus,
.fi-select-input:focus,
.fi-textarea:focus {
    border-color: var(--bq-sky) !important;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15) !important;
    outline: none !important;
}

.fi-fo-field-wrp-label label {
    font-family: var(--font-arabic) !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    color: #374151 !important;
}

.fi-fo-helper-text {
    font-family: var(--font-arabic) !important;
    font-size: 0.78rem !important;
    color: #94A3B8 !important;
}

/* ═══ 11. Badges ═══ */
.fi-badge {
    font-family: var(--font-arabic) !important;
    font-weight: 700 !important;
    font-size: 0.72rem !important;
    border-radius: 6px !important;
    padding: 0.2rem 0.6rem !important;
}

/* ═══ 12. Modals ═══ */
.fi-modal-window {
    border-radius: 16px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2) !important;
}

.fi-modal-header {
    border-bottom: 1px solid var(--surface-border) !important;
    padding: 1.25rem 1.5rem !important;
}

.fi-modal-heading {
    font-weight: 800 !important;
    font-size: 1.05rem !important;
    color: var(--bq-navy) !important;
    font-family: var(--font-arabic) !important;
}

.fi-modal-footer {
    border-top: 1px solid var(--surface-border) !important;
    padding: 1rem 1.5rem !important;
    background: #F8FAFC !important;
}

/* ═══ 13. Notifications ═══ */
.fi-notifications {
    font-family: var(--font-arabic) !important;
}

.fi-notification {
    border-radius: 12px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid var(--surface-border) !important;
}

.fi-notification-title {
    font-weight: 700 !important;
    font-family: var(--font-arabic) !important;
}

/* ═══ 14. Tabs ═══ */
.fi-tabs-tab {
    font-family: var(--font-arabic) !important;
    font-weight: 600 !important;
    font-size: 0.875rem !important;
    border-radius: 8px 8px 0 0 !important;
    transition: all 0.15s !important;
}

.fi-tabs-tab[aria-selected="true"] {
    color: var(--bq-sky) !important;
    border-bottom-color: var(--bq-sky) !important;
    font-weight: 700 !important;
}

/* ═══ 15. Dropdowns ═══ */
.fi-dropdown-panel {
    border-radius: 12px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid var(--surface-border) !important;
    font-family: var(--font-arabic) !important;
}

.fi-dropdown-list-item-label {
    font-family: var(--font-arabic) !important;
    font-size: 0.875rem !important;
}

/* ═══ 16. Pagination ═══ */
.fi-pagination {
    font-family: var(--font-arabic) !important;
}

.fi-pagination-item button {
    border-radius: 6px !important;
    font-weight: 600 !important;
    transition: all 0.15s !important;
}

.fi-pagination-item-is-active button {
    background: var(--bq-navy-mid) !important;
    color: white !important;
}

/* ═══ 17. Filters / Actions Bar ═══ */
.fi-ta-filters-form,
.fi-ta-actions {
    font-family: var(--font-arabic) !important;
}

/* ═══ 18. Dashboard Page ═══ */
.fi-page {
    background: var(--surface-bg) !important;
}

.fi-simple-page {
    background: var(--surface-bg) !important;
}

/* ═══ 19. Back Button ═══ */
#fi-back-btn {
    border: 1px solid #E2E8F0 !important;
    border-radius: 8px !important;
    background: white !important;
    color: #475569 !important;
    font-family: var(--font-arabic) !important;
    font-weight: 600 !important;
    font-size: 0.82rem !important;
    padding: 0.4rem 0.9rem !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06) !important;
}

#fi-back-btn:hover {
    background: #F8FAFC !important;
    border-color: #CBD5E1 !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
}

/* ═══ 20. Dark Mode Overrides ═══
   IMPORTANT: use html.dark to target only when <html> has class "dark".
   Plain ".dark .x" has same specificity as ":not(.dark) .x" which causes
   the light-mode rule to win (last in file). html.dark is more specific.
   ══════════════════════════════════════════════════════════════════════ */
html.dark .fi-page,
html.dark .fi-simple-page { background: #0F172A !important; }
html.dark .fi-header-heading { color: #E2E8F0 !important; }
html.dark .fi-section { background: #1E293B !important; border-color: #334155 !important; }
html.dark .fi-section-header { border-color: #334155 !important; }
html.dark .fi-section-header-heading { color: #E2E8F0 !important; }
html.dark .fi-ta-header-cell { background: #1E293B !important; color: #94A3B8 !important; }
html.dark .fi-ta-cell { color: #CBD5E1 !important; border-bottom-color: #1E293B !important; }
html.dark .fi-ta-row:hover .fi-ta-cell { background: rgba(14, 165, 233, 0.05) !important; }
html.dark .fi-modal-window { background: #1E293B !important; }
html.dark .fi-modal-footer { background: #0F172A !important; }
html.dark .fi-topbar { background: #0F172A !important; border-bottom-color: #1E293B !important; }
html.dark .fi-wi-stats-overview-stat { background: #1E293B !important; border-color: #334155 !important; }
html.dark .fi-wi-stats-overview-stat-value { color: #E2E8F0 !important; }
html.dark #fi-back-btn { background: #1E293B !important; border-color: #334155 !important; color: #CBD5E1 !important; }

/* ═══ 21. Light Mode Explicit Overrides ═══
   Use html:not(.dark) to ONLY target when <html> does NOT have class "dark".
   ":not(.dark) .x" wrongly matches body/div ancestors in dark mode too.
   ══════════════════════════════════════════════════════════════════════ */
html:not(.dark) .fi-page,
html:not(.dark) .fi-simple-page { background: #EFF3F8 !important; }

html:not(.dark) .fi-header-heading { color: #0D2137 !important; }
html:not(.dark) .fi-header-subheading { color: #475569 !important; }
html:not(.dark) .fi-section-header-heading { color: #1E3A5F !important; }
html:not(.dark) .fi-wi-stats-overview-stat-value { color: #0D2137 !important; }
html:not(.dark) .fi-wi-stats-overview-stat-label { color: #475569 !important; }

html:not(.dark) .fi-section,
html:not(.dark) .fi-wi-stats-overview-stat {
    background: #FFFFFF !important;
    border-color: #D1DCE8 !important;
    box-shadow: 0 2px 8px rgba(13, 33, 55, 0.07) !important;
}

html:not(.dark) .fi-topbar {
    background: #FFFFFF !important;
    border-bottom: 1px solid #D1DCE8 !important;
    box-shadow: 0 2px 8px rgba(13, 33, 55, 0.06) !important;
}

html:not(.dark) .fi-ta-header-cell { background: #F0F5FA !important; color: #374151 !important; }
html:not(.dark) .fi-ta-cell { color: #1E293B !important; }
html:not(.dark) .fi-ta-row:hover .fi-ta-cell { background: #EBF5FF !important; }

/* ═══ 22. Custom Blade Pages — Dark Mode Table Text ═══
   Tailwind dark: variants in hand-written blade files may not
   be compiled when Filament owns the CSS build pipeline.
   Override plain <table> elements explicitly for dark mode.
   ══════════════════════════════════════════════════════════ */
html.dark table thead tr {
    background: rgba(30, 41, 59, 0.8) !important;
}
html.dark table th {
    color: #94A3B8 !important;
    border-color: #334155 !important;
}
html.dark table td {
    color: #CBD5E1 !important;
    border-color: #1E293B !important;
}
html.dark table tr:hover td {
    background: rgba(14, 165, 233, 0.05) !important;
}
html.dark table tbody {
    color: #CBD5E1 !important;
}
/* Report summary cards */
html.dark .bg-white {
    background-color: #1E293B !important;
}
html.dark .bg-gray-50 {
    background-color: #0F172A !important;
}
html.dark .border-gray-200 {
    border-color: #334155 !important;
}
html.dark .border-gray-100 {
    border-color: #1E293B !important;
}
html.dark .text-gray-800,
html.dark .text-gray-700 {
    color: #E2E8F0 !important;
}
html.dark .text-gray-600,
html.dark .text-gray-500 {
    color: #94A3B8 !important;
}
html.dark .text-gray-400 {
    color: #64748B !important;
}
html.dark .divide-gray-100 > * + * {
    border-color: #1E293B !important;
}

/* ═══ 23. Sidebar Nav — Always Dark (both modes) ═══ */
/* Force all sidebar text to be visible on dark navy background */

html body .fi-sidebar .fi-sidebar-group-label {
    color: rgba(212, 175, 55, 0.9) !important;
    opacity: 1 !important;
}

/* ── Icon sizing fix ──
   Filament renders heroicons inside .fi-sidebar-item-icon (a <span>).
   Without explicit dimensions the SVG collapses to a tiny dot.
   Force 20×20 on both the wrapper AND the SVG inside.                */
html body .fi-sidebar .fi-sidebar-item-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    min-width: 1.25rem !important;
    min-height: 1.25rem !important;
    flex-shrink: 0 !important;
    overflow: visible !important;
    color: #8BAEC8 !important;
    opacity: 1 !important;
}

html body .fi-sidebar .fi-sidebar-item-icon svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
    min-width: 1.25rem !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* ── Group-item connector line ──
   Filament shows a vertical border-line connecting items within a group.
   Tint it to match our dark sidebar palette instead of showing starkly. */
html body .fi-sidebar [class*="group-items"],
html body .fi-sidebar [class*="sidebar-group"] ul {
    border-inline-start-color: rgba(148, 163, 184, 0.15) !important;
    border-inline-end-color: rgba(148, 163, 184, 0.15) !important;
}

/* ── Item text & states ── */
html body .fi-sidebar .fi-sidebar-item-button,
html body .fi-sidebar .fi-sidebar-item-label {
    color: #C8D6E5 !important;
    opacity: 1 !important;
}

html body .fi-sidebar .fi-sidebar-item-button:hover,
html body .fi-sidebar .fi-sidebar-item-button:hover .fi-sidebar-item-label {
    color: #FFFFFF !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

html body .fi-sidebar .fi-sidebar-item-button:hover .fi-sidebar-item-icon,
html body .fi-sidebar .fi-sidebar-item-button:hover .fi-sidebar-item-icon svg {
    color: #38BDF8 !important;
}

html body .fi-sidebar .fi-sidebar-item-button.fi-active,
html body .fi-sidebar .fi-sidebar-item-button[aria-current="page"],
html body .fi-sidebar .fi-sidebar-item-button.fi-active .fi-sidebar-item-label,
html body .fi-sidebar .fi-sidebar-item-button[aria-current="page"] .fi-sidebar-item-label {
    color: #38BDF8 !important;
    background: rgba(14, 165, 233, 0.15) !important;
    font-weight: 700 !important;
}

html body .fi-sidebar .fi-sidebar-item-button.fi-active .fi-sidebar-item-icon,
html body .fi-sidebar .fi-sidebar-item-button[aria-current="page"] .fi-sidebar-item-icon {
    color: #38BDF8 !important;
}
