/* ═══════════════════════════════════════════════════════════════════════════
   DFMS MODERN LAYOUT & THEME
   Rebuilt from scratch for a clean, professional admin interface.
   Replaces legacy main.css and site.css.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   1. DESIGN TOKENS (Variables)
   ───────────────────────────────────────────────────────────────────────────── */
:root {
    /* Brand Colors - Navy Blue Theme (consistent with theme-modern.css) */
    --brand-primary: #1e3a5f;       /* Navy Blue (Active states, Buttons) */
    --brand-primary-hover: #152c4a;
    --brand-secondary: #64748b;     /* Slate Gray (Secondary text/icons) */
    
    --brand-success: #10b981;       /* Green (Active/Success) */
    --brand-warning: #f59e0b;       /* Amber (Expiring) */
    --brand-danger: #ef4444;        /* Red (Revoked/Error) */
    --brand-info: #3b82f6;          /* Blue (Pending) */
    
    /* Backgrounds */
    --bg-body: #f8fafc;             /* Very Light Blue-Gray Background */
    --bg-surface: #ffffff;          /* White Surface */
    --bg-sidebar: #ffffff;          /* White Sidebar */
    
    /* Text */
    --text-primary: #1e293b;        /* Slate 800 */
    --text-secondary: #64748b;      /* Slate 500 */
    --text-on-brand: #ffffff;       /* White text on blue background */

    /* Dimensions */
    --header-height: 70px;
    --sidebar-width: 260px;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    
    /* Borders & Shadows */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;           /* Increased radius for cards */
    --radius-xl: 16px;
    --radius-pill: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-card: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -1px rgb(0 0 0 / 0.03);
    --shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
    
    /* Transitions */
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. RESET & BASE STYLES
   ───────────────────────────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-size: 0.925rem;
    line-height: 1.5;
}

a { text-decoration: none; color: inherit; transition: color var(--duration-fast); }
ul { list-style: none; padding: 0; margin: 0; }
button { cursor: pointer; font-family: inherit; }

/* ─────────────────────────────────────────────────────────────────────────────
   3. LAYOUT GRID (App Shell)
   ───────────────────────────────────────────────────────────────────────────── */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: width var(--duration-normal) var(--ease-in-out);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

/* Main Content Wrapper */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents overflow issues */
    transition: margin-left var(--duration-normal) var(--ease-in-out);
}

/* Header */
.app-header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
    position: sticky;
    top: 0;
    z-index: 900;
}

/* Content Area */
.app-content {
    padding: var(--space-5);
    max-width: var(--container-max-width);
    margin: 0 auto;
    width: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. COMPONENT: SIDEBAR
   ───────────────────────────────────────────────────────────────────────────── */
/* Logo Area */
.app-header__logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-5);
    border-bottom: 1px solid #f1f5f9;
}

.logo-src {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.2;
}
.logo-src:before {
    content: "";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: url("/images/mdcsl-logo.png") center / contain no-repeat;
    background-color: transparent;
    border-radius: 6px;
    font-size: 0.9rem;
}
.logo-src:after {
    content: "";
    display: none;
}
/* Hide original text if any */
.logo-src > * { display: none; }


/* Navigation Menu */
.scrollbar-sidebar {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4); /* Add padding for floating feel */
}

.vertical-nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vertical-nav-menu .app-sidebar__heading {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: var(--space-4) var(--space-2) var(--space-2);
    margin: 0;
}

.vertical-nav-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-md); /* Rounded corners for menu items */
    transition: all var(--duration-fast);
    text-decoration: none;
    font-size: 0.95rem;
}

.vertical-nav-menu li a:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

/* Active State - Blue Pill */
.vertical-nav-menu li a.mm-active {
    background: var(--brand-primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.metismenu-icon {
    width: 24px;
    margin-right: 12px;
    text-align: center;
    font-size: 1.1em;
    opacity: 1; /* Icons should be fully visible */
}

/* Submenus */
.vertical-nav-menu ul {
    margin-left: 12px;
    border-left: 1px solid #e2e8f0;
    padding-left: 4px;
    margin-top: 4px;
}
.vertical-nav-menu ul li a {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Mobile Toggle */
.hamburger, .app-header__mobile-menu { display: none; }


/* ─────────────────────────────────────────────────────────────────────────────
   5. COMPONENT: HEADER
   ───────────────────────────────────────────────────────────────────────────── */
.header-left { display: flex; align-items: center; gap: var(--space-4); }
.header-right { display: flex; align-items: center; gap: var(--space-4); }

/* Header is clean white in reference */
.app-header {
    background: white;
    border-bottom: none; /* Cleaner look */
    box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
}

.search-wrapper input {
    background: #f1f5f9;
    border: 1px solid transparent;
}
.search-wrapper input:focus {
    background: white;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* User Profile in Header */
.header-user-info .widget-heading {
    color: var(--text-primary);
    font-size: 0.9rem;
}
.header-user-info .widget-subheading {
    color: var(--text-secondary);
}

/* ─────────────────────────────────────────────────────────────────────────────
   6. COMPONENT: CARDS & WIDGETS
   ───────────────────────────────────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid #f1f5f9;
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-5);
}

.card-header {
    background: white;
    border-bottom: 1px solid #f1f5f9;
    padding: 20px 24px;
    font-size: 1.1rem;
}

.card-body { padding: 24px; }

/* Dashboard Stat Cards */
.widget-content {
    padding: 24px;
    display: flex;
    flex-direction: column; /* Stack for the layout in image? No, image is Side-by-Side but Title is Top Left */
    /* Image: Title Top Left, Icon Top Right. Number Middle. N/A Bottom. */
    position: relative;
    align-items: flex-start;
}

.widget-content-wrapper {
    width: 100%;
}

.widget-heading {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.widget-numbers {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1;
}

.widget-subheading {
    font-size: 0.85rem;
    color: #94a3b8; /* Lighter text for "N/A" */
}

/* Icon in top right */
.widget-icon-right {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Icon Colors */
.bg-primary-soft { background: #eff6ff; color: var(--brand-primary); }
.bg-success-soft { background: #ecfdf5; color: var(--brand-success); }
.bg-warning-soft { background: #fffbeb; color: var(--brand-warning); }
.bg-info-soft { background: #eff6ff; color: var(--brand-info); }


/* ─────────────────────────────────────────────────────────────────────────────
   7. COMPONENT: TABLES
   ───────────────────────────────────────────────────────────────────────────── */
.table th {
    background: white;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: none; /* Image shows normal case headers */
    font-size: 0.85rem;
    border-bottom: 1px solid #f1f5f9;
}

.table td {
    border-bottom: 1px solid #f1f5f9;
    padding: 16px 24px;
    font-size: 0.95rem;
}

.btn-primary { 
    background-color: var(--brand-primary); 
    border-color: var(--brand-primary);
}
.btn-primary:hover { background: var(--brand-primary-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.btn-secondary { background: white; border-color: #d1d5db; color: var(--text-primary); }
.btn-secondary:hover { background: #f3f4f6; border-color: #9ca3af; }

.btn-outline-primary { color: var(--brand-primary); border-color: var(--brand-primary); background: transparent; }
.btn-outline-primary:hover { background: var(--brand-primary); color: white; }

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8rem; }

/* Badges */
.badge {
    padding: 0.35em 0.8em;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.75em;
    text-transform: uppercase;
}
.bg-success { background: #dcfce7 !important; color: #166534; }
.bg-warning { background: #fef3c7 !important; color: #92400e; }
.bg-danger { background: #fee2e2 !important; color: #991b1b; }
.bg-info { background: #dbeafe !important; color: #1e40af; }

/* ─────────────────────────────────────────────────────────────────────────────
   9. PAGE HEADER
   ───────────────────────────────────────────────────────────────────────────── */
.app-page-title {
    margin-bottom: var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title-wrapper { display: flex; align-items: center; gap: var(--space-4); }
.page-title-icon {
    width: 48px;
    height: 48px;
    background: white;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    color: var(--brand-accent);
    font-size: 1.5rem;
}

.page-title-heading { margin: 0; }
.page-title-heading div:first-child { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.page-title-subheading { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }

/* ─────────────────────────────────────────────────────────────────────────────
   11. CUSTOM TABS (System Settings Style)
   ───────────────────────────────────────────────────────────────────────────── */
.nav-pills-custom {
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    display: inline-flex;
    gap: 4px;
}

.nav-pills-custom .nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    transition: all var(--duration-fast);
}

.nav-pills-custom .nav-link:hover {
    color: var(--text-primary);
    background-color: rgba(255,255,255,0.5);
}

.nav-pills-custom .nav-link.active {
    background-color: white;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────────────────
   12. UTILITIES & RESPONSIVE
   ───────────────────────────────────────────────────────────────────────────── */
.text-right { text-align: right; }
.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }
.d-none { display: none !important; }

@media (max-width: 992px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
    
    .sidebar-mobile-open .app-sidebar { transform: translateX(0); }
    .hamburger, .app-header__mobile-menu { display: block; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   13. SYNCFUSION GRID OVERRIDES
   ───────────────────────────────────────────────────────────────────────────── */
.e-grid {
    border: none !important;
    font-family: 'Inter', system-ui, sans-serif !important;
}

.e-grid .e-gridheader {
    border-bottom: 1px solid #e2e8f0;
    border-top: none;
    background: white;
}

.e-grid .e-headercell {
    background-color: #ffffff !important;
    color: var(--text-secondary) !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 14px 16px !important;
}

.e-grid .e-rowcell {
    border: none !important;
    border-bottom: 1px solid #f1f5f9 !important;
    font-size: 0.925rem !important;
    color: var(--text-primary) !important;
    padding: 16px !important;
    vertical-align: middle !important;
}

.e-grid .e-row:hover .e-rowcell {
    background-color: #f8fafc !important;
}

.e-grid .e-altrow .e-rowcell {
    background-color: #fafbfc !important;
}

.e-grid .e-gridcontent {
    border: none !important;
}

/* Pager */
.e-grid .e-pager {
    border: none !important;
    border-top: 1px solid #f1f5f9 !important;
    background-color: white !important;
    padding: 12px 16px !important;
}

.e-pager .e-currentitem {
    background-color: var(--brand-primary) !important;
    color: white !important;
    border-radius: var(--radius-sm) !important;
}

.e-pager .e-numericitem {
    border-radius: var(--radius-sm) !important;
    margin: 0 2px !important;
}

.e-pager .e-numericitem:hover {
    background-color: #f1f5f9 !important;
}

/* Toolbar */
.e-grid .e-toolbar {
    background: white !important;
    border: none !important;
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 8px 16px !important;
}

.e-grid .e-toolbar .e-tbar-btn {
    background: white !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-secondary) !important;
    font-size: 0.85rem !important;
}

.e-grid .e-toolbar .e-tbar-btn:hover {
    background: #f8fafc !important;
    color: var(--text-primary) !important;
}

/* Filter Dialog */
.e-grid .e-excelfilter {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-card) !important;
}

/* Selection */
.e-grid .e-selectionbackground {
    background-color: rgba(37, 99, 235, 0.08) !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   14. AVATAR STYLES
   ───────────────────────────────────────────────────────────────────────────── */
.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-title {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ─────────────────────────────────────────────────────────────────────────────
   15. CHART CONTAINER STYLES
   ───────────────────────────────────────────────────────────────────────────── */
.card-body canvas {
    max-height: 300px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   16. SIMPLE DATATABLES STYLING (Alternative to Syncfusion)
   ───────────────────────────────────────────────────────────────────────────── */
.datatable-wrapper {
    font-family: 'Inter', system-ui, sans-serif;
}

.datatable-top,
.datatable-bottom {
    padding: 12px 0;
}

.datatable-search input {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: 0.9rem;
}

.datatable-search input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.datatable-selector {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 6px 8px;
}

.datatable-pagination-list-item-link {
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    color: var(--text-secondary);
}

.datatable-pagination-list-item.datatable-active .datatable-pagination-list-item-link {
    background-color: var(--brand-primary);
    color: white;
}

/* ─────────────────────────────────────────────────────────────────────────────
   17. CARD HEADER THEME OVERRIDES
   ───────────────────────────────────────────────────────────────────────────── */
/* Override Bootstrap's bg-primary to use our theme color */
.card-header.bg-primary {
    background-color: var(--brand-primary) !important;
    border-bottom: none;
}

/* Consistent card styling */
.card {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    border-radius: 0;
    font-weight: 600;
}

.card-header h4,
.card-header h5,
.card-header h6 {
    font-weight: 600;
}

/* Theme-aware button overrides */
.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
}

.btn-outline-primary {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

/* Text and background theme colors */
.text-primary {
    color: var(--brand-primary) !important;
}

.bg-primary {
    background-color: var(--brand-primary) !important;
}

/* Breadcrumb styling */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
}

.breadcrumb-item a {
    color: var(--brand-primary);
}

.breadcrumb-item a:hover {
    color: var(--brand-primary-hover);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

/* Badge overrides */
.badge.bg-primary {
    background-color: var(--brand-primary) !important;
}
