@import url('variables.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-fast);
}

ul {
    list-style: none;
}

/* Layout */
.wrapper {
    display: flex;
    flex-direction: column;
    /* Force vertical stack for horiz layout */
    min-height: 100vh;
}

/* Sidebar - Hidden for Horizontal Layout, but kept for reference if needed */
.sidebar {
    display: none;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Content Area */
.content-wrapper {
    padding: 30px;
    flex: 1;
}

/* Top Header (Branding) */
.brand-header {
    background: #fff;
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    border-bottom: 1px solid #eee;
}

.brand-logo {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    color: var(--primary-color);
    font-weight: 700;
    display: flex;
    flex-direction: column;
}

.brand-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
    font-family: var(--font-body);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

/* Horizontal Navbar */
.navbar {
    background: linear-gradient(to right, var(--primary-color), var(--primary-light));
    color: #fff;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 30px;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 5px;
    height: 100%;
    width: 100%;
}

.nav-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-link {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    padding: 0 15px;
    font-size: 0.9rem;
    font-weight: 500;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    cursor: pointer;
    white-space: nowrap;
}

.nav-link:hover,
.nav-item:hover .nav-link {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Dropdowns */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    width: max-content;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border-radius: 0 0 8px 8px;
    padding: 10px 0;
    margin-top: 0;
    /* Ensure no margin spacing */

    /* Smooth Transition Setup */
    display: block;
    visibility: hidden;
    opacity: 0;
    transform: translateY(5px);
    /* Reduced movement */
    transition: all 0.2s ease-in-out;

    z-index: 9999;
}

/* Invisible Bridge to prevent gap closing - LARGER BRIDGE */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -30px;
    /* Extend further up */
    left: 0;
    width: 100%;
    height: 30px;
    /* Cover the gap + overlap nav item */
    background: transparent;
}

.nav-item:hover .dropdown-menu,
.dropdown-menu:hover {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    justify-content: flex-start !important;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.1s;
    position: relative;
    gap: 12px !important;
}

.dropdown-item:hover {
    background: #f0f0f0;
    color: var(--primary-color);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
}

.dropdown-item i.fa-chevron-right {
    font-size: 0.8em;
    width: auto !important;
    color: #ccc !important;
    margin-left: auto !important;
}

/* Level 3 Nesting */
.submenu-level-2 {
    position: absolute;
    left: 100%;
    top: 0;
    /* Align perfectly with top */
    margin-top: -5px;
    /* Slight upward nudge for padding alignment */
    margin-left: -1px;
    /* Overlap slightly to kill gap */

    min-width: 240px;
    background: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 10px 0;

    /* Smooth Transition */
    display: block;
    visibility: hidden;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease;

    z-index: 10000;
}

/* Bridge for Submenu - ROBUST BRIDGE */
.submenu-level-2::before {
    content: '';
    position: absolute;
    top: -20px;
    /* Extend up */
    right: 100%;
    /* Bridge gap to left */
    width: 25px;
    /* Wide enough to catch diagonal movement */
    height: 140%;
    /* Very tall */
    background: transparent;
}


.has-submenu:hover>.submenu-level-2 {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
}

/* Level 3 Nesting (Same logic as Level 2) */
.submenu-level-3 {
    position: absolute;
    left: 100%;
    top: 0;
    margin-top: -5px;
    margin-left: -1px;
    min-width: 240px;
    background: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 10px 0;
    display: block;
    visibility: hidden;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s ease;
    z-index: 10000;
}

.submenu-level-3::before {
    content: '';
    position: absolute;
    top: -20px;
    right: 100%;
    width: 25px;
    height: 140%;
    background: transparent;
}

.has-submenu:hover>.submenu-level-3 {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
}

/* Components: Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    transition: var(--transition-fast);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--secondary-color);
    color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--secondary-hover);
}

/* Responsive Utilities */
@media (max-width: 1366px) {
    .content-wrapper {
        padding: 20px;
    }
}

/* Dropdown Divider */
.dropdown-divider {
    height: 0;
    margin: 0.5rem 0;
    overflow: hidden;
    border-top: 1px solid #e9ecef;
}

/* Header Right Area */
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

#live-datetime {
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.2;
}

#current-time {
    display: block;
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: 700;
}

/* Mobile Menu Toggle - Force Hide on Desktop */
.mobile-menu-toggle {
    display: none !important;
}

/* Icon Colors - Multi-color Theme & Propagation */
.nav-item:nth-child(1) .nav-link i,
.nav-item:nth-child(1) .dropdown-item i {
    color: #4361ee !important;
}

.nav-item:nth-child(2) .nav-link i,
.nav-item:nth-child(2) .dropdown-item i {
    color: #7209b7 !important;
}

.nav-item:nth-child(3) .nav-link i,
.nav-item:nth-child(3) .dropdown-item i {
    color: #f72585 !important;
}

.nav-item:nth-child(4) .nav-link i,
.nav-item:nth-child(4) .dropdown-item i {
    color: #4cc9f0 !important;
}

.nav-item:nth-child(5) .nav-link i,
.nav-item:nth-child(5) .dropdown-item i {
    color: #ff9e00 !important;
}

.nav-item:nth-child(6) .nav-link i,
.nav-item:nth-child(6) .dropdown-item i {
    color: #2ec4b6 !important;
}

.nav-item:nth-child(7) .nav-link i,
.nav-item:nth-child(7) .dropdown-item i {
    color: #e63946 !important;
}

.nav-item:nth-child(8) .nav-link i,
.nav-item:nth-child(8) .dropdown-item i {
    color: #9d4edd !important;
}

.nav-item:nth-child(9) .nav-link i,
.nav-item:nth-child(9) .dropdown-item i {
    color: #38b000 !important;
}

.nav-item:nth-child(10) .nav-link i,
.nav-item:nth-child(10) .dropdown-item i {
    color: #5aa9e6 !important;
}

.nav-item:nth-child(11) .nav-link i,
.nav-item:nth-child(11) .dropdown-item i {
    color: #607d8b !important;
}

@media (max-width: 992px) {
    .brand-header {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 20px;
        gap: 15px;
    }

    .header-right {
        margin-left: auto;
        gap: 15px;
    }

    /* Force visibility of hamburger on mobile */
    .mobile-menu-toggle {
        display: block !important;
        background: none;
        border: none;
        font-size: 1.8rem;
        color: var(--primary-color);
        cursor: pointer;
        padding: 5px;
    }

    /* Mobile Navbar Container */
    .navbar {
        height: auto !important;
        padding: 0;
        background: #fff !important;
        /* Force white background for vertical menu */
        border-bottom: 1px solid #ddd;
    }

    /* Mobile Menu List */
    .nav-menu {
        flex-direction: column !important;
        display: none;
        /* Hidden by default */
        width: 100%;
        background: #fff;
    }

    /* Active State for Mobile Menu */
    .nav-menu.active {
        display: flex !important;
    }

    .nav-item {
        width: 100%;
        border-bottom: 1px solid #f0f0f0;
        height: auto;
    }

    .nav-link {
        color: #333 !important;
        /* Dark text for mobile white bg */
        padding: 15px 20px;
        width: 100%;
        justify-content: space-between;
    }

    .nav-link:hover {
        background: #f8f9fa;
        color: var(--primary-color);
    }

    .nav-link i.fa-caret-down {
        transform: rotate(-90deg);
        transition: transform 0.2s;
    }

    /* Mobile Dropdowns */
    .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
        background: #f8f9fa;
        display: none;
        padding-left: 20px;
        /* Indent */
    }

    /* Show dropdown when parent is active */
    .nav-item.active>.dropdown-menu {
        display: block;
    }

    .nav-item.active .nav-link i.fa-caret-down {
        transform: rotate(0deg);
    }

    /* Level 3 on Mobile */
    .submenu-level-2 {
        position: static;
        width: 100%;
        box-shadow: none;
        padding-left: 20px;
        background: #eee;
        display: none;
    }

    .has-submenu:hover>.submenu-level-2 {
        display: none !important;
        /* Disable hover */
    }

    .has-submenu.active>.submenu-level-2 {
        display: block !important;
    }

    /* Level 3 Mobile */
    .submenu-level-3 {
        position: static;
        width: 100%;
        box-shadow: none;
        padding-left: 20px;
        background: #e9ecef; /* Slightly darker than level 2 */
        display: none;
    }

    .has-submenu:hover>.submenu-level-3 {
        display: none !important;
    }

    .has-submenu.active>.submenu-level-3 {
        display: block !important;
    }

    .user-profile {
        display: none;
        /* Hide profile name on mobile header to save space */
    }
}

@media (min-width: 993px) {
    .nav-menu {
        display: flex !important;
    }


    /* Global Form Control Size Fix */
    .form-control,
    .custom-select,
    select.form-control,
    input.form-control,
    textarea.form-control {
        font-size: 0.85rem !important;
        /* Reduce from 1rem */
        height: auto !important;
        /* Allow auto height calculation */
        padding: 0.4rem 0.75rem !important;
        /* Adjust padding */
        line-height: 1.5 !important;
        background-color: #fff !important;
        color: #333 !important;
    }

    /* Ensure dropdown options are also readable */
    option {
        font-size: 0.85rem !important;
        background-color: #fff !important;
        color: #333 !important;
    }

    /* Fix Labels */
    label {
        font-size: 0.85rem !important;
        margin-bottom: 0.3rem !important;
        font-weight: 500;
    }

    /* Fix Input Groups */
    .input-group-text {
        font-size: 0.9rem !important;
        padding: 0.4rem 0.75rem !important;
    }

    /* Fix Table text if needed */
    .table td,
    .table th {
        font-size: 0.9rem !important;
        vertical-align: middle !important;
    }
}