/* ============================================
   GESTORELO - FINANCIAL APP THEME
   ============================================ */

/* Variables */
:root {
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #1e40af;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 64px;
    --top-header-height: 60px;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --primary-color: #1e40af;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --info-color: #0891b2;
    --light-color: #f8fafc;
    --dark-color: #1e293b;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ============================================
   SIDEBAR (Authenticated Layout)
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand:hover {
    color: #ffffff;
    text-decoration: none;
}

.sidebar-brand i {
    color: var(--primary-light);
    font-size: 1.5rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav .nav-label {
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: #e2e8f0;
    background: var(--sidebar-hover);
    text-decoration: none;
}

.sidebar-link.active {
    color: #ffffff;
    background: rgba(30, 64, 175, 0.2);
    border-left-color: var(--primary-light);
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar submenu (Gastos dropdown) */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.sidebar-submenu.show {
    max-height: 200px;
}

.sidebar-submenu .sidebar-link {
    padding-left: 3.25rem;
    font-size: 0.8125rem;
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
}

.sidebar-toggle-btn .chevron {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.sidebar-toggle-btn[aria-expanded="true"] .chevron {
    transform: rotate(90deg);
}

/* Sidebar footer (user section) */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.75rem 1.5rem;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.6875rem;
    color: #64748b;
}

/* ============================================
   TOP HEADER (Authenticated Layout)
   ============================================ */

.top-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--top-header-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
    transition: left 0.3s ease;
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: color 0.15s ease;
}

.sidebar-mobile-toggle:hover {
    color: var(--primary-color);
}

/* Desktop sidebar collapsed state - icon only */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

/* Esconde textos e labels explicitamente (não depende de overflow) */
body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .sidebar-link > span,
body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .sidebar-brand > span,
body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .chevron {
    display: none;
}

body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .nav-label {
    visibility: hidden;
    height: 0;
    padding: 0;
    margin: 0;
}

body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .sidebar-user-info {
    display: none;
}

/* Centraliza ícones quando colapsado */
body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .sidebar-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .sidebar-footer {
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .sidebar:not(.sidebar-hovered) .sidebar-user {
    justify-content: center;
}

/* Sidebar expandida no hover (classe adicionada via JS) */
body.sidebar-collapsed .sidebar.sidebar-hovered {
    width: var(--sidebar-width);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.35);
    z-index: 1045;
}

body.sidebar-collapsed .sidebar.sidebar-hovered .sidebar-link {
    gap: calc(0.75rem + 10px);
}

body.sidebar-collapsed .top-header {
    left: var(--sidebar-collapsed-width);
}

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

body.sidebar-collapsed .app-footer {
    margin-left: var(--sidebar-collapsed-width);
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* User dropdown in top header */
.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-dropdown-toggle:hover {
    background: var(--body-bg);
    border-color: var(--primary-light);
}

/* ============================================
   MAIN CONTENT (Authenticated Layout)
   ============================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--top-header-height);
    flex: 1;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.main-content > .content-wrapper {
    padding: 1.5rem;
    max-width: 2500px;
}

/* Minimal footer for authenticated */
.app-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-left: var(--sidebar-width);
    background: var(--card-bg);
    transition: margin-left 0.3s ease;
}

/* ============================================
   VISITOR LAYOUT (Non-authenticated)
   ============================================ */

.visitor-layout body {
    display: flex;
    flex-direction: column;
}

.visitor-layout main {
    flex: 1;
}

/* Visitor Navbar */
.visitor-navbar {
    background: var(--sidebar-bg) !important;
    padding: 0.75rem 0;
}

.visitor-navbar .navbar-brand {
    font-size: 1.35rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.visitor-navbar .navbar-brand i {
    color: var(--primary-light);
}

.visitor-navbar .nav-link {
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem !important;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.visitor-navbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Visitor Footer */
.visitor-footer {
    background: var(--sidebar-bg);
    color: #94a3b8;
    margin-top: auto;
}

.visitor-footer h5 {
    color: #e2e8f0;
    font-size: 0.9375rem;
}

.visitor-footer a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.15s ease;
}

.visitor-footer a:hover {
    color: var(--primary-light);
}

.visitor-footer-bottom {
    background: rgba(0, 0, 0, 0.2);
    color: #64748b;
    font-size: 0.8125rem;
}

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

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.875rem 1.25rem;
}

/* KPI Cards with left border accent */
.card.border-primary { border: 1px solid var(--border-color); border-left: 4px solid var(--primary-color) !important; }
.card.border-success { border: 1px solid var(--border-color); border-left: 4px solid var(--success-color) !important; }
.card.border-info { border: 1px solid var(--border-color); border-left: 4px solid var(--info-color) !important; }
.card.border-secondary { border: 1px solid var(--border-color); border-left: 4px solid var(--secondary-color) !important; }
.card.border-dark { border: 1px solid var(--border-color); border-left: 4px solid var(--dark-color) !important; }
.card.border-warning { border: 1px solid var(--border-color); border-left: 4px solid var(--warning-color) !important; }

/* Dashboard Cards */
.dashboard-card {
    border-left: 4px solid var(--primary-color);
}

.dashboard-card:hover {
    border-left-width: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dashboard-card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.25rem;
}

/* Stats */
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* ============================================
   TABLES
   ============================================ */

.table {
    border-radius: 10px;
    overflow: hidden;
    font-size: 0.875rem;
}

.table thead {
    background-color: var(--body-bg);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table thead th {
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table-hover tbody tr:hover {
    background-color: rgba(30, 64, 175, 0.03);
}

/* ============================================
   FORMS
   ============================================ */

.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
}

.btn:hover {
    transform: none;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-success {
    background: var(--success-color);
    border-color: var(--success-color);
}

/* ============================================
   BADGES
   ============================================ */

.badge {
    padding: 0.35em 0.65em;
    font-weight: 500;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    border-radius: 10px;
    border: none;
    font-size: 0.875rem;
}

/* ============================================
   HERO SECTION (Landing Page)
   ============================================ */

.hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #1e40af 100%);
}

/* ============================================
   FILE UPLOAD
   ============================================ */

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    padding: 3rem;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-light);
    background-color: rgba(59, 130, 246, 0.03);
}

.upload-area.drag-over {
    border-color: var(--success-color);
    background-color: rgba(5, 150, 105, 0.05);
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress {
    height: 0.5rem;
    border-radius: 1rem;
    background: var(--body-bg);
}

.progress-bar {
    transition: width 0.6s ease;
    border-radius: 1rem;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* ============================================
   CONTAINER OVERRIDE
   ============================================ */

.container-fluid {
    max-width: 2500px;
}

/* ============================================
   ANIMATIONS (minimal)
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1035;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .top-header {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .app-footer {
        margin-left: 0;
    }

    .page-title {
        font-size: 0.95rem;
    }
}

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .main-content > .content-wrapper {
        padding: 1rem;
    }
}

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

.text-primary-custom {
    color: var(--primary-color) !important;
}

.bg-primary-custom {
    background-color: var(--primary-color) !important;
}

.border-primary-custom {
    border-color: var(--primary-color) !important;
}

.bg-primary {
    background-color: rgb(30, 58, 95) !important;
}

/* Scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 2px;
}

/* ============================================
   PWA INSTALL PROMPT
   ============================================ */

.pwa-install-prompt {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .sidebar,
    .top-header,
    .app-footer,
    .btn,
    .no-print {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }

    body {
        background: white;
        color: black;
    }
}
