/*
    CliniCore Premium Design System
    Role: Global production stylesheet for desktop SaaS layout and mobile app-like UI.
    Palette: Deep Navy #0A192F, clean white surfaces, vibrant amber accent.
*/
:root {
    --navy: #0A192F;
    --navy-2: #112240;
    --amber: #F59E0B;
    --amber-soft: #FFF7E6;
    --white: #FFFFFF;
    --page: #F6F8FC;
    --text-strong: #0A192F;
    --text: #1E293B;
    --muted: #64748B;
    --line: #E2E8F0;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --radius-xl: 30px;
    --radius-lg: 22px;
    --shadow-soft: 0 24px 80px rgba(10, 25, 47, .10);
    --shadow-card: 0 16px 45px rgba(10, 25, 47, .08);
}

/* Base reset and typography hierarchy. */
* { box-sizing: border-box; }
html { font-size: var(--fs-body, 15px); }
body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: var(--clinic-font, Inter), Roboto, Cairo, system-ui, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 20% -8%, rgba(245, 158, 11, .16), transparent 30%),
        radial-gradient(circle at 88% 8%, rgba(10, 25, 47, .10), transparent 28%),
        var(--page);
}
h1, h2, h3, h4, h5, h6 { color: var(--text-strong); font-weight: 900; letter-spacing: -.025em; }
h1 { font-size: clamp(1.7rem, 2.6vw, 2.45rem); }
a { color: inherit; text-decoration: none; }
code, pre { direction: ltr; text-align: left; }

/* Desktop application shell: fixed smart sidebar plus sticky topbar. */
.app-shell { display: flex; }
.app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    z-index: 1045;
    width: 280px;
    padding: 24px 16px;
    overflow-y: auto;
    color: #DDE8FF;
    background: var(--navy);
    border-left: 1px solid rgba(255, 255, 255, .08);
    border-radius: 0;
    box-shadow: -10px 0 30px rgba(10, 25, 47, .04);
}
html[dir="ltr"] .app-sidebar { right: auto; left: 0; border-left: 0; border-right: 1px solid rgba(255, 255, 255, .08); }
.app-main { width: calc(100% - 280px); min-height: 100vh; margin-right: 280px; }
html[dir="ltr"] .app-main { margin-right: 0; margin-left: 280px; }

/* Brand panel inside sidebar. */
.brand-card { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 10px 18px; }
.brand-logo { width: 58px; height: 58px; object-fit: contain; padding: 8px; border-radius: 20px; background: var(--white); }
.brand-text strong { display: block; color: var(--white); font-size: 1.05rem; font-weight: 900; }
.brand-text span { display: block; margin-top: 4px; color: #9FB2D8; font-size: .82rem; font-weight: 700; }
.sidebar-close { display: none; margin-inline-start: auto; width: 44px; height: 44px; border: 0; border-radius: 16px; color: var(--white); background: rgba(255,255,255,.10); }

/* Sidebar navigation links. */
.main-nav { height: calc(100vh - 248px); min-height: 330px; overflow-y: auto; padding: 6px 2px 12px; scrollbar-width: thin; }
.main-nav a { display: flex; align-items: center; gap: 12px; min-height: 48px; margin: 6px 0; padding: 12px 14px; border-radius: 18px; color: #B8C7E6; font-weight: 850; transition: .2s ease; }
.main-nav a i { display: grid; place-items: center; width: 28px; height: 28px; font-size: 1.1rem; }
.main-nav a:hover, .main-nav a.active { color: var(--white); background: rgba(245, 158, 11, .15); box-shadow: inset 3px 0 0 var(--amber); }
html[dir="rtl"] .main-nav a:hover, html[dir="rtl"] .main-nav a.active { box-shadow: inset -3px 0 0 var(--amber); }
.sidebar-promo { margin-top: 12px; padding: 16px; border-radius: 24px; color: var(--white); background: rgba(255,255,255,.08); }
.sidebar-promo .promo-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 10px; border-radius: 18px; color: var(--navy); background: var(--amber); font-size: 24px; }
.sidebar-promo p { margin: 6px 0 0; color: #B8C7E6; line-height: 1.7; font-size: .84rem; }

/* Sticky top navigation with search and account actions. */
.app-topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: 16px; height: 86px; padding: 0 28px; background: rgba(255,255,255,.82); border-bottom: 1px solid rgba(226,232,240,.85); backdrop-filter: blur(22px); }
.topbar-user, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.user-avatar, .notify-btn, .mobile-menu { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 18px; }
.user-avatar { color: var(--navy); background: var(--amber-soft); font-size: 22px; }
.user-chip strong, .user-chip small { display: block; }
.user-chip small { color: var(--muted); font-weight: 700; }
.notify-btn, .mobile-menu { border: 1px solid var(--line); color: var(--navy); background: var(--white); font-size: 21px; }
.notify-btn { position: relative; }
.notify-btn span { position: absolute; top: -5px; right: -5px; min-width: 22px; height: 22px; display: grid; place-items: center; border-radius: 99px; color: var(--navy); background: var(--amber); font-size: 11px; font-weight: 900; }
.global-search { position: relative; flex: 1; max-width: 520px; margin-inline-start: auto; }
.global-search input { width: 100%; height: 50px; border: 1px solid var(--line); border-radius: 18px; padding: 0 48px 0 18px; outline: 0; background: #F8FAFC; font-weight: 750; }
html[dir="ltr"] .global-search input { padding: 0 18px 0 48px; }
.global-search i { position: absolute; top: 50%; right: 17px; transform: translateY(-50%); color: var(--muted); }
html[dir="ltr"] .global-search i { right: auto; left: 17px; }
.clinic-switcher { display: flex; align-items: center; gap: 10px; min-width: 230px; height: 50px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); }
.clinic-switcher .form-select { border: 0; box-shadow: none; background-color: transparent; font-weight: 850; }
.mobile-menu { display: none; }
.logout-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border: 1px solid rgba(239,68,68,.28); border-radius: 16px; color: var(--danger); background: var(--white); font-weight: 900; }
.content-wrap { width: min(100%, 1580px); margin: 0 auto; padding: 32px 30px 52px; }

/* Page headers, hero search blocks, and dashboard cards. */
.page-head, .page-head-pro, .hero-section { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head p, .page-head-pro p, .hero-section p { margin: 8px 0 0; color: var(--muted); font-weight: 700; }
.hero-section { padding: 28px; border-radius: 34px; color: var(--white); background: linear-gradient(135deg, var(--navy), #102A4C); box-shadow: var(--shadow-soft); }
.hero-section h1, .hero-section p { color: var(--white); }
.smart-filter-bar { display: flex; align-items: center; gap: 12px; min-width: min(620px, 100%); padding: 10px; border-radius: 24px; background: rgba(255,255,255,.10); }
.smart-filter-bar .form-control, .smart-filter-bar .form-select { background: var(--white); border: 0; }
.panel, .card-pro, .soft-table, .kpi-card, .card-soft { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-xl); background: rgba(255,255,255,.94); box-shadow: var(--shadow-card); }
.panel, .card-pro, .kpi-card, .card-soft { padding: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.stat-card { position: relative; overflow: hidden; min-height: 150px; padding: 22px; border: 1px solid var(--line); border-radius: 28px; background: var(--white); box-shadow: var(--shadow-card); }
.stat-card::after { content: ""; position: absolute; top: -44px; inset-inline-end: -42px; width: 135px; height: 135px; border-radius: 50%; background: rgba(245,158,11,.14); }
.stat-card .icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px; color: var(--navy); background: var(--amber-soft); font-size: 22px; }
.stat-card .num { margin-top: 14px; color: var(--navy); font-size: 2rem; font-weight: 950; }
.stat-card .label { color: var(--muted); font-weight: 850; }

/* Forms, buttons, and toolbars. */
.toolbar-pro { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.searchbox { position: relative; flex: 1; max-width: 560px; }
.searchbox i { position: absolute; top: 50%; right: 16px; transform: translateY(-50%); color: var(--muted); }
html[dir="ltr"] .searchbox i { right: auto; left: 16px; }
.searchbox .form-control { padding-right: 46px; }
html[dir="ltr"] .searchbox .form-control { padding-right: .92rem; padding-left: 46px; }
.btn { min-height: 44px; border-radius: 16px; font-weight: 900; padding: .68rem 1rem; }
.btn-primary { border: 0; color: var(--navy); background: linear-gradient(135deg, var(--amber), #FBBF24); box-shadow: 0 14px 32px rgba(245,158,11,.28); }
.btn-light { color: var(--navy); border: 1px solid var(--line); background: var(--white); }
.btn-outline-secondary { border-color: var(--line); color: var(--muted); }
.form-label, label { margin-bottom: .45rem; color: var(--navy); font-weight: 850; }
.form-control, .form-select { min-height: 46px; border-color: var(--line); border-radius: 16px; background-color: #F8FAFC; color: var(--navy); padding: .76rem .92rem; }
.form-control:focus, .form-select:focus { border-color: var(--amber); background: var(--white); box-shadow: 0 0 0 .22rem rgba(245,158,11,.18); }
.form-check-input:checked { background-color: var(--amber); border-color: var(--amber); }

/* Tables and responsive record cards. */
.table { margin: 0; color: #334155; vertical-align: middle; }
.table thead th, .table tr:first-child th { padding: 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .84rem; font-weight: 950; background: #F8FAFC; }
.table > :not(caption) > * > * { padding: 15px 16px; border-color: #EEF2F7; }
.badge-soft, .status-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: .45rem .72rem; font-size: .82rem; font-weight: 900; }
.badge-soft { color: var(--navy); background: var(--amber-soft); }
.status-pill { color: var(--success); background: #ECFDF5; }
.status-pill.danger, .status-pill.inactive, .status-pill.failed { color: var(--danger); background: #FEF2F2; }
.status-pill.warning, .status-pill.pending { color: var(--warning); background: #FFFBEB; }
.mobile-cards, .mobile-card-list, .mobile-finance-cards { display: none; }
.mobile-record-card { padding: 17px; border: 1px solid var(--line); border-radius: 24px; background: var(--white); box-shadow: var(--shadow-card); }
.mobile-record-card .meta { margin-top: 5px; color: var(--muted); font-weight: 750; }

/* Doctor, module, automation, and feature cards. */
.doctor-card, .module-card, .automation-rule, .feature-card, .testimonial-card { position: relative; overflow: hidden; height: 100%; padding: 22px; border: 1px solid var(--line); border-radius: 28px; background: var(--white); box-shadow: var(--shadow-card); }
.doctor-card::before, .feature-card::before { content: ""; position: absolute; inset-inline-end: -34px; inset-block-start: -36px; width: 120px; height: 120px; border-radius: 50%; background: rgba(245,158,11,.16); }
.doctor-photo, .feature-icon, .module-card > i { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 16px; border-radius: 24px; color: var(--navy); background: var(--amber-soft); font-size: 34px; }
.doctor-photo { width: 92px; height: 92px; margin: 0 auto 16px; font-size: 42px; }
.doctor-card h5, .doctor-card p, .doctor-card small { display: block; text-align: center; }
.doctor-card p, .doctor-card small { color: var(--muted); font-weight: 750; }
.doctor-footer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid #EEF2F7; }
.doctor-footer span { text-align: center; color: var(--muted); font-size: .82rem; font-weight: 800; }
.doctor-footer b { display: block; color: var(--navy); }
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

/* Modal layer: desktop centered, mobile bottom sheet/drawer. */
.modal { z-index: 2200; }
.modal-backdrop { z-index: 2190; }
.modal-content { border: 0; border-radius: 30px; box-shadow: 0 35px 120px rgba(10,25,47,.26); }
.modal-header, .modal-footer { padding: 20px 24px; border-color: #EEF2F7; }
.modal-body { padding: 24px; }
.modal-header .btn-close { margin: 0; }
.swal2-container { z-index: 3500 !important; }
.dropdown-menu, .ts-dropdown, .flatpickr-calendar { z-index: 3000 !important; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 1040; background: rgba(10,25,47,.48); backdrop-filter: blur(4px); }

/* Mobile bottom tab bar. */
.mobile-tabbar { display: none; }

/* Login pages. */
.login-page, .portal-bg { display: grid; place-items: center; min-height: 100vh; padding: 18px; background: linear-gradient(135deg, #F8FAFC, #FFFFFF 45%, #FFF7E6); }
.login-card, .portal-card { width: min(450px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 34px; background: rgba(255,255,255,.94); box-shadow: var(--shadow-soft); }

/* Tablet layout adjustments. */
@media (max-width: 1180px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

/* Mobile native-app experience: drawer sidebar, bottom tabs, edge-to-edge cards, touch targets. */
@media (max-width: 991px) {
    body { background: var(--page); }
    .app-sidebar, html[dir="ltr"] .app-sidebar { top: 0; bottom: 0; right: 0; left: auto; width: min(88vw, 380px); height: 100vh; border-radius: 0 0 0 34px; transform: translateX(110%); transition: transform .25s ease; }
    html[dir="ltr"] .app-sidebar { right: auto; left: 0; transform: translateX(-110%); border-radius: 0 0 34px 0; }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .sidebar-close, .mobile-menu { display: grid; }
    .app-main, html[dir="ltr"] .app-main { width: 100%; margin: 0; }
    .app-topbar { height: 72px; padding: 0 13px; }
    .clinic-switcher, .notify-btn, .logout-btn, .global-search { display: none !important; }
    .topbar-user { flex: 1; min-width: 0; }
    .user-chip { min-width: 0; }
    .user-chip strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .content-wrap { width: 100%; padding: 16px 12px 106px; }
    .page-head, .page-head-pro, .hero-section, .toolbar-pro { align-items: stretch; flex-direction: column; }
    .hero-section { margin-inline: -4px; border-radius: 28px; }
    .smart-filter-bar { flex-direction: column; align-items: stretch; }
    .panel, .card-pro, .soft-table, .kpi-card, .card-soft { border-radius: 24px; }
    .panel, .card-pro, .kpi-card, .card-soft { padding: 18px; }
    .desktop-table, .soft-table.desktop-table, .table-only-desktop { display: none !important; }
    .mobile-cards, .mobile-card-list, .mobile-finance-cards { display: grid !important; gap: 13px; }
    .stats-grid { grid-template-columns: 1fr; }
    .searchbox { max-width: none; }
    .btn, .form-control, .form-select { min-height: 48px; }
    .modal-dialog { display: flex; align-items: flex-end; min-height: 100%; margin: 0; }
    .modal.fade .modal-dialog { transform: translateY(100%); }
    .modal.show .modal-dialog { transform: translateY(0); }
    .modal-content { width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 28px 28px 0 0; }
    .mobile-tabbar { position: fixed; right: 12px; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 1060; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px; border: 1px solid rgba(226,232,240,.9); border-radius: 26px; background: rgba(255,255,255,.92); box-shadow: 0 18px 55px rgba(10,25,47,.18); backdrop-filter: blur(18px); }
    .mobile-tabbar a, .mobile-tabbar button { display: grid; place-items: center; gap: 3px; min-height: 54px; border: 0; border-radius: 18px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 900; }
    .mobile-tabbar i { font-size: 20px; }
    .mobile-tabbar a.active { color: var(--navy); background: var(--amber-soft); }
}

/* Small mobile refinements. */
@media (max-width: 560px) {
    .content-wrap { padding-inline: 10px; }
    .brand-logo { width: 54px; height: 54px; }
    .mobile-record-card, .doctor-card, .module-card, .automation-rule { border-radius: 22px; }
}

/* Compact dashboard data blocks and testimonial slider cards. */
.mini-stat { padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: #F8FAFC; }
.mini-stat span { display: block; margin-bottom: 6px; color: var(--muted); font-weight: 850; }
.mini-stat b { color: var(--navy); font-size: 1.15rem; }
.testimonial-slider { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(280px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.testimonial-card { scroll-snap-align: start; min-height: 170px; }
.app-footer { margin-top: 30px; padding: 22px; border: 1px solid var(--line); border-radius: 28px; background: var(--white); color: var(--muted); box-shadow: var(--shadow-card); }
.app-footer strong { color: var(--navy); }
@media (max-width: 991px) { .testimonial-slider { grid-auto-columns: 86%; margin-inline: -2px; } .app-footer { margin-bottom: 8px; } }
