/* ============================================================================
   MJM LIFE CARE PVT LTD - Modern Healthcare ERP Design System (SaaS UI)
   Redesigned 2025
   ============================================================================ */

:root {
    /* Brand Colors */
    --mjm-primary: #0284c7;
    --mjm-primary-dark: #0369a1;
    --mjm-primary-light: #0ea5e9;
    --mjm-secondary: #0d9488;
    --mjm-teal: #14b8a6;
    --mjm-accent: #10b981;
    --mjm-navy: #0f172a;

    /* Neutrals */
    --mjm-dark: #1e293b;
    --mjm-light: #f8fafc;
    --mjm-border: #e2e8f0;
    --mjm-muted: #64748b;
    --mjm-card-bg: #ffffff;
    --mjm-body-bg: #f1f5f9;

    /* Sidebar */
    --mjm-sidebar-bg: #0f172a;
    --mjm-sidebar-hover: #1e293b;
    --mjm-sidebar-text: #94a3b8;
    --mjm-sidebar-active: #0284c7;

    /* Shadows */
    --mjm-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --mjm-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
    --mjm-shadow-md: 0 8px 16px -4px rgba(15, 23, 42, 0.08);
    --mjm-shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.1);

    /* Radius */
    --mjm-radius: 14px;
    --mjm-radius-sm: 10px;
    --mjm-radius-lg: 18px;
    --mjm-radius-full: 9999px;

    /* Typography */
    --mjm-font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark Theme */
[data-bs-theme="dark"] {
    --mjm-body-bg: #0b0f19;
    --mjm-card-bg: #131b2e;
    --mjm-border: #1e293b;
    --mjm-muted: #94a3b8;
    --mjm-sidebar-bg: #080d1a;
    --mjm-sidebar-hover: #131b2e;
    --mjm-dark: #e2e8f0;
}

/* Base */
body {
    font-family: var(--mjm-font);
    background-color: var(--mjm-body-bg);
    color: #1e293b;
    min-height: 100vh;
    font-size: 0.9rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[data-bs-theme="dark"] body {
    color: #cbd5e1;
}

/* ======================
   LAYOUT
====================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ======================
   SIDEBAR
====================== */
.app-sidebar {
    width: 268px;
    background: var(--mjm-sidebar-bg);
    color: var(--mjm-sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar-brand {
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}
.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

.menu-category {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #64748b;
    padding: 16px 14px 8px;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--mjm-radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 3px;
    transition: all 0.2s ease;
    position: relative;
}

.nav-link-item i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
    color: #64748b;
    transition: all 0.2s ease;
}

.nav-link-item:hover {
    background-color: var(--mjm-sidebar-hover);
    color: #ffffff;
}

.nav-link-item:hover i {
    color: var(--mjm-primary-light);
}

.nav-link-item.active {
    background: linear-gradient(135deg, var(--mjm-primary), var(--mjm-secondary));
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
    font-weight: 600;
}

.nav-link-item.active i {
    color: #ffffff;
}

/* Sidebar User */
.sidebar-user {
    padding: 16px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284c7, #0d9488);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
}

/* ======================
   MAIN CONTENT
====================== */
.app-main {
    flex: 1;
    margin-left: 268px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* ======================
   TOPBAR
====================== */
.app-topbar {
    height: 70px;
    background: var(--mjm-card-bg);
    border-bottom: 1px solid var(--mjm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--mjm-shadow-sm);
    backdrop-filter: blur(8px);
}

.topbar-search {
    position: relative;
    width: 400px;
}

.topbar-search input {
    border-radius: var(--mjm-radius-full);
    padding: 10px 16px 10px 44px;
    font-size: 0.875rem;
    border: 1px solid var(--mjm-border);
    background-color: var(--mjm-body-bg);
    transition: all 0.2s ease;
    width: 100%;
}

.topbar-search input:focus {
    background-color: var(--mjm-card-bg);
    border-color: var(--mjm-primary);
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
    outline: none;
}

.topbar-search .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--mjm-muted);
    font-size: 1rem;
}

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: var(--mjm-card-bg);
    border: 1px solid var(--mjm-border);
    border-radius: var(--mjm-radius);
    box-shadow: var(--mjm-shadow-lg);
    z-index: 1050;
    max-height: 420px;
    overflow-y: auto;
    display: none;
}

/* ======================
   CONTENT AREA
====================== */
.app-content {
    padding: 28px 32px;
    flex: 1;
}

/* ======================
   CARDS
====================== */
.mjm-card {
    background: var(--mjm-card-bg);
    border: 1px solid var(--mjm-border);
    border-radius: var(--mjm-radius);
    box-shadow: var(--mjm-shadow);
    margin-bottom: 24px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mjm-card:hover {
    box-shadow: var(--mjm-shadow-md);
}

.mjm-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--mjm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to right, rgba(2, 132, 199, 0.03), transparent);
}

.mjm-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
}

[data-bs-theme="dark"] .mjm-card-title {
    color: #f1f5f9;
}

.mjm-card-body {
    padding: 24px;
}

/* ======================
   KPI CARDS (Improved)
====================== */
.kpi-card {
    padding: 22px 24px;
    position: relative;
    border-top: 4px solid var(--mjm-primary);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    transition: all 0.25s ease;
    border-radius: var(--mjm-radius);
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--mjm-shadow-md);
}

.kpi-card.teal   { border-top-color: #0d9488; }
.kpi-card.emerald{ border-top-color: #10b981; }
.kpi-card.amber  { border-top-color: #f59e0b; }
.kpi-card.rose   { border-top-color: #f43f5e; }
.kpi-card.indigo { border-top-color: #6366f1; }
.kpi-card.cyan   { border-top-color: #06b6d4; }

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--mjm-muted);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    background: rgba(2, 132, 199, 0.1);
    color: var(--mjm-primary);
    transition: all 0.25s ease;
}

.kpi-card:hover .kpi-icon {
    transform: scale(1.08);
}

.kpi-card.teal .kpi-icon    { background: rgba(13, 148, 136, 0.12); color: #0d9488; }
.kpi-card.emerald .kpi-icon { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.kpi-card.amber .kpi-icon   { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.kpi-card.rose .kpi-icon    { background: rgba(244, 63, 94, 0.12); color: #f43f5e; }
.kpi-card.indigo .kpi-icon  { background: rgba(99, 102, 241, 0.12); color: #6366f1; }
.kpi-card.cyan .kpi-icon    { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.6px;
    color: #0f172a;
    line-height: 1.15;
    margin-bottom: 6px;
}

[data-bs-theme="dark"] .kpi-value {
    color: #f8fafc;
}

.kpi-subtext {
    font-size: 0.8rem;
    color: var(--mjm-muted);
}

.kpi-subtext a {
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

.kpi-subtext a:hover {
    opacity: 0.8;
}

/* ======================
   TABLES
====================== */
.mjm-table {
    width: 100%;
    margin-bottom: 0;
    vertical-align: middle;
}

.mjm-table thead th {
    background-color: var(--mjm-body-bg);
    color: var(--mjm-muted);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--mjm-border);
    white-space: nowrap;
}

.mjm-table tbody td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--mjm-border);
    font-size: 0.875rem;
    color: #334155;
}

[data-bs-theme="dark"] .mjm-table tbody td {
    color: #cbd5e1;
}

.mjm-table tbody tr {
    transition: background-color 0.15s ease;
}

.mjm-table tbody tr:hover {
    background-color: rgba(2, 132, 199, 0.04);
}

[data-bs-theme="dark"] .mjm-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* ======================
   BADGES
====================== */
.badge-status {
    padding: 5px 12px;
    border-radius: var(--mjm-radius-full);
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-transform: capitalize;
}

.badge-paid     { background: #dcfce7; color: #15803d; }
.badge-partial,
.badge-due      { background: #fef3c7; color: #b45309; }
.badge-unpaid   { background: #fee2e2; color: #b91c1c; }
.badge-overdue  { background: #ffe4e6; color: #be123c; font-weight: 700; }
.badge-confirmed{ background: #e0f2fe; color: #0369a1; }
.badge-void     { background: #f1f5f9; color: #64748b; text-decoration: line-through; }

/* Dark mode badge adjustments */
[data-bs-theme="dark"] .badge-paid     { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
[data-bs-theme="dark"] .badge-partial,
[data-bs-theme="dark"] .badge-due      { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
[data-bs-theme="dark"] .badge-unpaid   { background: rgba(239, 68, 68, 0.2); color: #f87171; }
[data-bs-theme="dark"] .badge-overdue  { background: rgba(244, 63, 94, 0.2); color: #fb7185; }
[data-bs-theme="dark"] .badge-confirmed{ background: rgba(2, 132, 199, 0.2); color: #38bdf8; }

/* ======================
   BUTTONS
====================== */
.btn-sm {
    border-radius: var(--mjm-radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-sm:hover {
    transform: translateY(-1px);
}

.btn-mjm-primary {
    background: linear-gradient(135deg, var(--mjm-primary), var(--mjm-secondary));
    color: #ffffff;
    border: none;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: var(--mjm-radius-sm);
    box-shadow: 0 3px 8px rgba(2, 132, 199, 0.3);
    transition: all 0.2s ease;
}

.btn-mjm-primary:hover {
    background: linear-gradient(135deg, var(--mjm-primary-dark), #0f766e);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.4);
    transform: translateY(-2px);
}

.btn-mjm-primary:active {
    transform: translateY(0);
}

/* Chart filter buttons */
.chart-filter-btn {
    font-size: 0.75rem;
    border-radius: var(--mjm-radius-sm) !important;
    font-weight: 500;
}

.chart-filter-btn.active {
    background-color: var(--mjm-primary);
    color: #ffffff;
    border-color: var(--mjm-primary);
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

/* ======================
   UTILITIES
====================== */
.text-teal { color: #0d9488 !important; }
.bg-teal   { background-color: #0d9488 !important; }

/* ======================
   RESPONSIVE
====================== */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }

    .topbar-search {
        width: 220px;
    }

    .app-content {
        padding: 20px 16px;
    }
}

@media (max-width: 575.98px) {
    .topbar-search {
        width: 160px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }
}