/* ============================================
   Billing SaaS - Sidebar Layout Styles
   ============================================ */

/* Root Variables */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #000000;
    --sidebar-accent: #648dcb;
    --sidebar-hover: #648dcb;
    --sidebar-text: #ffffff;
    --topbar-height: 72px;
    --transition-speed: 0.25s;
}

/* Body - Prevent Horizontal Scroll */
body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* App Layout Container */
.app-layout {
    display: flex;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    background-color: #f4f5f7;
    position: relative;
}

/* ============================================
   SIDEBAR STYLES
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: transform var(--transition-speed) ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Sidebar close (mobile, inside panel) */
.sidebar-close {
    display: none;
}

/* Sidebar Logo */
.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.sidebar-logo a {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sidebar-logo-img {
    max-width: 120px;
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.sidebar-logo a i {
    color: var(--sidebar-accent);
    font-size: 28px;
}

.sidebar-logo a:hover {
    color: var(--sidebar-accent);
}

.sidebar-logo a:hover .sidebar-logo-img {
    opacity: 0.9;
    transition: opacity 0.25s ease;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu-item {
    margin: 0;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.25s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.sidebar-menu-link:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
    border-left-color: var(--sidebar-hover);
    padding-left: 25px;
}

.sidebar-menu-link.active {
    background-color: var(--sidebar-hover);
    color: #ffffff;
    border-left-color: var(--sidebar-hover);
    font-weight: 600;
}

.sidebar-menu-link i {
    width: 24px;
    margin-right: 12px;
    font-size: 18px;
    text-align: center;
}

.sidebar-menu-link span {
    flex: 1;
}

/* Menu Group Header */
.menu-group-header {
    padding: 15px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    margin-top: 10px;
}

.menu-group-header:first-child {
    margin-top: 0;
}

/* Submenu Items */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.3);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease;
}

.sidebar-submenu.expanded {
    max-height: 500px;
}

.sidebar-submenu-item {
    margin: 0;
}

.sidebar-submenu-link {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 50px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.25s ease;
    font-size: 14px;
}

.sidebar-submenu-link:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
    padding-left: 55px;
}

.sidebar-submenu-link.active {
    color: #ffffff;
    background-color: var(--sidebar-hover);
}

.sidebar-submenu-link i {
    width: 20px;
    margin-right: 10px;
    font-size: 14px;
}

/* Menu Toggle Button (for collapsible groups) */
.menu-toggle {
    margin-left: auto;
    transition: transform var(--transition-speed) ease;
}

.menu-toggle.rotated {
    transform: rotate(180deg);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed) ease, width var(--transition-speed) ease;
    overflow-x: hidden;
}

/* ============================================
   TOPBAR STYLES
   ============================================ */

.topbar {
    height: var(--topbar-height);
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 500px;
}

.topbar-search {
    position: relative;
    width: 100%;
}

.topbar-search input {
    width: 100%;
    padding: 8px 15px 8px 40px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    transition: all var(--transition-speed) ease;
}

.topbar-search input:focus {
    outline: none;
    border-color: var(--sidebar-accent);
    box-shadow: 0 0 0 3px rgba(255, 240, 0, 0.1);
}

.topbar-search i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar-icon {
    position: relative;
    color: #666;
    font-size: 20px;
    cursor: pointer;
    transition: color var(--transition-speed) ease;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-icon:hover {
    color: var(--sidebar-accent);
    background-color: rgba(255, 240, 0, 0.1);
}

.topbar-icon .badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #ff4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* User Profile Dropdown */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 20px;
    transition: background-color var(--transition-speed) ease;
}

.user-profile:hover {
    background-color: #f5f5f5;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sidebar-accent) 0%, #ffd700 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: bold;
    font-size: 14px;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}

.user-role {
    font-size: 12px;
    color: #999;
    line-height: 1.2;
}

/* ============================================
   CONTENT WRAPPER
   ============================================ */

.content-wrapper {
    flex: 1;
    width: 100%;
    max-width: 100%;
    padding: 30px;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Breadcrumb */
.breadcrumb-nav {
    margin-bottom: 20px;
    padding: 0;
    background: transparent;
}

.breadcrumb-nav .breadcrumb-item a {
    color: #666;
    text-decoration: none;
}

.breadcrumb-nav .breadcrumb-item a:hover {
    color: var(--sidebar-accent);
}

.breadcrumb-nav .breadcrumb-item.active {
    color: #333;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* Mobile Hamburger Button */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all var(--transition-speed) ease;
}

.sidebar-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-accent);
}

/* Tablet and Mobile */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        height: 100dvh;
        max-height: 100dvh;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    .sidebar.show,
    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .sidebar-toggle {
        display: flex;
    }

    /* Hide fixed hamburger while drawer is open — use in-sidebar close instead */
    body.sidebar-mobile-open .sidebar-toggle {
        visibility: hidden;
        pointer-events: none;
        opacity: 0;
    }

    .sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 2;
        width: 36px;
        height: 36px;
        padding: 0;
        border: none;
        border-radius: 6px;
        background: rgba(255, 255, 255, 0.12);
        color: var(--sidebar-text);
        font-size: 1.15rem;
        cursor: pointer;
        transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
    }

    .sidebar-close:hover {
        background: rgba(255, 255, 255, 0.2);
        color: var(--sidebar-accent);
    }

    .sidebar-logo {
        padding: 16px 48px 16px 16px;
        text-align: left;
    }

    .sidebar-logo a {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sidebar-logo-img {
        max-width: 100px;
        max-height: 40px;
    }

    .sidebar-logo a span {
        font-size: 14px;
        line-height: 1.3;
        text-align: left;
    }

    .sidebar-menu {
        padding-bottom: 50%;
    }

    .topbar {
        padding-left: 60px;
    }

    .content-wrapper {
        padding: 20px;
        width: 100%;
        max-width: 100%;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .topbar-left {
        max-width: 200px;
    }

    .topbar-search input {
        font-size: 12px;
        padding: 6px 12px 6px 35px;
    }

    .user-info {
        display: none;
    }

    .content-wrapper {
        padding: 15px;
        width: 100%;
        max-width: 100%;
    }

    .topbar {
        padding: 0 15px 0 60px;
    }
}

/* ============================================
   DASHBOARD CARDS
   ============================================ */

.dashboard-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    height: 100%;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Responsive Cards */
@media (max-width: 768px) {
    .dashboard-card {
        padding: 20px;
        margin-bottom: 15px;
    }
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.12);
}

.dashboard-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, var(--sidebar-accent) 0%, #ffd700 100%);
    color: #000;
}

.dashboard-card-title {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-card-value {
    font-size: 32px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.dashboard-card-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dashboard-card-change.positive {
    color: #28a745;
}

.dashboard-card-change.negative {
    color: #dc3545;
}

/* ============================================
   TABLE STYLING
   ============================================ */

.table-modern {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 100%;
    table-layout: auto;
}

/* Responsive Tables */
@media (max-width: 768px) {
    .table-modern {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-modern thead,
    .table-modern tbody,
    .table-modern tr,
    .table-modern td,
    .table-modern th {
        display: block;
    }

    .table-modern thead {
        display: none;
    }

    .table-modern tr {
        margin-bottom: 15px;
        border: 1px solid #e0e0e0;
        border-radius: 5px;
        padding: 10px;
    }

    .table-modern td {
        text-align: right;
        padding: 10px;
        border-bottom: 1px solid #f0f0f0;
    }

    .table-modern td:before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        color: #666;
    }
}

.table-modern thead {
    background-color: #f8f9fa;
}

.table-modern thead th {
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: #666;
    padding: 15px;
}

.table-modern tbody tr {
    transition: background-color var(--transition-speed) ease;
}

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

.table-modern tbody td {
    padding: 15px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

/* ============================================
   PAGINATION STYLING
   ============================================ */

.pagination-modern {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.pagination-modern .page-item .page-link {
    border: 1px solid #e0e0e0;
    color: #666;
    padding: 8px 15px;
    border-radius: 5px;
    transition: all var(--transition-speed) ease;
}

.pagination-modern .page-item .page-link:hover {
    background-color: var(--sidebar-accent);
    color: #000;
    border-color: var(--sidebar-accent);
}

.pagination-modern .page-item.active .page-link {
    background-color: var(--sidebar-accent);
    color: #000;
    border-color: var(--sidebar-accent);
    font-weight: 600;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-accent {
    color: var(--sidebar-accent) !important;
}

.bg-accent {
    background-color: var(--sidebar-accent) !important;
}

.border-accent {
    border-color: var(--sidebar-accent) !important;
}

/* ============================================
   ADDITIONAL RESPONSIVE FIXES
   ============================================ */

/* Ensure all containers respect max-width */
.container-fluid,
.container {
    max-width: 100%;
    overflow-x: hidden;
}

/* Fix for cards and containers */
.card {
    max-width: 100%;
    box-sizing: border-box;
}

/* Responsive images */
img {
    max-width: 100%;
    height: auto;
}

/* Fix for forms */
.form-control,
.form-select {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure tables don't break layout */
.table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
}

/* Responsive wrapper for all content */
.row {
    margin-left: 0;
    margin-right: 0;
}

.row > * {
    padding-left: 15px;
    padding-right: 15px;
}

@media (max-width: 768px) {
    .row > * {
        padding-left: 10px;
        padding-right: 10px;
    }
}

