/* ================= Theme Variables ================= */
:root {
    /* Light Mode */
    --bg-body: #f8f9fa;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --text-main: #333333;
    --text-dark: #343a40;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --navbar-bg: #0d6efd;
    --navbar-text: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.08);
    --accent-blue: #0d6efd;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 70px;
}

body.dark-theme {
    /* Dark Mode */
    --bg-body: #121212;
    --bg-sidebar: #1e1e1e;
    --bg-card: #252525;
    --text-main: #e0e0e0;
    --text-dark: #e0e0e0;
    --text-muted: #a0a0a0;
    --border-color: #333333;
    --navbar-bg: #1a1a1a;
    --navbar-text: #0d6efd;
    --card-shadow: rgba(0, 0, 0, 0.4);
}

/* ================= Global Reset ================= */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* ================= Sidebar ================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    padding: 20px 0;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 1200;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Default State: Collapsed */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    padding: 20px 10px;
}

.sidebar .user-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent-blue);
    color: white;
    border-radius: 50%;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sidebar.collapsed .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.sidebar .user-details {
    margin-left: 10px;
    line-height: 1.4;
}
.sidebar .profile-bottom-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgb(221, 221, 221);
    padding: 15px;
    position: absolute;
    bottom: 0;
    width: 100%;
}
.sidebar .user-name {
    font-size: .875rem;
    color: var(--text-main);
    font-weight: 500;
    margin-bottom: 0px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}
.sidebar .user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

.sidebar .menu-section {
    border-bottom: 1px solid #ddd;
    padding-bottom: 15px;
}
.sidebar .menu-section-title {
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 15px;
    margin: 10px 0 10px;
    letter-spacing: 1px;
}

.sidebar a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 0;
    margin-bottom: 4px;
    text-decoration: none;
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.sidebar a i {
    min-width: 20px;
    font-size: 1rem;
    margin-right: .25rem;
}
.sidebar a i.dropdown-icon {
    font-size: .75rem;
}

.sidebar a:hover, .sidebar a.active {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--accent-blue);
}

.sidebar a.active {
    background-color: var(--accent-blue);
    color: #ffffff;
    font-weight: 500;
}

/* Hiding text when collapsed */
.sidebar.collapsed .user-details,
.sidebar.collapsed .logout-btn,
.sidebar.collapsed .menu-section-title,
.sidebar.collapsed .user-email,
.sidebar.collapsed a span {
    display: none;
}

.sidebar.collapsed .profile-bottom-section {
    justify-content: center;
    width: 70%;
    padding: 15px 0;
}
.sidebar.collapsed .dropdown-icon {
    display: none;
}

#sidebarnav {
    list-style: none;
    padding-left: 0;
}

#sidebarnav {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#sidebarnav li {
    list-style: none;
}

/* Dropdown */
.has-dropdown > .submenu {
    display: none;
    padding-left: 15px;
}

.has-dropdown.open > .submenu {
    display: block;
}

/* Dropdown icon rotation */
.dropdown-icon {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.has-dropdown.open .dropdown-icon {
    transform: rotate(180deg);
}

/* Submenu link style */
.submenu a {
    font-size: 0.85rem;
    padding: 8px 15px;
}

/* =========================
   MOBILE SIDEBAR FIX
========================= */

@media (max-width: 992px) {

    .sidebar {
        left: -100%;
        width: 260px;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .main-content,
    .navbar-custom {
        margin-left: 0 !important;
    }

    /* Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        backdrop-filter: blur(2px);
        z-index: 1100;
        opacity: 0;
        visibility: hidden;
        transition: 0.3s;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

}

/* ================= Header ================= */
.navbar-custom {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 60px;
    background-color: var(--navbar-bg);
    color: var(--navbar-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px var(--card-shadow);
}

.navbar-custom.collapsed {
    left: var(--sidebar-collapsed-width);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 0;
}

.navbar-title {
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hamburger {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    padding: 5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
}

.user-initials {
    width: 35px;
    height: 35px;
    background-color: #fff;
    color: var(--accent-blue);
    border-radius: 50%;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================= Main Content ================= */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 80px 25px 25px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* ================= Dashboard Grid & Cards ================= */
.dashboard-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card-dashboard {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px var(--card-shadow);
    transition: transform 0.2s ease;
}


.card-dashboard .title {
    margin-top: 0;
    margin-bottom: 0;
    font-size: 1.125rem;
    font-weight: 500;
    line-height: 1.3;
}
.counts p {
    font-size: 13px;
    margin: 0 0 1rem;
}
.counts .stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

/* Card Utility Colors (Softened for Dark Mode) */
.bg-lightblue  { background-color: #b9e2fe !important; color: var(--text-main); }
.bg-lightyellow { background-color: #fee289 !important; color: var(--text-main); }
.bg-lightorange { background-color: #ffd8a5 !important; color: var(--text-main); }
.bg-lightpink   { background-color: #ffc6c6 !important; color: var(--text-main); }

body.dark-theme .bg-lightblue  { background-color: #0d3b66 !important; color: #fff; }
body.dark-theme .bg-lightyellow { background-color: #5f4d1a !important; color: #fff; }
body.dark-theme .bg-lightorange  { background-color: #662e0d !important; color: #fff; }
body.dark-theme .bg-lightpink { background-color: #5f1a54 !important; color: #fff; }

/* ================= Responsive Queries ================= */

/* Tablets */
@media (max-width: 992px) {
    /* Side bar is icons-only by default on tablets */
    :root {
        --sidebar-width: 70px;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .navbar-custom {
        left: 0 !important; /* Force header to span full width on mobile */
        width: 100%;
        padding: 0 15px;
    }

    .header-left {
        gap: 10px; /* Tighten gap for small screens */
    }

    .navbar-title {
        font-size: 0.9rem; /* Prevent title from pushing icons off-screen */
    }
}

@media (max-width: 480px) {
    .navbar-title { font-size: 0.9rem; }
    .dashboard-container { grid-template-columns: 1fr; }
}

/* ================= Table Styling ================= */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    color: var(--text-main);
}

.custom-table th {
    text-align: left;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.02);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

body.dark-theme .custom-table th {
    background-color: rgba(255, 255, 255, 0.05);
}

.custom-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 0.9rem;
}

.custom-table tr:hover {
    background-color: rgba(13, 110, 253, 0.02);
}

/* --- ID Badge --- */
.badge-id {
    background: var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* --- Buttons --- */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn-edit, .btn-delete {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-edit { color: #ffc107; }
.btn-delete { color: #dc3545; }

.btn-edit:hover, .btn-delete:hover {
    transform: scale(1.2);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .custom-table th, .custom-table td {
        padding: 10px;
        font-size: 0.8rem;
    }
}

/* --- Package Badge --- */
.badge-package {
    background-color: rgba(13, 110, 253, 0.1);
    color: var(--accent-blue);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(13, 110, 253, 0.2);
}

body.dark-theme .badge-package {
    background-color: rgba(13, 110, 253, 0.2);
    color: #8dbbff;
}

/* Ensure long addresses don't break the layout */
.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================= Form Styling ================= */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Two columns by default */
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input, 
.form-group select, 
.form-group textarea {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

/* Width Helpers */
.full-width {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    gap: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* Alert Styling */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.alert-danger { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }

/* Responsive Forms */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr; /* Stack inputs on mobile */
    }
    .full-width {
        grid-column: span 1;
    }
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    background: var(--accent-blue);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 10px;
}

/* --- Date Box Styling --- */
.date-box {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.date-day {
    font-weight: 700;
    color: var(--text-main);
    font-size: 1rem;
}
.date-month {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* --- Utilities --- */
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }

body.dark-theme .user-avatar-sm {
    background: #2a2a2a;
    border: 1px solid var(--border-color);
    color: var(--accent-blue);
}

/* Specific Package Badge Color for Enquiries */
.badge-package {
    background-color: rgba(32, 201, 151, 0.1); /* Teal tint */
    color: #20c997;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(32, 201, 151, 0.2);
}

/* ================= Tabs ================= */
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
    border-bottom: 2px solid var(--border-color);
}

.nav-tabs li {
    margin-right: 12px;
}

.nav-tabs li:last-child {
    margin-right: 0;
}

.nav-tabs .nav-link {
    display: inline-block;
    padding: 8px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--accent-blue);
    background: rgba(13,110,253,0.05);
}

.nav-tabs .nav-link.active {
    color: #fff;
    background: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    border-bottom: 2px solid #fff;
}

.nav-tabs li + li .nav-link {
    margin-left: 0;
}

/* ================= Pagination ================= */
.pagination {
    display: flex;
    list-style: none;
    padding-left: 0;
    margin-top: 15px;
}

.pagination .page-item {
    margin-right: 5px;
}

.pagination .page-link {
    display: block;
    padding: 6px 12px;
    font-size: 0.875rem;
    color: var(--accent-blue);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
}

.pagination .page-link:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

.pagination .page-item.active .page-link {
    background-color: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.pagination .page-item.disabled .page-link {
    color: var(--text-muted);
    pointer-events: none;
    background: var(--bg-card);
}

@media (max-width: 768px) {
    .nav-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tabs li {
        flex: 0 0 auto;
    }

    .nav-tabs .nav-link {
        padding: 6px 16px;
        font-size: 0.8rem;
    }

    .pagination {
        flex-wrap: wrap;
    }
}
