:root {
    /* --- Spacing System --- */
    --space-xs: 0.5rem;   /* 8px */
    --space-sm: 0.75rem;  /* 12px */
    --space-md: 1rem;     /* 16px */
    --space-lg: 1.5rem;   /* 24px */
    --space-xl: 2rem;     /* 32px */
    --space-xxl: 3rem;    /* 48px */

    /* --- Shadows (Modern & Soft) --- */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* --- Border Radius --- */
    --radius-sm: 0.375rem; /* 6px */
    --radius-md: 0.75rem;  /* 12px */
    --radius-lg: 1rem;     /* 16px */
    --radius-xl: 1.5rem;   /* 24px */

    /* --- Typography Overrides --- */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-bold: 600;
}

/* --- Global Reset & Base --- */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--bs-gray-800);
    background-color: #f3f4f6; /* Slightly cooler gray for modern feel */
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

#main-wrapper {
    overflow-x: hidden;
}

.header .nav-control {
    display: none !important;
}

body[data-sidebar-style="mini"] .deznav .nav-text {
    display: inline !important;
}



/* --- Typography --- */
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    color: var(--bs-gray-900);
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.025em; /* Tighten headings for modern look */
}

/* --- Card Component (Overhaul) --- */
.card {
    border: none !important;
    background: #ffffff;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: var(--space-lg);
    /* overflow: hidden; */ /* Removed to prevent clipping of content like buttons at the bottom */
}

.card:hover {
    /* Subtle lift effect only if it has interaction class or simply general polish */
    box-shadow: var(--shadow-lg); 
}

/* Specific fix for the "box-hover" class used in dashboard */
.box-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--bs-gray-200);
    padding: var(--space-lg);
    font-weight: var(--font-weight-bold);
}

.card-body {
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-lg) * 1.8);
}

.content-body .container-fluid > .row {
    --bs-gutter-x: 1.5rem;
    --bs-gutter-y: 1.5rem;
}

.content-body .container-fluid > .row > [class*="col-"] .card {
    margin-bottom: 0;
}

/* --- Forms & Inputs --- */
.form-control {
    min-height: 48px; /* Larger touch target */
    border-radius: var(--radius-sm);
    border: 1px solid var(--bs-gray-300);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.95rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.form-control:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 3px var(--rgba-primary-2);
}

label {
    margin-bottom: var(--space-xs);
    font-weight: var(--font-weight-medium);
    color: var(--bs-gray-700);
    font-size: 0.9rem;
}

/* --- Buttons --- */
.btn {
    padding: 0.6rem 1.2rem;
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-sm);
    letter-spacing: 0.01em;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem; /* Space between icon and text */
}

.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* --- Tables --- */
.table-responsive {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background: white;
}

.table {
    margin-bottom: 0;
    width: 100%;
}

.table thead th {
    background-color: #f9fafb;
    color: var(--bs-gray-600);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: var(--space-md);
    border-bottom: 1px solid var(--bs-gray-200);
    border-top: none;
}

.table tbody td {
    padding: var(--space-md);
    vertical-align: middle;
    color: var(--bs-gray-700);
    border-bottom: 1px solid var(--bs-gray-100);
    font-size: 0.9rem;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

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

/* --- Sidebar & Navigation --- */
.deznav {
    background-color: var(--sidebar-bg) !important;
    box-shadow: var(--shadow-sm);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.nav-header {
    background-color: var(--sidebar-bg) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.deznav .metismenu > li > a {
    font-weight: var(--font-weight-medium);
    color: rgba(255, 255, 255, 0.92) !important;
    border-radius: 0;
    margin: 0;
    padding: var(--space-sm) var(--space-md);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    width: 100%;
    text-align: left;
    position: relative;
}

.deznav .metismenu > li > a .menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
}

.deznav .metismenu > li > a .menu-icon svg {
    width: 24px;
    height: 24px;
}

.deznav .metismenu > li > a svg {
    margin-right: 0 !important;
    margin-top: 0 !important;
}

.deznav .metismenu > li > a .nav-text {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    font-size: 1.05rem;
    line-height: 1.25;
}

.deznav .metismenu > li > a:hover,
.deznav .metismenu > li > a:focus,
.deznav .metismenu > li.mm-active > a {
    background-color: rgba(255, 255, 255, 0.14);
    color: #ffffff !important;
}

.deznav .metismenu .has-arrow:after {
    border-top: 0.3125rem solid rgba(255, 255, 255, 0.95);
    border-left: 0.3125rem solid rgba(255, 255, 255, 0.95);
    border-bottom: 0.3125rem solid transparent;
    border-right: 0.3125rem solid transparent;
    border-width: 1px;
    right: 15px;
    top: 50%;
    transform: rotate(-225deg) translateY(-50%);
}

.deznav .metismenu .has-arrow[aria-expanded=true]:after,
.deznav .metismenu .mm-active > .has-arrow:after {
    transform: rotate(-135deg) translateY(-50%);
}

.deznav .metismenu ul a {
    color: rgba(255, 255, 255, 0.7) !important;
    text-align: left;
    display: flex;
    align-items: center;
    width: 100%;
    padding-left: 3rem !important;
    padding-right: 1rem !important;
    padding-top: 0.6rem !important;
    padding-bottom: 0.6rem !important;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    position: relative;
    text-decoration: none;
}

/* Bullet point for submenu items */
.deznav .metismenu ul a::before {
    content: "" !important;
    position: absolute;
    left: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transition: all 0.2s;
}

/* Hover state */
.deznav .metismenu ul a:hover,
.deznav .metismenu ul a:focus {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

.deznav .metismenu ul a:hover::before,
.deznav .metismenu ul a:focus::before {
    background-color: #ffffff;
    transform: translateY(-50%) scale(1.2);
}

/* Active state */
.deznav .metismenu ul a.mm-active {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.15) !important;
    font-weight: 600;
}

.deznav .metismenu ul a.mm-active::before {
    background-color: #ffffff;
    transform: translateY(-50%) scale(1.2);
}

.deznav .metismenu > li > ul {
    background: rgba(0, 0, 0, 0.08) !important;
    margin: 0 var(--space-xs);
    padding: 0.25rem 0.25rem;
    border-radius: var(--radius-md);
    box-shadow: none !important;
}

.nav-header .brand-title {
    font-size: 1.2rem !important;
    font-weight: 700;
    color: #ffffff !important;
    letter-spacing: -0.025em;
    display: none;
    line-height: 1;
}

@media (min-width: 769px) {
    .nav-header .brand-title {
        display: inline-block;
    }
}

/* --- Sidebar Styling --- */
.deznav {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 3.125rem);
    padding-bottom: 0;
}

.deznav .deznav-scroll {
    flex: 1 1 auto;
    overflow-y: auto !important;
    height: auto !important;
    display: flex;
    flex-direction: column;
}

.deznav .menu-icon svg [stroke] {
    stroke: rgba(255, 255, 255, 0.92) !important;
}

.deznav .metismenu > li.mm-active > a .menu-icon svg [stroke],
.deznav .metismenu > li:hover > a .menu-icon svg [stroke],
.deznav .metismenu > li:focus > a .menu-icon svg [stroke] {
    stroke: #ffffff !important;
}

/* Profile Section */
.sidebar-profile {
    padding: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.08);
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-top: auto; /* Push to bottom */
}

.sidebar-profile .profile-img img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-profile .profile-info {
    margin-left: var(--space-sm);
    flex: 1;
    overflow: hidden;
}

.sidebar-profile .profile-info h6 {
    font-size: 0.875rem;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile .profile-info span {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.75);
}

.logout-btn {
    color: rgba(255, 255, 255, 0.75);
    padding: var(--space-xs);
    transition: color 0.2s;
}

.logout-btn:hover {
    color: var(--bs-danger);
}

@media (max-width: 576px) {
    body[data-layout="vertical"] .nav-header,
    body[data-layout="vertical"] .deznav {
        width: 80vw !important;
        max-width: 18rem !important;
    }

    body[data-sidebar-style="mini"][data-layout="vertical"] .deznav {
        width: 80vw !important;
        max-width: 18rem !important;
    }

    body[data-sidebar-style="mini"][data-layout="vertical"] .deznav .nav-text {
        display: inline !important;
    }

    .deznav .metismenu > li > a .menu-icon {
        flex: 0 0 32px;
        width: 32px;
    }

    .deznav .metismenu > li > a .menu-icon svg {
        width: 26px;
        height: 26px;
    }

    .deznav .metismenu > li > a .nav-text {
        font-size: 1.1rem;
    }

    body[data-sidebar-style="mini"][data-layout="vertical"] .deznav .metismenu > li:hover > ul {
        left: auto !important;
        width: auto !important;
        position: static !important;
        padding: 0 !important;
        margin-left: 0 !important;
        height: auto !important;
        overflow: hidden !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    body[data-sidebar-style="mini"][data-layout="vertical"] .deznav .metismenu > li > ul {
        background: rgba(0, 0, 0, 0.08) !important;
    }

    .content-body .container-fluid > .row {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    .sidebar-profile {
        display: flex !important;
    }

    body .header .nav-control {
        display: flex !important;
        position: static !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        background: transparent !important;
        width: auto !important;
        height: auto !important;
        padding: 0 !important;
        z-index: 10;
    }

    .header .nav-control .hamburger {
        top: 0;
        left: 0;
        width: 1.625rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .header .nav-control .hamburger .line {
        margin: 2px 0 !important;
    }

    .header .nav-control .hamburger .line {
        background: #000000 !important;
    }

    .header-profile2 {
        display: none;
    }

    .header {
        padding-left: 0 !important;
    }

    .header .navbar-collapse {
        display: flex !important;
    }

    .header .header-content:after {
        display: none !important;
    }

    .content-body {
        margin-left: 0 !important;
    }

    .container-fluid {
        padding-left: var(--space-md) !important;
        padding-right: var(--space-md) !important;
        overflow-x: hidden;
    }
}

/* --- Top Header --- */
.header {
    background: #ffffff !important;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid #eee;
    height: 3.125rem;
}

.header .header-content {
        padding-left: var(--space-md) !important;
        padding-right: var(--space-md) !important;
    }

    /* Show mobile logo */
    .mobile-logo {
        display: flex !important;
        align-items: center;
        height: 100%;
        color: var(--bs-gray-900) !important;
    }

    .mobile-logo img {
        height: 32px !important;
        width: auto;
    }

    .mobile-logo .brand-title {
        display: block !important;
        font-weight: 700;
        font-size: 1.1rem;
        margin-left: 0.5rem;
        color: #333;
    }

    .nav-header .brand-logo {
        padding: 0 var(--space-md);
        display: flex;
        align-items: center;
    }

/* --- Dashboard Specifics --- */
.icon-box {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.icon-box i {
    font-size: 1.35rem;
    line-height: 1;
}

.icon-box.rounded-circle {
    border-radius: 50% !important;
}

.card.box-hover {
    height: 100%;
}

.card.box-hover .card-body .d-flex.align-items-center {
    gap: 14px;
}

.total-projects {
    flex: 1;
    min-width: 0;
}

.total-projects h3, .total-projects h4 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bs-gray-900);
    line-height: 1.2;
}

.total-projects span {
    font-size: 0.875rem;
    font-weight: 500;
}

/* --- Utilities --- */
.text-muted {
    color: #6b7280 !important; /* Cool gray 500 */
}

.rounded-circle {
    border-radius: 50% !important;
}

/* --- Login / Auth Pages --- */
.auth-form {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    background: #ffffff;
}

.auth-form .btn {
    height: 48px; /* Match input height */
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: var(--font-weight-bold);
}

.authincation {
    background: #f3f4f6; /* Ensure background is not white */
}

/* --- Layout Spacing --- */
.content-body {
    background-color: #f9fafb; /* Light cool gray */
}

.container-fluid {
    padding-top: var(--space-lg);
    padding-bottom: var(--space-xl);
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
}

.page-titles {
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    margin-bottom: var(--space-md);
    box-shadow: none; /* Remove default shadow if any */
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
}

.breadcrumb-item.active a {
    color: var(--bs-gray-600);
}

/* --- Footer --- */
.footer {
    background: #ffffff;
    padding: var(--space-md);
    border-top: 1px solid var(--bs-gray-200);
    color: var(--bs-gray-500);
    font-size: 0.875rem;
}

/* --- Responsive & Adaptive Layout --- */

/* Mobile Devices (< 576px) */
@media (max-width: 575.98px) {
    .container-fluid {
        padding-left: var(--space-md) !important;
        padding-right: var(--space-md) !important;
    }

    .card-body {
        padding: var(--space-md);
        padding-bottom: calc(var(--space-md) * 1.8);
    }

    .auth-form {
        padding: var(--space-lg);
    }

    h1, .h1 {
        font-size: 1.5rem;
    }

    .deznav {
        width: 100vw !important;
        max-width: 100vw !important;
        position: fixed;
        left: -100vw;
        top: 0;
        bottom: 0;
        height: 100vh;
        transition: all 0.3s ease;
        z-index: 100;
    }

    .deznav.show {
        left: 0;
    }

    .content-body {
        margin-left: 0 !important;
        width: 100% !important;
        padding-top: 4rem; /* Space for fixed header */
    }

    .header {
        width: 100% !important;
        padding-left: 0 !important;
        position: fixed;
        top: 0;
        z-index: 99;
    }

    .nav-header {
        width: auto !important;
        background: transparent !important;
        display: none; /* Hide brand in sidebar on mobile, use header brand */
    }

    /* Form usability */
    .form-control, .btn {
        min-height: 48px;
    }

    /* Stack grid columns */
    .col-md-3, .col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: var(--space-md);
    }
    
    /* Scrollable tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
}

/* Tablet / Medium Devices (576px - 991px) */
@media (min-width: 576px) and (max-width: 991.98px) {
    .container-fluid {
        padding-left: var(--space-lg);
        padding-right: var(--space-lg);
    }

    .deznav {
        width: 16rem !important;
        position: fixed;
        left: -16rem; /* Hidden by default */
        top: 0;
        bottom: 0;
        z-index: 100;
        transition: all 0.3s ease;
        box-shadow: var(--shadow-lg);
    }

    .deznav.show {
        left: 0;
    }

    /* Overlay backdrop when sidebar is shown */
    .deznav.show::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: -1;
    }

    .content-body {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .header {
        padding-left: 0 !important;
        width: 100% !important;
    }

    /* 2 Columns for cards */
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Desktop / Large Devices (>= 992px) */
@media (min-width: 992px) {
    /* Standard Sidebar */
    .deznav {
        width: 17rem !important; 
        left: 0;
        position: fixed;
        top: 0;
        bottom: 0;
        z-index: 10;
        transition: all 0.3s ease;
    }

    .header {
        padding-left: 17rem !important;
        width: 100% !important;
        transition: all 0.3s ease;
    }

    .content-body {
        margin-left: 17rem !important;
        width: auto !important;
        transition: all 0.3s ease;
    }

    /* Mini Sidebar Support */
    body[data-sidebar-style="mini"] .deznav {
        width: 5rem !important;
        overflow: visible !important;
    }

    body[data-sidebar-style="mini"] .header {
        padding-left: 5rem !important;
    }

    body[data-sidebar-style="mini"] .content-body {
        margin-left: 5rem !important;
    }

    body[data-sidebar-style="mini"] .deznav .nav-text {
        display: none !important;
    }

    body[data-sidebar-style="mini"] .deznav:hover {
        width: 17rem !important;
    }

    body[data-sidebar-style="mini"] .deznav:hover .nav-text {
        display: inline-block !important;
    }

    /* Standard Grid */
    .col-md-3 {
        flex: 0 0 25%;
        max-width: 25%;
    }
}

/* Print Optimization */
@media print {
    .deznav, .header, .footer, .btn, .no-print {
        display: none !important;
    }

    .content-body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    .container-fluid {
        padding: 0 !important;
    }
}
