@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Exact Dark Theme Variables */
    --primary: #F99A01;
    --primary-hover: #e08b00;
    --primary-soft: rgba(249, 154, 1, 0.15);

    --bg-main: #0f1115;
    --sidebar-bg: #14161C;
    /* Solid equivalent to rgba(20, 22, 28, 0.85) */
    --card-glass: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.1);

    --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-sidebar: #ffffff;
}

/* Light Theme Override Classes */
body.light-theme {
    /* Revert to Bootstrap / Original Light Theme Colors */
    --bg-main: #f8f9fc;
    --sidebar-bg: #ffffff;
    --card-glass: #ffffff;
    --border-glass: #e3e6f0;
    --text-primary: #5a5c69;
    --text-secondary: #858796;
    --text-sidebar: #5a5c69;
    --shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Sidebar - Fixed Left */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-glass);
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transition: width 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Collapsed Sidebar State */
body.sidebar-collapsed #sidebar {
    width: 80px;
}

body.sidebar-collapsed .logo-img {
    max-width: 40px;
}

body.sidebar-collapsed .user-name {
    display: none;
}

body.sidebar-collapsed .user-icon {
    margin-top: 10px;
    font-size: 1.4rem;
}

body.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 12px;
}

body.sidebar-collapsed .nav-link i {
    font-size: 1.3rem;
}

.sidebar-header {
    padding: 10px 0 30px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-glass);
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.logo-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.logo-img {
    max-width: 75%;
    /* Matches the prominent size of the GoTo logo */
    height: auto;
    object-fit: contain;
    transition: all 0.3s ease;
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.user-icon {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
    /* Limits long names inside the sidebar */
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    text-decoration: none;
    color: var(--text-secondary) !important;
    /* Exact gray/white from GoTo, overriding Bootstrap blue */
    border-radius: 12px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.nav-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    color: var(--text-secondary) !important;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

.nav-link:hover i {
    color: #ffffff !important;
}

.nav-link.active {
    background: var(--primary-soft) !important;
    border: 1px solid rgba(249, 154, 1, 0.3) !important;
    color: var(--primary) !important;
    box-shadow: 0 4px 15px -5px rgba(249, 154, 1, 0.4) !important;
}

.nav-link.active i {
    color: var(--primary) !important;
}

body.light-theme .nav-link {
    color: var(--text-sidebar);
}

body.light-theme .nav-link:hover {
    background: #f1f3f9;
}

body.light-theme .nav-link.active {
    background: #e9ecef;
    border-color: #d1d3e2;
    color: var(--primary);
}

/* Submenu Sliding Panel */
.sidebar-submenu {
    position: fixed;
    left: -320px;
    top: 0;
    width: 290px;
    height: 100vh;
    background: rgba(13, 17, 28, 0.98);
    /* Exact GoTosubmenu dark tint */
    border-right: 1px solid var(--border-glass);
    z-index: 1050;
    transition: left 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    padding: 0;
    display: none;
    flex-direction: column;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.6);
}

.sidebar-submenu.active {
    display: flex;
    left: 280px;
    /* Right next to fixed sidebar */
}

body.sidebar-collapsed .sidebar-submenu.active {
    left: 80px;
    /* Adjust if sidebar is collapsed */
}

.submenu-header {
    padding: 2.5rem 2rem 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1rem;
}

.submenu-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.btn-close-submenu {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-close-submenu:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: rotate(90deg);
}

.submenu-nav {
    flex: 1;
    padding: 0.5rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.25s;
    border: 1px solid transparent;
}

.submenu-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--primary);
    transition: transform 0.3s;
}

.submenu-link:hover {
    background: rgba(249, 154, 1, 0.08);
    color: var(--primary);
    transform: translateX(6px);
}

.submenu-link:hover i {
    transform: scale(1.2);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    padding: 20px;
    margin-left: 280px;
    /* Push content to accommodate fixed sidebar */
    transition: margin-left 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    min-height: 100vh;
    background: var(--bg-main);
    background-image: radial-gradient(circle at top right, rgba(249, 154, 1, 0.05), transparent 40%);
}

/* Card Overrides for Dark Mode */
body:not(.light-theme) .card {
    background: var(--card-glass) !important;
    border: 1px solid var(--border-glass) !important;
}

body:not(.light-theme) .card-header,
body:not(.light-theme) .card-footer {
    background: transparent !important;
    border-color: var(--border-glass) !important;
}

body.sidebar-collapsed .main-content {
    margin-left: 80px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

#sidebarToggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

#sidebarToggle:hover {
    color: var(--primary);
}

/* Table Styles Refinement */
.table {
    margin-bottom: 2rem;
    background: transparent !important;
    border-collapse: separate;
    border-spacing: 0 8px;
    /* Original spacing */
    --bs-table-bg: transparent;
    /* Override BS5 */
    --bs-table-accent-bg: transparent;
    /* Override BS5 stripes/hover */
    --bs-table-striped-bg: transparent;
    --bs-table-active-bg: transparent;
    --bs-table-hover-bg: transparent;
}

/* Clear BS5 td inherited backgrounds only for body rows, preserved for sticky headers */
body:not(.light-theme) .table tbody>tr>* {
    background-color: transparent !important;
    box-shadow: none !important;
}

.table thead th {
    position: sticky !important;
    top: 0;
    z-index: 1000 !important;
    background-color: #1a1c23 !important;
    background-clip: padding-box;
    /* Essential for sticky headers with borders */
    border-bottom: 2px solid var(--primary) !important;
    color: var(--primary) !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    padding: 1.25rem 1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5) !important;
    vertical-align: middle;
}

/* Force dark mode background on tables avoiding Bootstrap defaults */
body:not(.light-theme) .table tbody tr {
    background: rgba(255, 255, 255, 0.02) !important;
    /* Extremely dark grey glass */
    transition: all 0.2s ease;
}

body:not(.light-theme) .table-striped tbody tr:nth-of-type(odd) {
    background: rgba(255, 255, 255, 0.03) !important;
}

body:not(.light-theme) .table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    transform: translateY(-2px);
}

.table tbody td {
    padding: 1.15rem 1rem;
    border: none !important;
    vertical-align: middle;
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
}

/* Light Mode Overrides for Table */
body.light-theme .table {
    --bs-table-bg: #ffffff;
    --bs-table-accent-bg: transparent;
    --bs-table-striped-bg: rgba(0, 0, 0, 0.02);
    --bs-table-hover-bg: rgba(0, 0, 0, 0.04);
}

body.light-theme .table> :not(caption)>*>* {
    box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg) !important;
}

body.light-theme .table tbody tr,
body.light-theme .table-striped tbody tr:nth-of-type(odd) {
    background: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.light-theme .table tbody tr:hover {
    background: #f8f9fc !important;
    transform: none;
}

body.light-theme .table tbody td,
body.light-theme .table-striped tbody td {
    color: #5a5c69 !important;
}

body.light-theme .table thead th {
    background: transparent !important;
    border-bottom: 1px solid var(--border-glass) !important;
}

.table tbody tr td:first-child {
    border-radius: 12px 0 0 12px;
}

.table tbody tr td:last-child {
    border-radius: 0 12px 12px 0;
}

/* Button Styles */
.btn-primary {
    background: var(--primary) !important;
    border: none !important;
    color: white !important;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(249, 154, 1, 0.3);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(249, 154, 1, 0.4);
}

/* Premium Operations & Support Components */
body:not(.light-theme) .card-premium {
    background: #1a1c23 !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

body:not(.light-theme) .input-premium {
    background: #111318 !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

body:not(.light-theme) .input-premium:focus {
    background: #161920 !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(249, 154, 1, 0.15) !important;
    outline: none;
}

/* Premium Information Display Pattern */
.card-premium .info-item {
    color: var(--text-secondary) !important;
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.card-premium .info-item strong {
    color: var(--primary) !important;
    font-weight: 600;
    margin-right: 8px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.light-theme .card-premium .info-item strong {
    color: var(--primary);
}

/* Custom Premium Radio Buttons */
.radio-premium {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding-left: 32px;
    margin-right: 25px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
    transition: all 0.3s ease;
    min-height: 24px;
}

/* Hide native input */
.radio-premium input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

/* Custom checkmark/circle */
.radio-premium .checkmark {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: #111318 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 50%;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.radio-premium:hover input~.checkmark {
    background-color: #161920 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.radio-premium input:checked~.checkmark {
    border-color: var(--primary) !important;
    box-shadow: 0 0 8px rgba(249, 154, 1, 0.2);
}

/* Inner dot */
.radio-premium .checkmark:after {
    content: "";
    position: absolute;
    display: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.radio-premium input:checked~.checkmark:after {
    display: block;
    transform: translate(-50%, -50%) scale(1);
}

.radio-premium:hover {
    color: #ffffff;
}

.radio-premium .text {
    margin-top: 1px;
}

/* Custom Premium Checkboxes */
.checkbox-premium {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    user-select: none;
    transition: all 0.2s ease;
    min-height: 20px;
}

.checkbox-premium input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkbox-premium .checkmark {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 18px;
    width: 18px;
    background-color: #111318 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 4px;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.checkbox-premium:hover input~.checkmark {
    background-color: #161920 !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.checkbox-premium input:checked~.checkmark {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.checkbox-premium .checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-premium input:checked~.checkmark:after {
    display: block;
}

/* Text Utility Overrides for Dark Theme */
body:not(.light-theme) .text-secondary {
    color: var(--text-secondary) !important;
}

body:not(.light-theme) .text-muted {
    color: rgba(255, 255, 255, 0.4) !important;
}

body:not(.light-theme) .text-dark {
    color: #ffffff !important;
}

/* Premium Light Mode Fallbacks */
body.light-theme .card-premium {
    background: #ffffff !important;
    border: 1px solid #e3e6f0 !important;
    border-radius: 16px;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

body.light-theme .input-premium {
    background: #f8f9fc !important;
    border: 1px solid #d1d3e2 !important;
    color: #5a5c69 !important;
    border-radius: 12px;
    padding: 14px 18px;
}

body.light-theme .input-premium:focus {
    background: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(249, 154, 1, 0.25) !important;
}

/* Form Controls (Generic Fallbacks) */
.form-control,
.form-select {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border-glass) !important;
    color: white !important;
    border-radius: 12px;
    padding: 12px 15px;
}

.form-control:focus {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 0.25rem var(--primary-soft) !important;
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Mobile Responsive Adjustments */
@media (max-width: 767.98px) {

    html,
    body {
        height: 100vh;
        overflow: hidden !important;
        position: relative;
    }

    .app-container {
        height: 100vh;
        width: 100vw;
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        flex-direction: column;
    }

    #sidebarToggle {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 15px !important;
        padding-top: 80px !important;
        /* Spacing for fixed top header */
        min-height: calc(100vh - 68px);
        /* Account for bottom nav */
    }

    .top-header-fixed {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1050;
        background: var(--sidebar-bg);
        height: 64px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .light-theme .top-header-fixed {
        background: #ffffff;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }

    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Adjust page headers for mobile */
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
}


/* Ensure submenus don't break layout on small screens if triggered */
@media (max-width: 991.98px) {
    .sidebar-submenu {
        width: 100%;
        left: -100%;
    }

    .sidebar-submenu.active {
        left: 0;
    }
}