/* ==============================================================
   Radiant Dental DCMS - FreeDash Theme Integration & Overrides
   ============================================================== */

:root {
    --primary: #5f76e8;
    --primary-hover: #485ec4;
    --primary-light: #eceffd;
    --primary-dark: #3b4ea8;
    --secondary: #6c757d;
    --dark: #1c2d41;
    --slate: #334155;
    --light-bg: #2b3035;
    --card-bg: #ffffff;
    --border-color: #e9ecef;
    --teal: #0d9488;
    --teal-light: #ccfbf1;
    --teal-dark: #0f766e;
    --success: #22ca80;
    --warning: #fdc16a;
    --danger: #ff4f70;
    --info: #01caf1;
}

body {
    font-family: 'Rubik', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--light-bg);
    color: var(--dark);
    margin: 0;
    padding: 0;
}

#main-wrapper,
.page-wrapper {
    background: linear-gradient(180deg, #343a40 0%, #2b3035 100%) !important;
}

/* Keep page-level titles & subtitles directly on the dark background readable */
.page-wrapper > .container-fluid > :not(.card):not(.card-custom):not(.stat-card):not(.dental-chart-container):not(.alert):not(.row):not(.bg-white):not(.bg-light):not(.btn):not(.dropdown-menu):not(.modal) .text-dark,
.page-wrapper > .container-fluid > :not(.card):not(.card-custom):not(.stat-card):not(.dental-chart-container):not(.alert):not(.row):not(.bg-white):not(.bg-light):not(.btn):not(.dropdown-menu):not(.modal).text-dark {
    color: #f8fafc !important;
}

.page-wrapper > .container-fluid > :not(.card):not(.card-custom):not(.stat-card):not(.dental-chart-container):not(.alert):not(.row):not(.bg-white):not(.bg-light):not(.btn):not(.dropdown-menu):not(.modal) .text-muted,
.page-wrapper > .container-fluid > :not(.card):not(.card-custom):not(.stat-card):not(.dental-chart-container):not(.alert):not(.row):not(.bg-white):not(.bg-light):not(.btn):not(.dropdown-menu):not(.modal).text-muted {
    color: #cbd5e1 !important;
}

.page-wrapper > .container-fluid > :not(.card):not(.card-custom):not(.stat-card):not(.dental-chart-container):not(.alert):not(.row):not(.bg-white):not(.bg-light) .btn-light .text-dark,
.page-wrapper > .container-fluid > :not(.card):not(.card-custom):not(.stat-card):not(.dental-chart-container):not(.alert):not(.row):not(.bg-white):not(.bg-light) .bg-white .text-dark {
    color: #1c2d41 !important;
}

.footer {
    background-color: transparent !important;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    color: #cbd5e1 !important;
    padding: 1rem 1.5rem;
}

/* ==============================================================
   FreeDash Sidebar Customizations & Active States
   ============================================================== */
.sidebar-nav #sidebarnav .sidebar-item .sidebar-link {
    color: #4F5467;
    font-size: 14.5px;
    font-weight: 400;
    padding: 10px 20px 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 0 30px 30px 0;
    margin-right: 14px;
    transition: all 0.2s ease;
}

.sidebar-nav #sidebarnav .sidebar-item .sidebar-link:hover {
    color: var(--primary);
    background: #f4f6fa;
}

.sidebar-nav #sidebarnav .sidebar-item .sidebar-link .feather-icon {
    width: 18px;
    height: 18px;
    color: #7c8798;
    transition: color 0.2s ease;
}

.sidebar-nav #sidebarnav .sidebar-item .sidebar-link:hover .feather-icon {
    color: var(--primary);
}

.sidebar-nav #sidebarnav .sidebar-item.selected > .sidebar-link,
.sidebar-nav #sidebarnav .sidebar-item.active > .sidebar-link,
.sidebar-nav #sidebarnav .sidebar-link.active {
    border-radius: 0 30px 30px 0;
    color: #fff !important;
    font-weight: 500;
    background: linear-gradient(to right, #8971ea, #7f72ea, #7574ea, #6a75e9, #5f76e8) !important;
    box-shadow: 0px 7px 12px 0px rgba(95, 118, 232, 0.25);
    opacity: 1;
}

.sidebar-nav #sidebarnav .sidebar-item.selected > .sidebar-link .feather-icon,
.sidebar-nav #sidebarnav .sidebar-item.selected > .sidebar-link i,
.sidebar-nav #sidebarnav .sidebar-item.active > .sidebar-link .feather-icon,
.sidebar-nav #sidebarnav .sidebar-item.active > .sidebar-link i,
.sidebar-nav #sidebarnav .sidebar-link.active .feather-icon,
.sidebar-nav #sidebarnav .sidebar-link.active i {
    color: #fff !important;
}

.sidebar-nav .nav-small-cap {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8d97ad;
    padding: 14px 20px 4px 18px;
}

.sidebar-nav .list-divider {
    height: 1px;
    margin: 8px 18px;
    background: #edf2f6;
}

/* ==============================================================
   Topbar Header & Search
   ============================================================== */
.topbar {
    box-shadow: 0 1px 15px rgba(0, 0, 0, 0.04);
}

.topbar .navbar-header {
    width: 260px;
    border-right: 1px solid var(--border-color);
}

.topbar .navbar-brand {
    padding: 0 1.25rem;
    height: 65px;
    display: flex;
    align-items: center;
}

.topbar .customize-input input {
    height: 40px;
    border-radius: 20px;
    padding-left: 2.5rem;
    font-size: 0.88rem;
    border: 1px solid #e9ecef;
}

.topbar .customize-input .form-control-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
    pointer-events: none;
}

/* ==============================================================
   Card Components & FreeDash Harmonization
   ============================================================== */
.card-custom, .card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.22);
    margin-bottom: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-custom:hover {
    box-shadow: 0 14px 36px 0 rgba(0, 0, 0, 0.3);
}

.card-header-custom, .card-header {
    padding: 1.15rem 1.4rem;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title-custom, .card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-body-custom, .card-body {
    padding: 1.4rem;
}

/* ==============================================================
   KPI & Stat Cards
   ============================================================== */
.stat-card {
    border-radius: 10px;
    padding: 1.25rem 1.4rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px 0 rgba(0, 0, 0, 0.3);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-icon.primary { background: #eceffd; color: #5f76e8; }
.stat-icon.teal { background: #ccfbf1; color: #0d9488; }
.stat-icon.blue { background: #e0f2fe; color: #0284c7; }
.stat-icon.emerald { background: #d1fae5; color: #10b981; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.rose { background: #ffe4e6; color: #e11d48; }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }

.stat-number {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--dark);
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 0.25rem;
}

/* ==============================================================
   Buttons & Themes
   ============================================================== */
.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(95, 118, 232, 0.3);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    box-shadow: 0 4px 10px rgba(95, 118, 232, 0.4);
}

.btn-teal {
    background-color: var(--teal) !important;
    border-color: var(--teal) !important;
    color: #ffffff !important;
}

.btn-teal:hover {
    background-color: var(--teal-dark) !important;
    border-color: var(--teal-dark) !important;
}

.btn-outline-teal {
    color: var(--teal) !important;
    border-color: var(--teal) !important;
    background-color: transparent !important;
}

.btn-outline-teal:hover {
    background-color: var(--teal) !important;
    border-color: var(--teal) !important;
    color: #ffffff !important;
}

/* ==============================================================
   Colors & Utilities
   ============================================================== */
.text-teal { color: var(--teal) !important; }
.text-amber { color: #d97706 !important; }
.text-rose { color: #e11d48 !important; }
.text-purple { color: #7c3aed !important; }
.text-slate { color: #334155 !important; }

.bg-teal { background-color: var(--teal) !important; color: #ffffff !important; }
.bg-teal-subtle { background-color: var(--teal-light) !important; color: var(--teal-dark) !important; }
.border-teal { border-color: var(--teal) !important; }

.custom-shadow {
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.22) !important;
}
.custom-radius {
    border-radius: 8px !important;
}

/* ==============================================================
   Custom Data Tables
   ============================================================== */
.table-custom {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table-custom td {
    padding: 0.95rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    color: #334155;
}

.table-custom tbody tr:hover {
    background-color: #f8fafc;
}

/* ==============================================================
   Clinical Status Badges
   ============================================================== */
.badge-status {
    padding: 0.35rem 0.65rem;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-active, .badge-completed, .badge-paid {
    background: #d1fae5;
    color: #065f46;
}

.badge-waiting, .badge-in_progress, .badge-partially_paid, .badge-arrived {
    background: #fef3c7;
    color: #92400e;
}

.badge-in_consultation, .badge-with_doctor, .badge-treatment_in_progress {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-booked, .badge-confirmed {
    background: #ccfbf1;
    color: #0f766e;
}

.badge-cancelled, .badge-overdue, .badge-failed, .badge-no_show {
    background: #fee2e2;
    color: #991b1b;
}

/* ==============================================================
   Odontogram / Dental Chart Styling
   ============================================================== */
.dental-chart-container {
    background: #ffffff;
    border-radius: 10px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.22);
}

.odontogram-arch {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.tooth-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    transition: all 0.2s ease;
    user-select: none;
    min-width: 48px;
}

.tooth-box:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(95, 118, 232, 0.2);
}

.tooth-box.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.tooth-box.has-condition {
    border-color: #94a3b8;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.tooth-box.has-condition .tooth-number {
    font-weight: 800;
    color: var(--primary);
}

.tooth-number {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;
    margin-top: 4px;
}

/* SVG Tooth Surface Styling */
.tooth-svg {
    width: 38px;
    height: 48px;
}

.tooth-surface {
    fill: #ffffff;
    stroke: #94a3b8;
    stroke-width: 1.2;
    transition: stroke 0.2s ease;
    cursor: pointer;
}

.tooth-surface:hover {
    stroke: #1c2d41;
    stroke-width: 1.8;
    filter: brightness(0.92);
}

.tooth-surf-label {
    font-size: 6px;
    font-weight: 700;
    fill: #94a3b8;
    opacity: 0.7;
    user-select: none;
}

.tooth-box:hover .tooth-surf-label {
    fill: #334155;
    opacity: 1;
}

.tooth-state-caries   { border-color: #fca5a5 !important; background: #fef2f2 !important; }
.tooth-state-restored { border-color: #93c5fd !important; background: #eff6ff !important; }
.tooth-state-planned  { border-color: #fcd34d !important; background: #fffbeb !important; }
.tooth-state-rct      { border-color: #f9a8d4 !important; background: #fdf2f8 !important; }
.tooth-state-crown    { border-color: #c4b5fd !important; background: #f5f3ff !important; }
.tooth-state-implant  { border-color: #67e8f9 !important; background: #ecfeff !important; }
.tooth-state-missing  { border-color: #cbd5e1 !important; background: #f1f5f9 !important; border-style: dashed !important; opacity: 0.85; }

/* Condition Colors */
.cond-caries, .cond-cavity, .cond-fracture { fill: #ef4444 !important; }
.cond-filling, .cond-restoration { fill: #3b82f6 !important; }
.cond-rct, .cond-root_canal { fill: #ec4899 !important; }
.cond-crown, .cond-bridge, .cond-cap { fill: #8b5cf6 !important; }
.cond-implant { fill: #06b6d4 !important; }
.cond-missing, .cond-extracted, .cond-impacted { fill: #94a3b8 !important; opacity: 0.6; }
.cond-planned_treatment { fill: #f59e0b !important; }
.cond-completed_treatment { fill: #10b981 !important; }
.cond-mobility { fill: #ea580c !important; }
.cond-healthy { fill: #ffffff !important; }

/* Chart Legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.82rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

/* ==============================================================
   Horizontal Top Header Menu Layout Overrides
   ============================================================== */
#main-wrapper.horizontal-layout .page-wrapper {
    margin-left: 0 !important;
    padding-top: 0 !important;
    min-height: calc(100vh - 110px);
}

#main-wrapper.horizontal-layout .topbar-horizontal {
    z-index: 1030;
}

.horizontal-nav .hnav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.65rem 0.9rem !important;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569 !important;
    border-radius: 8px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.horizontal-nav .hnav-link:hover {
    color: #0d9488 !important;
    background: #f0fdfa;
}

.horizontal-nav .hnav-link.active {
    color: #0d9488 !important;
    background: #ccfbf1;
    font-weight: 600;
}

.horizontal-nav .feather-icon-sm {
    width: 15px;
    height: 15px;
    stroke-width: 2;
}

.horizontal-nav .dropdown-menu {
    border-radius: 10px;
    padding: 0.45rem;
    min-width: 230px;
    margin-top: 2px;
}

.horizontal-nav .dropdown-item {
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 500;
}

.horizontal-nav .dropdown-item:hover {
    background: #f1f5f9;
}

/* ==============================================================
   Print View Styles
   ============================================================== */
@media print {
    body, #main-wrapper, .page-wrapper {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .topbar, .topbar-horizontal, .left-sidebar, .footer, .btn-print, .no-print, .preloader {
        display: none !important;
    }
    .page-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .card-custom, .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
