/* --- COMPONENT STYLE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    overflow-x: hidden;
    color: var(--text-main);
}

body.mobile-menu-open {
    overflow: hidden;
}

#wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text-active);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar.collapsed {
    width: 80px;
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 80px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    overflow: hidden;
}

.brand-logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.brand-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 2px;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    white-space: nowrap;
}

.sidebar-nav .nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background: #3b82f6;
    border-radius: 0 4px 4px 0;
    transition: height 0.2s;
}

.sidebar-nav .nav-item:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-item:hover::before {
    height: 70%;
}

.sidebar-nav .nav-item.active {
    background: var(--sidebar-item-active);
    color: var(--primary-light);
}

.sidebar-nav .nav-item.active::before {
    height: 70%;
}

.sidebar-nav .nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-nav .nav-item span {
    opacity: 0;
    width: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar.collapsed .user-info {
    opacity: 0;
    width: 0;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    opacity: 0.7;
}

.user-menu-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar.collapsed .user-menu-btn {
    opacity: 0;
    width: 0;
}

/* ========== TOPBAR (MOBILE) ========== */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: none !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mobile-menu-toggle {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #1e293b;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.mobile-menu-toggle:hover {
    background: #f3f4f6;
}

.topbar-brand {
    display: flex;
    align-items: center;
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
}

.topbar-brand i {
    color: #3b82f6;
}

.topbar-user-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #1e293b;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.topbar-user-btn:hover {
    background: #f3f4f6;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2.5rem;
    background-color: var(--bg-app);
    min-height: 100vh;
    transition: var(--transition);
}

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

/* ========== SIDEBAR OVERLAY (MOBILE) ========== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 998;
}

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

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1001;
        width: 280px !important;
    }

    .sidebar.mobile-active {
        transform: translateX(0);
    }

    /* Ocultar botão de colapso no mobile */
    .sidebar-toggle {
        display: none !important;
    }

    .sidebar.collapsed {
        width: 280px !important;
        transform: translateX(-100%);
    }

    .sidebar.collapsed.mobile-active {
        transform: translateX(0);
    }

    /* Garantir que textos sempre apareçam no mobile */
    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .sidebar-nav .nav-item span,
    .sidebar.collapsed .user-info,
    .sidebar.collapsed .user-menu-btn {
        opacity: 1 !important;
        width: auto !important;
    }

    .topbar {
        display: flex !important;
    }

    .main-content {
        margin-left: 0;
        margin-top: 60px;
        padding: 1rem;
    }

    .sidebar.collapsed~.main-content {
        margin-left: 0;
    }
}

/* ========== CARDS ========== */
.card {
    border: 1px solid var(--border-ui);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ========== TABLES & BADGES ========== */
.table thead th {
    background-color: var(--bg-app) !important;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem 1.5rem !important;
    border-bottom: 2px solid var(--border-ui) !important;
}

.table tbody td {
    padding: 1rem 1.5rem !important;
    color: var(--text-main);
}

.badge-status {
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.status-success,
.status-paga,
.status-recebida {
    background: rgba(16, 185, 129, 0.1) !important;
    color: #059669 !important;
}

.status-warning,
.status-aberta {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #d97706 !important;
}

.status-danger,
.status-atrasada {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #dc2626 !important;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--transition);
}

/* ========== AUTH SCREEN STATE ========== */
body.auth-screen .sidebar,
body.auth-screen #sidebar,
body.auth-screen .topbar,
body.auth-screen #topbar,
body.auth-screen .sidebar-overlay,
body.auth-screen #sidebarOverlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

body.auth-screen .main-content {
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding: 0 !important;
    background-color: #f1f5f9;
}

body.auth-screen #wrapper {
    display: block;
}

/* ========== RESPONSIVE TABLES ========== */
@media (max-width: 768px) {
    .table-responsive-stack table {
        border: 0;
    }

    .table-responsive-stack thead {
        display: none;
    }

    .table-responsive-stack tr {
        display: block;
        border-bottom: 2px solid #f1f5f9;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
        background: #fff;
    }

    .table-responsive-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 0.75rem 1.25rem !important;
        border-bottom: 1px solid #f8fafc;
        min-height: 48px;
    }

    .table-responsive-stack td:last-child {
        border-bottom: 0;
    }

    .table-responsive-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        margin-right: 1.5rem;
        color: #64748b;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        min-width: 120px;
    }

    .table-responsive-stack .ps-4,
    .table-responsive-stack .pe-4 {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    .table-responsive-stack .text-end {
        text-align: right !important;
        justify-content: flex-end;
    }

    /* Aumentar o tamanho do texto no mobile */
    body {
        font-size: 16px;
    }

    h4 {
        font-size: 1.25rem;
    }

    .btn {
        padding: 0.6rem 1.2rem;
    }
}

/* --- AVATARS & INITIALS --- */
.user-avatar {
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.avatar-sm {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* --- TRANSITIONS --- */
.hover-shadow-sm:hover {
    box-shadow: var(--shadow-sm) !important;
    transform: translateY(-2px);
}

.cursor-pointer {
    cursor: pointer;
}

.transition-all {
    transition: var(--transition);
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-app);
}

::-webkit-scrollbar-thumb {
    background: var(--border-ui);
    border-radius: 10px;
}

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