/* =========================================
   1. CONFIGURAÇÕES GERAIS E VARIÁVEIS
   ========================================= */
:root {
    --primary-dark: #131B47;
    --bg-body: #f3f4f6;
    --bg-actions: #eaeff5;
    --border-actions: #cfd9e0;
    --text-main: #2c3e50;
    --text-muted: #64748b;

    /* Cores Funcionais */
    --color-blue: #4ba3da;   --color-blue-soft: rgba(75, 163, 218, 0.1);
    --color-orange: #ef8e28; --color-orange-soft: rgba(239, 142, 40, 0.1);
    --color-green: #28a745;  --color-green-soft: rgba(40, 167, 69, 0.1);
    --color-purple: #9b59b6; --color-purple-soft: rgba(155, 89, 182, 0.1);
    --color-teal: #17a2b8;   --color-teal-soft: rgba(23, 162, 184, 0.1);
    --color-red: #dc3545;    --color-red-soft: rgba(220, 53, 69, 0.1);
    --color-gray: #64748b;   --color-gray-soft: rgba(100, 116, 139, 0.1);
    
    --color-splash-dot: #37a8e1;
}

* { font-family: 'Inter', 'Segoe UI', sans-serif; margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-size: 15px; /* Aumentado de 13px para 15px */
    background-color: var(--bg-body);
    min-height: 100vh;
    margin: 0; 
    overflow-x: hidden; 
    color: var(--text-main); 
    scroll-behavior: smooth;
}

/* Scrollbar Personalizada */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- TELA DE LOGIN --- */
#login-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--primary-dark);
    z-index: 10000;
    display: flex; justify-content: center; align-items: center;
}
.login-box {
    background: white; width: 400px; padding: 40px; border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    text-align: center;
}
.login-logo { font-size: 40px; margin-bottom: 10px; display: block; }
.login-title { font-size: 24px; font-weight: 800; color: var(--primary-dark); margin-bottom: 5px; }
.login-subtitle { font-size: 14px; color: #666; margin-bottom: 30px; }
.login-input {
    width: 100%; padding: 14px; margin-bottom: 15px; border: 1px solid #ddd;
    border-radius: 8px; font-size: 14px; outline: none; transition: border 0.3s;
}
.login-input:focus { border-color: var(--color-blue); }
.btn-login {
    width: 100%; padding: 14px; background: var(--primary-dark); color: white;
    border: none; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer;
    transition: background 0.3s;
}
.btn-login:hover { background: #2c3e50; }
.login-error { color: var(--color-red); font-size: 13px; margin-top: 15px; display: none; }

/* =========================================
   2. TELA DE CARREGAMENTO (SPLASH)
   ========================================= */
#splash-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--primary-dark); /* Azul Escuro Padrão */
    z-index: 9999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}

/* NOVA CLASSE PARA FUNDO TRANSPARENTE/BRANCO NA CRIAÇÃO DE USER */
#splash-screen.splash-light {
    background-color: rgba(19, 27, 71, 0.25) !important;
}
#splash-screen.splash-light p {
    color: #666 !important;
}

.hide-splash { opacity: 0; visibility: hidden; }

.splash-v3-loader { 
    position: relative; width: 280px; height: 280px; 
    display: flex; justify-content: center; align-items: center; 
}

.breathing-logo { 
    max-width: 180px; height: auto; position: relative; z-index: 10; 
    animation: breath 3s ease-in-out infinite alternate; 
}

.orbit { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.03); 
}

/* Ajuste da órbita para o modo claro */
#splash-screen.splash-light .orbit {
    border: 1px solid rgba(0, 0, 0, 0.05); 
}

.planet { 
    position: absolute; top: -5px; left: calc(50% - 5px); 
    width: 10px; height: 10px; border-radius: 50%; 
    box-shadow: 0 0 10px currentColor; 
}

.orbit-blue { animation: spinOrbit 2s linear infinite; }
.orbit-blue .planet { background-color: var(--color-splash-dot); color: var(--color-splash-dot); }

.orbit-orange { 
    width: 75%; height: 75%; top: 12.5%; left: 12.5%; 
    animation: spinOrbit 3.5s linear infinite reverse; 
}
.orbit-orange .planet { background-color: var(--color-splash-dot); color: var(--color-splash-dot); }

@keyframes breath { 0% { opacity: 0.8; transform: scale(1); } 100% { opacity: 1; transform: scale(1.05); } }
@keyframes spinOrbit { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* =========================================
   3. LAYOUT (SIDEBAR E HEADER)
   ========================================= */
.layout { display: flex; width: 100%; min-height: 100vh; }

.sidebar.left {
    width: 260px; flex-shrink: 0;
    background-color: var(--primary-dark); color: #ffffff;
    display: flex; flex-direction: column; padding: 30px 24px; gap: 20px;
    z-index: 100; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand-area { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.brand-logo { font-size: 20px; font-weight: 700; color: white; display: flex; align-items: center; gap: 10px; }

.sidebar h3 { 
    font-size: 11px; font-weight: 600; text-transform: uppercase; 
    letter-spacing: 0.12em; color: #6c7a89; margin-bottom: 12px; margin-top: 10px; 
}

.sidebar-item { 
    font-size: 13px; margin-bottom: 12px; display: flex; 
    justify-content: space-between; align-items: center; color: #ecf0f1; 
}

.sidebar .badge { 
    padding: 4px 10px; border-radius: 12px; font-size: 10px; font-weight: 700; 
    background: rgba(255,255,255,0.1); color: #fff; 
}

.main-content { 
    flex-grow: 1; display: flex; flex-direction: column; 
    background-color: var(--bg-body); min-width: 0; 
}

.header {
    background: #ffffff; height: 80px; padding: 0 40px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 90;
}

.page-title h1 { font-size: 22px; font-weight: 700; color: var(--primary-dark); letter-spacing: -0.5px; margin: 0; }
.page-title p { font-size: 13px; color: var(--text-muted); margin-top: 4px; margin-bottom: 0; }

#btn-voltar-home {
    opacity: 0; pointer-events: none; transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex; align-items: center; gap: 8px; padding: 10px 20px;
    background-color: #f1f5f9; color: var(--primary-dark); border: 1px solid #e2e8f0;
    border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer;
}
#btn-voltar-home.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
#btn-voltar-home:hover { background-color: #e2e8f0; }

#btn-imprimir {
    display: none; align-items: center; gap: 8px; padding: 10px 20px;
    background-color: var(--primary-dark); color: white; border: none;
    border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; margin-right: 10px;
}
#btn-imprimir:hover { background-color: #2c3e50; }

/* AJUSTE PARA MAIOR LARGURA LATERAL */
.content-wrapper { 
    padding: 20px 10px; /* Reduz o respiro lateral externo */
    max-width: 98%;      /* Expande o limite de 1200px para quase 100% da tela */
    width: 100%; 
    margin: 0 auto; 
}


.theme-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 10px;
}

.btn-theme-sidebar {
  border: none;
  background: #f1f5f9;
  color: #64748b;
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-theme-sidebar i {
  font-size: 16px;
}

.theme-toggle-label {
  font-size: 12px;
  color: #64748b;
}


/* =========================================
   4. MENU DE AÇÕES E CARDS
   ========================================= */
.actions-container {
    background-color: var(--bg-actions); 
    background-image: linear-gradient(to bottom,  #dfe6ed, #d3d3d3);
    border: 1px solid var(--border-actions); 
    border-radius: 16px; padding: 35px; margin-bottom: 50px;
    box-shadow: inset 0 2px 6px rgba(19, 27, 71, 0.08); 
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); overflow: hidden; 
}

.actions-container.minimized { 
    padding: 15px 35px; margin-bottom: 30px; 
    background-image: linear-gradient(to bottom,  #eef3f7, #e1e6eb); 
}
.actions-container.minimized .actions-header { display: none; }

.actions-header { 
    margin-bottom: 20px; font-size: 14px; font-weight: 600; 
    text-transform: uppercase; letter-spacing: 0.05em; color: #5a6670; 
}

.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }

.menu-card {
    background: #ffffff; border-radius: 12px; padding: 20px;
    cursor: pointer; transition: all 0.4s ease;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border: 1px solid rgba(255,255,255,0.6);
    display: flex; flex-direction: column; gap: 15px; position: relative; overflow: hidden;
}

.actions-container.minimized .menu-card { 
    padding: 10px 15px; flex-direction: row; align-items: center; 
    gap: 12px; border-radius: 8px; 
}

.menu-card:hover { transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.actions-container.minimized .menu-card:hover { transform: translateY(-2px); }

.icon-box { 
    width: 44px; height: 44px; border-radius: 10px; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 20px; transition: all 0.4s ease; 
}
.actions-container.minimized .icon-box { width: 32px; height: 32px; font-size: 14px; border-radius: 6px; }
.menu-card:hover .icon-box { transform: scale(1.1); }

.card-title { font-size: 14px; font-weight: 600; color: var(--text-main); transition: all 0.3s; }
.actions-container.minimized .card-title { font-size: 13px; }

/* Cores dos Cards */
.card-blue .icon-box { background: var(--color-blue-soft); color: var(--color-blue); }
.card-orange .icon-box { background: var(--color-orange-soft); color: var(--color-orange); }
.card-green .icon-box { background: var(--color-green-soft); color: var(--color-green); }
.card-purple .icon-box { background: var(--color-purple-soft); color: var(--color-purple); }
.card-teal .icon-box { background: var(--color-teal-soft); color: var(--color-teal); }
.card-red .icon-box { background: var(--color-red-soft); color: var(--color-red); }
.card-gray .icon-box { background: var(--color-gray-soft); color: var(--color-gray); }

/* =========================================
   5. OVERVIEW E PAINÉIS
   ========================================= */
#home-overview { display: block; animation: fadeIn 0.8s ease-out; }
.overview-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 30px; }

.overview-card { 
    background: #fff; border-radius: 12px; padding: 30px; 
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1); border: 1px solid #e5e7eb; 
}
.overview-header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 20px; border-bottom: 1px solid #f0f0f0; padding-bottom: 15px; 
}
.overview-header h3 { font-size: 16px; font-weight: 700; color: var(--primary-dark); margin:0; }

.active-panel {
    display: none; 
    background: #ffffff; 
    border-radius: 12px; 
    padding: 25px 15px; /* Reduz o padding interno lateral para a tabela ganhar espaço */
    box-shadow: 0 10px 20px rgba(0,0,0,0.05); 
    border: 1px solid #e5e7eb; 
    border-left: 6px solid var(--primary-dark);
    width: 100%; 
}

.animate-entrance { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel-header { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 30px; border-bottom: 1px solid #f0f0f0; padding-bottom: 20px; 
}
.panel-header h2 { font-size: 20px; font-weight: 700; color: var(--primary-dark); margin:0; }

.btn-close-panel { 
    background: none; border: none; font-size: 26px; color: #ccc; 
    cursor: pointer; transition: color 0.2s; 
}
.btn-close-panel:hover { color: var(--color-red); }

/* =========================================
   6. MODAIS E FORMULÁRIOS
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(19, 27, 71, 0.6); 
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none; justify-content: center; align-items: center;
    opacity: 0; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; }

.modal-box {
    background: #fff; width: 700px; max-width: 95%;
    border-radius: 16px; padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    transform: translateY(20px); transition: transform 0.3s;
    position: relative;
}
.modal-overlay.open .modal-box { transform: translateY(0); }

.btn-close-modal {
    position: absolute; top: 20px; right: 20px;
    border: none; background: none; font-size: 24px; color: #999; cursor: pointer;
}
.btn-close-modal:hover { color: var(--color-red); }

.modal-header-custom { 
    display: flex; align-items: center; gap: 10px; margin-bottom: 25px; 
    padding-bottom: 15px; border-bottom: 1px solid #eee; 
}
.modal-header-custom h2 { font-size: 18px; color: var(--primary-dark); font-weight: 700; margin: 0; }

/* Grid de Formulário */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.full-width { grid-column: span 2; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #34495e; font-size: 13px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 12px 16px; 
    border: 1px solid #c0c4cc; 
    border-radius: 6px; font-size: 14px; background: #fcfcfc; color: #1f2937; 
    font-weight: 500; transition: all 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary-dark); background: #fff; outline: none; 
    box-shadow: 0 0 0 2px rgba(19, 27, 71, 0.1); 
}
.form-group input:disabled, .form-group select:disabled {
    background: #e9ecef; color: #6c757d; cursor: not-allowed; border-color: #d1d5db;
}

.radio-group { display: flex; gap: 20px; align-items: center; height: 100%; }
.radio-group label { margin: 0; font-weight: 500; display: flex; align-items: center; gap: 5px; cursor: pointer; }

.section-title { 
    margin-top: 30px; margin-bottom: 15px; color: #555; 
    border-bottom: 1px solid #eee; padding-bottom: 5px; 
    font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; 
}
.section-title:first-child { margin-top: 0; }

.panel-footer { 
    margin-top: 30px; text-align: right; padding-top: 20px; 
    border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 10px; 
}

/* =========================================
   7. BOTÕES E TABELAS
   ========================================= */
.btn-salvar { 
    background: var(--primary-dark); 
    color: #fff; border: none; padding: 12px 30px; font-size: 14px; font-weight: 600; 
    border-radius: 6px; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; 
}
.btn-salvar:hover { transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); filter: brightness(1.1); }

.btn-cancelar-form { 
    background: transparent; color: #64748b; border: 1px solid transparent; 
    padding: 12px 20px; font-size: 14px; font-weight: 600; 
    border-radius: 6px; cursor: pointer; transition: all 0.2s; 
}
.btn-cancelar-form:hover { background: #f1f5f9; color: #475569; }

.btn-action { 
    padding: 8px 12px; font-size: 12px; border-radius: 6px; 
    border: 1px solid #d1d5db; background: #fff; cursor: pointer; 
    display: flex; align-items: center; gap: 5px; transition: all 0.2s; 
}
.btn-action:hover { background: #f3f4f6; border-color: #9ca3af; }
.btn-action.danger { color: #dc2626; border-color: #fecaca; }
.btn-action.danger:hover { background: #fef2f2; }
.btn-action.success { color: #166534; border-color: #bbf7d0; }
.btn-action.success:hover { background: #f0fdf4; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { 
    text-align: left; padding: 12px; color: #95a5a6; font-size: 11px; 
    text-transform: uppercase; font-weight: 600; border-bottom: 1px solid #eee; 
}

.data-table td {
    white-space: nowrap; 
    padding: 10px 15px; 
    font-size: 13px !important;
    vertical-align: middle; 
}

.data-table .btn-action { font-size: 14px; }

.tag-status { padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.status-ok { background: #dcfce7; color: #166534; }
.status-pendente { background: #fef9c3; color: #854d0e; }
.status-cancel { background: #fee2e2; color: #991b1b; }

.items-list { 
    display: none; border: 1px solid #e5e7eb; border-radius: 8px; 
    overflow: hidden; margin-top: 10px; animation: fadeIn 0.3s; 
}
.items-list table { width: 100%; border-collapse: collapse; }
.items-list th { background: #f9fafb; padding: 10px; font-size: 12px; text-align: left; color: #6b7280; }
.items-list td { padding: 10px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }

#box-cliente-avulso { 
    display: none; background-color: #f0f9ff; border: 1px solid #bae6fd; 
    border-radius: 8px; padding: 15px; margin-top: 10px; animation: fadeIn 0.3s; 
}

.filter-tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 1px solid #e5e7eb; }
.filter-tab { 
    padding: 10px 20px; cursor: pointer; font-size: 13px; font-weight: 600; 
    color: #64748b; border-bottom: 2px solid transparent; transition: all 0.2s; 
}
.filter-tab.active { color: var(--primary-dark); border-bottom-color: var(--primary-dark); }
.filter-tab:hover { color: var(--primary-dark); background: rgba(0,0,0,0.02); }

.visible-table { display: block; margin-top: 20px; margin-bottom: 20px; }

/* =========================================
   8. ESTILOS DE IMPRESSÃO (CORRIGIDO)
   ========================================= */
#area-impressao { display: none; }

/* =================================================================
   ESTILOS DE IMPRESSÃO (CORREÇÃO TELA BRANCA)
   ================================================================= */
#area-impressao {
    display: none; /* Escondido na tela normal */
}

@media print {
    @page {
        margin: 0.5cm;
        size: A4;
    }

    /* 1. Esconde TUDO no corpo da página */
    body * {
        visibility: hidden;
    }

    /* 2. Reseta o corpo para garantir que a impressão ocupe tudo */
    body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    /* 3. Torna visível APENAS a área de impressão e seus filhos */
    #area-impressao,
    #area-impressao * {
        visibility: visible;
    }

    /* 4. Posiciona a área de impressão no topo absoluto */
    #area-impressao {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: #fff;
        z-index: 99999;
    }

    /* Estilos internos da impressão */
    .via-container {
        border: 1px solid #000;
        padding: 10px;
        margin-bottom: 20px;
        font-family: Arial, sans-serif;
        font-size: 11px;
        color: #000;
        page-break-inside: avoid;
    }

    .titulo-via {
        text-align: center;
        font-weight: bold;
        background: #eee !important; /* Força cor de fundo */
        -webkit-print-color-adjust: exact; /* Para Chrome imprimir fundo */
        print-color-adjust: exact;
        border-bottom: 1px solid #000;
        margin: -10px -10px 10px -10px;
        padding: 5px;
        font-size: 12px;
    }
    
    .print-table { width: 100%; border-collapse: collapse; margin-top: 5px; }
    .print-table th { background-color: #eee !important; -webkit-print-color-adjust: exact; font-weight: bold; border: 1px solid #000; padding: 4px; text-align: left; }
    .print-table td { border: 1px solid #000; padding: 4px; text-align: left; vertical-align: top; }
    
    .cabecalho-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; border-bottom: 1px solid #ccc; padding-bottom: 8px; margin-bottom: 8px; }
    .box-info { border: 1px solid #000; padding: 5px; background-color: #fafafa !important; -webkit-print-color-adjust: exact; }
    
    .cut-line {
        border-top: 1px dashed #000;
        text-align: center;
        margin: 20px 0;
        font-size: 10px;
        padding-top: 5px;
    }
}

/* Spinner Simples para Upload/Ações */
#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.9); z-index: 10001;
    display: none; flex-direction: column; justify-content: center; align-items: center;
}
.spinner {
    border: 8px solid #f3f3f3; border-top: 8px solid #3498db;
    border-radius: 50%; width: 60px; height: 60px;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }


/* ARQUIVO: styles.css */

/* Garante que o Toastify apareça na frente dos seus Modais */
.toastify {
    z-index: 99999 !important; /* Força ficar no topo */
    font-family: 'Inter', sans-serif; /* Força usar a fonte do seu site */
}

/* Spinner dentro do botão */
.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Estado visual de carregando */
.btn-loading {
    opacity: 0.7 !important;
    pointer-events: none; /* Impede clique */
    cursor: not-allowed;
}

/* =========================================
   ÍCONES PHOSPHOR & SPINNER
   ========================================= */
/* Alinhamento geral dos ícones */
i.ph, i.ph-bold, i.ph-fill {
    font-size: 1.2em;
    vertical-align: -2px; /* Ajuste fino vertical */
    margin-right: 5px;
}

/* Ícones grandes do Menu Principal */
.icon-box i {
    font-size: 26px;
    color: inherit;
    margin-right: 0;
}

/* Animação de rotação para o Loading */
@keyframes spin { 100% { transform: rotate(360deg); } }

.ph-spinner {
    animation: spin 1s linear infinite;
}

/* Estado de carregando do botão */
.btn-loading {
    opacity: 0.7;
    cursor: wait !important;
    pointer-events: none;
}


/* =========================================
   RESPONSIVIDADE DAS TABELAS (MOBILE CARDS)
   ========================================= */
@media screen and (max-width: 768px) {
    /* 1. Esconde o cabeçalho da tabela */
    .data-table thead {
        display: none;
    }

    /* 2. Transforma a tabela em blocos */
    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
    }

    /* 3. Estilo do "Card" (cada linha vira um cartão) */
    .data-table tr {
        margin-bottom: 15px;
        background-color: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        overflow: hidden; /* Garante bordas arredondadas */
    }

    /* 4. Estilo das Células */
    .data-table td {
        display: flex;
        justify-content: space-between; /* Texto à direita, Label à esquerda */
        align-items: center;
        text-align: right;
        padding: 12px 15px;
        border-bottom: 1px solid #f1f5f9;
        font-size: 13px;
        min-height: 45px; /* Altura mínima para toque */
    }

    .data-table td:last-child {
        border-bottom: none; /* Remove borda do último item */
        background-color: #f8fafc; /* Destaque para os botões de ação */
        justify-content: center; /* Centraliza botões */
        padding: 15px;
    }

    /* 5. O Pulo do Gato: Rótulos via CSS (Pega do atributo data-label) */
    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #64748b;
        text-transform: uppercase;
        font-size: 11px;
        letter-spacing: 0.5px;
        margin-right: 15px;
        text-align: left;
    }
}

/* =========================================
   DARK MODE (MODO ESCURO)
   ========================================= */
body.dark-mode {
    /* Redefine Variáveis para Escuro */
    --primary-dark: #1e293b; /* Azul acinzentado escuro */
    --bg-body: #0f172a;      /* Fundo quase preto */
    --bg-actions: #1e293b;   /* Fundo containers */
    --border-actions: #334155;
    --text-main: #f1f5f9;    /* Texto claro */
    --text-muted: #94a3b8;
}

/* Ajustes Específicos para componentes que eram Brancos fixos */
body.dark-mode .header,
body.dark-mode .menu-card,
body.dark-mode .overview-card,
body.dark-mode .active-panel,
body.dark-mode .modal-box,
body.dark-mode .data-table tr {
    background-color: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

/* Ajuste de Inputs e Selects */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode .login-input {
    background-color: #0f172a !important;
    border-color: #475569 !important;
    color: #fff !important;
}

/* Ajuste de Tabelas */
body.dark-mode .data-table th {
    background-color: #1e293b;
    color: #94a3b8;
    border-bottom-color: #334155;
}
body.dark-mode .data-table td {
    border-bottom-color: #334155;
}

/* Ajuste do Sidebar (Menu Lateral) */
body.dark-mode .sidebar {
    background-color: #020617; /* Ainda mais escuro */
    border-right: 1px solid #1e293b;
}

/* Ajuste do Login Box */
body.dark-mode .login-box {
    background-color: #1e293b;
    color: #fff;
}
body.dark-mode .login-title { color: #fff; }


/* ==============================
   COR DE TEXTOS NO MODO ESCURO
   ============================== */

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4 {
    color: #e5e7eb !important; /* cinza claro */
}

/* Títulos principais */
body.dark-mode .page-title h1,
body.dark-mode .page-title p {
    color: #f1f5f9 !important;
}

/* Títulos dos painéis */
body.dark-mode #titulo-painel {
    color: #f8fafc !important;
}

/* Subtítulos e headers de cards */
body.dark-mode .overview-header h3,
body.dark-mode .panel-header h2 {
    color: #e5e7eb !important;
}


/* Editar (laranja) */
.btn-editar,
.btn-editar:hover {
    background: #f59e0b !important;
    color: #fff !important;
}

/* Cancelar (vermelho) */
.btn-cancelar,
.btn-cancelar:hover {
    background: #dc2626 !important;
    color: #fff !important;
}



/* Botão de tema */
.btn-theme {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Tema claro */
.btn-theme.light {
    background-color: #f1f5f9;
    color: #64748b;
}

/* Tema escuro */
.btn-theme.dark {
    background-color: #334155;
    color: #fbbf24;
}



/* Se o corpo da página tiver essa classe, esconde os botões de deletar */
body.hide-delete-actions .btn-delete,
body.hide-delete-actions .btn-excluir {
    display: none !important;
}


/* Alinha os botões de editar e excluir lado a lado */
.td-acoes {
    display: flex !important;
    align-items: center;
    gap: 10px; /* Espaço entre o lápis e a lixeira */
    justify-content: flex-start;
    border-bottom: none !important; /* Remove borda extra se houver conflito */
}

/* =================================================================
   BOTÃO HAMBÚRGUER E SIDEBAR TOGGLE
   ================================================================= */

/* 1. Força o botão a aparecer e ser visível */
#btn-toggle-sidebar {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #f1f5f9; /* Fundo cinza claro */
    color: #333 !important;    /* Ícone escuro (Forçado) */
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #ddd !important;
}

#btn-toggle-sidebar:hover {
    background-color: #e2e8f0;
    transform: scale(1.05);
}

/* 2. Configura a transição suave dos elementos */
.sidebar, .main-content {
    transition: all 0.3s ease-in-out;
}

/* 3. O QUE ACONTECE QUANDO A CLASSE 'sidebar-closed' É ATIVADA NO BODY */

/* Esconde a Sidebar jogando ela para a esquerda (fora da tela) */
body.sidebar-closed .sidebar {
    margin-left: -260px; /* Ajuste conforme a largura da sua sidebar */
    opacity: 0;
    pointer-events: none; /* Impede cliques quando oculta */
}

/* Expande o conteúdo principal para ocupar a tela toda */
body.sidebar-closed .main-content {
    width: 100% !important;
    margin-left: 0 !important;
    max-width: 100% !important;
}
/* Ajuste para Consultar Histórico não vazar da tela */
#painel-operacional {
    max-width: 100%;
    overflow-x: hidden; 
}

/* Forçar a tabela a ser responsiva */
.data-table {
    width: 100% !important;
    table-layout: auto; /* Mudamos para auto para melhor ajuste */
    border-collapse: collapse;
}

/* Permitir que o texto quebre nas células para não esticar a tabela */
.data-table td {
    white-space: normal !important; /* IMPORTANTE: permite quebra de linha */
    word-break: break-word;
    vertical-align: middle;
    padding: 12px 8px;
    line-height: 1.4;
}

/* Container com scroll apenas na tabela caso ela ainda seja maior que a tela */
/* Garante que o conteúdo dentro do painel ocupe tudo */
#conteudo-painel {
    width: 100%;
    margin: 0;
}

/* =================================================================
   AJUSTE DE FONTES EXCLUSIVO PARA O PAINEL DE HISTÓRICO (CONSULTAR)
   ================================================================= */

/* Container do painel para garantir que ocupe todo o espaço sem vazar */
#painel-operacional #conteudo-painel {
    width: 100%;
    overflow-x: auto; /* Scroll apenas se for extremamente necessário */
}

/* Redução da tabela de consulta */
#painel-operacional .data-table {
    font-size: 14px !important; /* Fonte padrão 14px para leitura */
    width: 100% !important;
    table-layout: auto;
}

/* Cabeçalho da tabela (Th) */
#painel-operacional .data-table th {
    font-size: 10px !important;
    padding: 6px 8px !important;
    text-transform: uppercase;
    background-color: #f8fafc;
    color: #475569;
}

/* Células da tabela (Td) */
#painel-operacional .data-table td {
    padding: 12px 8px !important; /* Mais respiro vertical */
    line-height: 1.4;
    white-space: normal !important; /* Permite quebrar linha */
    word-break: break-word;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
}

/* Estilo para nomes de clientes ou docs muito longos */
.data-table td strong {
    font-weight: 600;
    color: var(--primary-dark);
}

/* Badges de Status menores dentro da consulta */
#painel-operacional .tag-status {
	
    font-size: 11px !important;
    padding: 4px 8px !important;
    border-radius: 4px;
    display: inline-block;
    white-space: nowrap;
}

/* Botões de ação na tabela menores */
#painel-operacional .btn-action {
    padding: 6px 10px !important;
}

#painel-operacional .btn-action i {
    font-size: 16px !important;
}

/* Ajuste do Título e Contador de resultados */
#titulo-painel {
    font-size: 20px !important;
    margin: 0;
}

/* Indica que a linha toda é um botão agora */
.linha-clicavel {
    cursor: pointer;
    transition: all 0.2s ease;
}

.linha-clicavel:hover {
    background-color: rgba(75, 163, 218, 0.08) !important;
}

/* Pequeno ajuste nos ícones para não brigarem visualmente com a linha */
.acoes-container-rapido button {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 5px;
    border-radius: 4px;
    margin-left: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.acoes-container-rapido button:hover {
    background: var(--primary-dark);
    color: white;
}

/* =================================================================
   ESTILOS DA TABELA DE PROTOCOLOS (Retorno e Alinhamento)
   ================================================================= */

/* Classe para centralizar Cabeçalhos (TH) e Células (TD) */
.col-center {
    text-align: center !important;
    vertical-align: middle !important;
}

/* Estilo do Retorno: SIM (Laranja) */
.retorno-sim {
    color: #e67e22; /* Laranja vibrante */
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
}

/* Estilo do Retorno: NÃO (Cinza claro) */
.retorno-nao {
    color: #adb5bd; /* Cinza suave */
    font-size: 12px;
}

/* =================================================================
   ALINHAMENTO GLOBAL DO PAINEL DE PROTOCOLOS (Limpo)
   ================================================================= */

/* 1. Força TÍTULOS e DADOS a ficarem centralizados apenas neste painel */
#painel-operacional .data-table th,
#painel-operacional .data-table td {
    text-align: left !important;
    vertical-align: middle !important;
}

/* 2. Garante que os botões de ação (lápis, impressora, etc) fiquem no meio */
#painel-operacional .acoes-container-rapido {
    justify-content: center !important;
}

/* (Opcional) Se quiser que apenas o NOME DO CLIENTE fique à esquerda */
/* Descomente a linha abaixo se achar que centralizar o nome ficou estranho: */
/* #painel-operacional .data-table td:nth-child(4) { text-align: left !important; } *//* =================================================================
   AJUSTE DE CONTRASTE: COLUNA RETORNO
   ================================================================= */

/* =================================================================
   CORREÇÃO DEFINITIVA DE CORES: COLUNA RETORNO
   ================================================================= */

/* Regra ultra-específica para vencer a cor padrão da tabela */
#painel-operacional .data-table span.retorno-sim {
    color: #e65100 !important; /* Laranja avermelhado bem forte */
    font-weight: 800 !important; /* Extra Negrito */
    font-size: 11px !important;
}

#painel-operacional .data-table span.retorno-nao {
    color: #1f2937 !important; /* Cinza quase preto (Chumbo) */
    font-weight: 700 !important; /* Negrito */
    font-size: 11px !important;
    opacity: 0.7; /* Leve transparência para diferenciar do texto normal */
	
}


/* =================================================================
   ALINHAMENTO DE AÇÕES À ESQUERDA (EXCEÇÃO)
   ================================================================= */

/* 1. Tira o alinhamento central apenas da ÚLTIMA coluna (Título e Célula) */
#painel-operacional .data-table th:last-child,
#painel-operacional .data-table td:last-child {
    text-align: left !important;
    padding-left: 15px !important; /* Adiciona um respiro na esquerda */
}

/* 2. Força o container dos botões a alinhar no início (esquerda) */
#painel-operacional .acoes-container-rapido {
    justify-content: flex-start !important;
}/* =========================================
   AJUSTE DE ALINHAMENTO - TABELA DE USUÁRIOS
   ========================================= */

/* 1. Alinha o Título "Ação" (Cabeçalho) à esquerda */
.visible-table .data-table th:last-child {
    text-align: left !important;
    padding-left: 0 !important; /* Opcional: remove padding extra se houver */
}

/* 2. Alinha os Botões (Célula) à esquerda */
.visible-table .data-table td:last-child {
    justify-content: flex-start !important; /* Força o alinhamento do Flexbox para o início */
    text-align: left !important;
}


/* 1. Remove o cursor piscante (caret) de toda a página */
body {
    caret-color: transparent;
}

/* 2. Traz o cursor de volta APENAS para campos de digitação */
input, textarea, [contenteditable="true"] {
    caret-color: auto; /* ou a cor preta/tema: #000 */
}

/* Animação de piscar suave (PULSE) */
@keyframes pulse-warning {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* Classe para a etiqueta de aviso */
.badge-vencendo {
    background-color: #ff9800; /* Laranja */
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    animation: pulse-warning 1.5s infinite ease-in-out; /* Onde a mágica acontece */
    box-shadow: 0 0 5px rgba(255, 152, 0, 0.6);
}

/* ================================================================= */
/* MODO DARK - CORREÇÃO FINAL (Status Coloridos + Texto Branco) */
/* ================================================================= */

/* 1. TEXTO GERAL: Tudo que está dentro da tabela vira branco... */
body.dark-mode .data-table td {
    color: #ffffff !important;
}

/* 2. ...EXCETO os Status e Badges Coloridos (Proteção) */
/* Aqui dizemos: "Não use o branco da regra acima, use a cor original do elemento" */
body.dark-mode .tag-status,
body.dark-mode .badge-vencendo,
body.dark-mode .retorno-sim { 
    color: inherit !important; /* Herda a cor definida na classe original (.status-ok, etc) */
    /* Se o inherit falhar, forçamos as cores originais abaixo por segurança: */
}

/* Reforço de segurança para as cores dos Status não sumirem */
body.dark-mode .status-ok { color: #166534 !important; }      /* Verde */
body.dark-mode .status-pendente { color: #854d0e !important; }/* Laranja/Marrom */
body.dark-mode .status-cancel { color: #991b1b !important; }  /* Vermelho */
body.dark-mode .retorno-sim { color: #e67e22 !important; }    /* Laranja */

/* 3. CLIENTE: Garante que o Negrito (Nome do Cliente) seja branco puro */
body.dark-mode .data-table td strong {
    color: #ffffff !important;
}

/* 4. UPLOAD (Novo Protocolo): Texto "Clique para anexar" e Ícone */
/* Remove o azul escuro original e põe branco */
body.dark-mode label[for="inp-arquivos"],
body.dark-mode label[for="inp-arquivos"] i {
    color: #ffffff !important;
    border-color: #ffffff !important;
}
body.dark-mode #msg-arquivos {
    color: #cccccc !important;
}

/* 5. RETORNO "NÃO": Cinza claro para ler no fundo escuro (o original era cinza escuro) */
body.dark-mode .retorno-nao {
    color: #94a3b8 !important; 
}

/* ================================================================= */
/* CORREÇÃO DO CABEÇALHO DAS TABELAS (MODO ESCURO) */
/* ================================================================= */

/* 1. Fundo Escuro para a barra de colunas (thead) */
body.dark-mode .data-table thead,
body.dark-mode .data-table thead tr,
body.dark-mode .data-table thead th {
    background-color: #0f172a !important; /* Azul muito escuro (quase preto) */
    color: #ffffff !important;           /* Texto branco puro */
    border-bottom: 2px solid #334155 !important; /* Linha separadora cinza azulada */
}

/* 2. Ajuste fino para os textos dos títulos das colunas */
body.dark-mode .data-table th {
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 3. Garante que os ícones de ordenação ou botões dentro do cabeçalho (se houver) fiquem brancos */
body.dark-mode .data-table thead th i,
body.dark-mode .data-table thead th button {
    color: #ffffff !important;
}

