/**
 * CHM Sistema - Estilos Principais
 * @author ch-mestriner (https://ch-mestriner.com.br)
 * @date 03/01/2026 06:04
 * @version 2.14.0
 */

:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --secondary: #0f3460;
    --accent: #e94560;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #212529;
    --sidebar-width: 220px;
    --header-height: 150px;
    --border-radius: 8px;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f5f7fb;
    color: var(--dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary);
    color: #fff;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.sidebar-user {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

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

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-nav {
    list-style: none;
    padding: 15px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.nav-header {
    padding: 15px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
}

.nav-item .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.nav-item .nav-link:hover,
.nav-item .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--accent);
}

.nav-item .nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    height: auto;
    overflow: visible;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    padding: 0;
}

.page-content {
    padding: 20px;
    padding-top: 20px;
    margin-top: 0;
    flex: 1;
    overflow: auto;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 15px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Stats Cards */
.stat-card {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
}

.stat-icon.primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.stat-icon.success { background: linear-gradient(135deg, #28a745, #20c997); }
.stat-icon.warning { background: linear-gradient(135deg, #ffc107, #fd7e14); }
.stat-icon.danger { background: linear-gradient(135deg, #dc3545, #e83e8c); }
.stat-icon.info { background: linear-gradient(135deg, #17a2b8, #6f42c1); }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.stat-info p {
    margin: 5px 0 0;
    color: #6c757d;
    font-size: 14px;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6c757d;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--border-radius);
    padding: 10px 15px;
    border: 1px solid #dee2e6;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.form-label {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 5px;
}

/* Buttons */
.btn {
    border-radius: var(--border-radius);
    padding: 10px 20px;
    font-weight: 500;
    transition: var(--transition);
}

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

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

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 12px;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: var(--border-radius);
    color: #fff;
    font-weight: 500;
    z-index: 9999;
    transform: translateX(120%);
    transition: var(--transition);
}

.toast-notification.show {
    transform: translateX(0);
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: var(--dark); }
.toast-info { background: var(--info); }

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    backdrop-filter: blur(2px);
}

/* Mobile Responsive - Menu Hamburger */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 25px rgba(0,0,0,0.3);
        visibility: hidden;
    }
    
    body.sidebar-open .sidebar {
        visibility: visible;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
    
    /* Sidebar Mobile - mais bonita */
    .sidebar-nav .nav-link {
        padding: 14px 20px;
        font-size: 15px;
    }
    
    .sidebar-nav .nav-link i {
        font-size: 20px;
    }
    
    .nav-header {
        padding: 18px 20px 10px;
        font-size: 12px;
    }
    
    /* User info no sidebar mobile */
    .sidebar-user {
        padding: 15px 20px;
    }
    

    .page-content {
        padding: 15px;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .stat-info h3 {
        font-size: 24px;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h4 {
    margin-bottom: 10px;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Print Styles */
@media print {
    .sidebar, .topbar, .no-print {
        display: none !important;
    }

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

    .page-content {
        padding: 0;
    }
}

/* Quick Actions FAB */
.fab-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.fab:hover {
    transform: scale(1.1);
}

/* Calendar Colors */
.fc-event {
    border: none !important;
    border-radius: 4px !important;
}

/* Status Colors */
.status-pending { color: var(--warning); }
.status-confirmed { color: var(--info); }
.status-in_progress { color: var(--primary); }
.status-completed { color: var(--success); }
.status-cancelled { color: var(--danger); }

/* ============================================
   MOBILE FIX CHM - Responsividade Completa
   @author ch-mestriner (https://ch-mestriner.com.br)
   @date 24/12/2025
   ============================================ */

/* Mobile First - Até 768px */
@media (max-width: 768px) {
    /* Sidebar Mobile */
    .sidebar {
        width: 100%;
        max-width: 280px;
    }
    
    /* Page Content Mobile - COMPACTO */
    .page-content {
        padding: 10px !important;
        flex: 1;
    }
    
    /* DASHBOARD CARDS COMPACTOS */
    .card {
        margin-bottom: 8px !important;
        border-radius: 10px;
    }
    
    .card-body {
        padding: 12px !important;
    }
    
    .card-header {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    /* Stat Cards ULTRA COMPACTOS */
    .stat-card {
        padding: 10px 12px !important;
        gap: 10px !important;
        margin-bottom: 8px !important;
    }
    
    .stat-card h2,
    .stat-card h3,
    .stat-info h3 {
        font-size: 1.3rem !important;
        margin: 0 !important;
    }
    
    .stat-info p {
        font-size: 12px !important;
        margin: 2px 0 0 !important;
    }
    
    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 18px !important;
        border-radius: 10px !important;
    }
    
    /* Row gaps reduzidos */
    .row {
        --bs-gutter-y: 0.5rem;
        --bs-gutter-x: 0.5rem;
    }
    
    .row.g-3, .row.g-4 {
        --bs-gutter-y: 0.5rem !important;
        --bs-gutter-x: 0.5rem !important;
    }
    
    /* Cards em colunas no mobile */
    .row > [class*="col-md-"],
    .row > [class*="col-lg-"] {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0;
        padding: 4px !important;
    }
    
    /* Cards de resumo financeiro - 2 por linha */
    .row > .col-md-3,
    .row > .col-lg-3 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    /* Botões Touch-Friendly */
    .btn {
        min-height: 42px;
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 13px;
    }
    
    /* Tabelas responsivas */
    .table-responsive {
        font-size: 12px;
    }
    
    .table td, .table th {
        padding: 6px 8px;
        white-space: nowrap;
    }
    
    /* Forms Mobile */
    .form-control, .form-select {
        min-height: 42px;
        font-size: 16px;
    }
    
    /* FAB Mobile */
    .fab-container {
        bottom: 80px; /* Acima do footer */
        right: 12px;
    }
    
    .fab {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* Títulos Mobile */
    h1, .h1 { font-size: 1.5rem !important; }
    h2, .h2 { font-size: 1.25rem !important; }
    h3, .h3 { font-size: 1.1rem !important; }
    
    /* Ocultar breadcrumb no mobile */
    .breadcrumb {
        display: none !important;
    }
    
    /* Ocultar colunas secundárias em tabelas */
    .table .hide-mobile {
        display: none !important;
    }
    
    /* Mobile Only */
    .mobile-only {
        display: block !important;
    }
    
    .desktop-only {
        display: none !important;
    }
}

/* Tablet - 769px a 991px */
@media (min-width: 769px) and (max-width: 991px) {
    .sidebar {
        width: 220px;
    }
    
    .mobile-only {
        display: none !important;
    }
    
    /* Cards em 2 colunas no tablet */
    .row > [class*="col-lg-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Desktop - 992px+ */
@media (min-width: 992px) {
    .sidebar {
        left: 0 !important;
    }
    
    .mobile-only {
        display: none !important;
    }
    
    .desktop-only {
        display: block !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
}

/* Ultra pequeno - 360px */
@media (max-width: 360px) {
    .sidebar {
        max-width: 100%;
    }
    
    .sidebar-logo {
        max-width: 140px;
        height: 56px;
    }
    
    .stat-card h2 {
        font-size: 1.25rem !important;
    }
    
    .btn {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .page-content {
        padding: 10px !important;
    }
}

/* Utilitários de visibilidade */
.mobile-only { display: none; }
.desktop-only { display: block; }


/* ============================================
   MOBILE-FIRST BASE SCREEN
   @author ch-mestriner (https://ch-mestriner.com.br)
   @date 29/12/2025
   ============================================ */


/* Page content mobile - BRANCO LIMPO */
@media (max-width: 991.98px) {
    .page-content {
        background: #fff !important;
        min-height: calc(100vh - 56px);
        padding: 0 !important;
    }
    
    .hide-on-mobile {
        display: none !important;
    }
    
    /* Esconder FAB no mobile */
    .fab-container {
        display: none !important;
    }
    
    /* Título Dashboard e data lado a lado */
    .container-fluid > .d-flex.justify-content-between {
        justify-content: space-between !important;
        flex-direction: row;
        align-items: center;
        padding: 12px 0;
    }
    
    .container-fluid > .d-flex.justify-content-between h4 {
        font-size: 1.25rem;
        font-weight: 500;
        color: #6c757d;
        margin: 0;
    }
    
    .container-fluid > .d-flex.justify-content-between .text-muted {
        color: #6c757d !important;
        font-size: 0.9rem;
    }
}

/* === DESKTOP (992px+) === */
@media (min-width: 992px) {
    .sidebar-header {
        display: none !important;
    }
    
    .sidebar-user {
        padding-top: 20px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding-bottom: 15px;
        margin-bottom: 10px;
    }
    
    .sidebar {
        width: 220px;
    }
    
    .desktop-only {
        display: flex !important;
    }
}

/* Sidebar toggle */
.sidebar-header .sidebar-toggle {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px;
    border-radius: 8px;
}

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

/* App Footer - Todas as telas */
.app-footer {
    background: var(--primary);
    color: rgba(255,255,255,0.8);
    text-align: center;
    padding: 20px 16px;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.app-footer p {
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* Mobile/Tablet: footer visível */
@media (max-width: 991.98px) {
    .app-footer {
        padding: 16px 12px;
        margin-top: 20px;
    }
    
    .app-footer p {
        font-size: 12px;
    }
}

/* ============================================
   GLOBAL TOP HEADER - ÚNICA FONTE
   @author ch-mestriner (https://ch-mestriner.com.br)
   @date 03/01/2026
   ============================================ */

.top-header {
    position: sticky;
    top: 0;
    height: 120px;
    min-height: 120px;
    max-height: 120px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
    z-index: 10;
}

.top-header-logo {
    display: flex;
    align-items: center;
    height: 100px;
}

.top-header-logo img {
    width: 160px;
    height: auto;
    max-height: 90px;
    object-fit: contain;
}

.top-header-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #dc3545;
    color: #fff;
    border: 2px solid #dc3545;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.top-header-logout:hover {
    background: #ffffff;
    color: #dc3545;
    border-color: #dc3545;
    text-decoration: none;
}

.top-header-logout i {
    font-size: 16px;
}

/* Botão Hamburguer - escondido por padrão (só aparece mobile/tablet) */
.top-header-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 26px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.top-header-hamburger:hover {
    background: var(--primary-light);
    transform: scale(1.05);
}

.top-header-hamburger:active {
    transform: scale(0.95);
}

/* ============================================
   MOBILE/TABLET FINAL (max-width: 991px)
   Header 45px, Logo 60px esquerda, Hamburguer direita visível, Sair OCULTO
   Desktop INTOCADO
   @author ch-mestriner
   @date 03/01/2026 06:04
   ============================================ */
@media (max-width: 991.98px) {
    /* Main content ocupa 100% */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Header mobile/tablet */
    .top-header {
        position: sticky !important;
        top: 0 !important;
        padding: 6px 12px !important;
        height: 45px !important;
        min-height: 45px !important;
        max-height: 45px !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: #fff !important;
        border-bottom: 1px solid #e0e0e0 !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
        z-index: 100 !important;
    }
    
    /* Logo ESQUERDA */
    .top-header-logo {
        order: 1 !important;
        height: 36px !important;
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }
    
    .top-header-logo img {
        width: 60px !important;
        height: 24px !important;
        max-width: 60px !important;
        max-height: 24px !important;
        min-width: unset !important;
        min-height: unset !important;
        object-fit: contain !important;
    }
    
    /* ESCONDER botão Sair COMPLETAMENTE */
    .top-header-logout {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
    }
    
    /* Hamburguer DIREITA */
    .top-header-hamburger {
        order: 3 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 38px !important;
        height: 38px !important;
        background: #1a1a2e !important;
        color: #fff !important;
        border: none !important;
        border-radius: 6px !important;
        font-size: 0 !important;
        line-height: 0 !important;
        cursor: pointer !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.2) !important;
        flex-shrink: 0 !important;
        transition: all 0.2s ease !important;
        position: relative !important;
    }
    
    .top-header-hamburger:hover {
        background: #16213e !important;
    }
    
    .top-header-hamburger:active {
        transform: scale(0.92) !important;
    }
    
    .top-header-hamburger span {
        display: block !important;
        width: 20px !important;
        height: 2px !important;
        background: #fff !important;
        position: relative !important;
        border-radius: 1px !important;
    }
    
    .top-header-hamburger span::before,
    .top-header-hamburger span::after {
        content: '' !important;
        position: absolute !important;
        width: 20px !important;
        height: 2px !important;
        background: #fff !important;
        border-radius: 1px !important;
        left: 0 !important;
        transition: all 0.2s ease !important;
    }
    
    .top-header-hamburger span::before {
        top: -6px !important;
    }
    
    .top-header-hamburger span::after {
        top: 6px !important;
    }
    
    /* Sidebar mobile */
    .sidebar {
        transform: translateX(-100%) !important;
        box-shadow: 4px 0 25px rgba(0,0,0,0.3) !important;
        visibility: hidden !important;
    }
    
    body.sidebar-open .sidebar {
        transform: translateX(0) !important;
        visibility: visible !important;
    }
    
    body.sidebar-open .sidebar-overlay {
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* Tablet: 768px a 991px */
@media (min-width: 768px) and (max-width: 991.98px) {
    .top-header {
        height: 50px !important;
        min-height: 50px !important;
        max-height: 50px !important;
        padding: 8px 14px !important;
    }
    
    .top-header-logo {
        height: 40px !important;
    }
    
    .top-header-logo img {
        width: 75px !important;
        height: 30px !important;
        max-width: 75px !important;
        max-height: 30px !important;
    }
    
    .top-header-hamburger {
        width: 42px !important;
        height: 42px !important;
        font-size: 0 !important;
        line-height: 0 !important;
    }
    
    .top-header-hamburger span {
        width: 22px !important;
        height: 2px !important;
    }
    
    .top-header-hamburger span::before,
    .top-header-hamburger span::after {
        width: 22px !important;
        height: 2px !important;
    }
    
    .top-header-hamburger span::before {
        top: -7px !important;
    }
    
    .top-header-hamburger span::after {
        top: 7px !important;
    }
}

/* Mobile pequeno: até 480px */
@media (max-width: 480px) {
    .top-header {
        padding: 5px 10px !important;
        height: 45px !important;
        min-height: 45px !important;
        max-height: 45px !important;
    }
    
    .top-header-logo {
        height: 36px !important;
    }
    
    .top-header-logo img {
        width: 58px !important;
        height: 23px !important;
        max-width: 58px !important;
        max-height: 23px !important;
    }
    
    .top-header-hamburger {
        width: 36px !important;
        height: 36px !important;
        font-size: 0 !important;
        line-height: 0 !important;
        border-radius: 5px !important;
    }
    
    .top-header-hamburger span {
        width: 18px !important;
        height: 2px !important;
    }
    
    .top-header-hamburger span::before,
    .top-header-hamburger span::after {
        width: 18px !important;
        height: 2px !important;
    }
    
    .top-header-hamburger span::before {
        top: -6px !important;
    }
    
    .top-header-hamburger span::after {
        top: 6px !important;
    }
}
