/* assets/css/erp-v1.css - Versão 7.7 (UI Kit & Logistics Fix) */

:root {
    --bg-dark: #0a0e12; 
    --sidebar-bg: #111; 
    --card-bg: #1a1a1a;
    --gold: #D4AF37; 
    --gold-dim: rgba(212, 175, 55, 0.15);
    --gold-hover: #f0c040;
    --text-main: #eee; 
    --text-muted: #888;
    
    /* Cores Semânticas */
    --accent-blue: #4488cc; 
    --accent-green: #2ecc71;
    --accent-red: #ff5c5c; 
    --accent-purple: #9b59b6; 
    --accent-orange: #ffaa55;
    --border-color: #333;
    
    /* Safe Areas para Mobile */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', sans-serif; outline: none; -webkit-tap-highlight-color: transparent; }

/* === ESTRUTURA GERAL (DESKTOP FIRST) === */
body { 
    background: var(--bg-dark); 
    color: var(--text-main); 
    height: 100vh; 
    height: 100dvh; 
    display: flex; 
    overflow: hidden; 
    width: 100vw;
}

/* === SCROLLBARS PERSONALIZADAS === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* === LOGIN === */
#login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 30000; display: flex; justify-content: center; align-items: center; }
.login-box { text-align: center; width: 300px; }
.login-input { width: 100%; padding: 12px; margin: 10px 0; background: #222; border: 1px solid #333; color: #fff; border-radius: 4px; }
.login-input:focus { border-color: var(--gold); }

/* === SIDEBAR (GAVETA LATERAL) === */
.sidebar { 
    background: var(--sidebar-bg); 
    border-right: 1px solid #333; 
    display: flex; 
    flex-direction: column; 
    padding: 20px; 
    transition: width 0.3s; 
    z-index: 100; 
    flex-shrink: 0; 
    overflow-y: auto;
    height: 100%;
    width: 260px; /* Largura padrão fixa */
}

.brand { color: var(--gold); font-size: 1.5rem; font-weight: bold; margin-bottom: 30px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-menu { list-style: none; flex: 1; display: flex; flex-direction: column; }
.nav-item { padding: 12px 15px; color: var(--text-muted); cursor: pointer; border-radius: 8px; margin-bottom: 5px; display: flex; align-items: center; gap: 10px; transition: 0.2s; white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: #222; color: #fff; }
.nav-item.active { background: var(--gold-dim); color: var(--gold); border-left: 3px solid var(--gold); }
.user-mini { font-size: 0.8rem; color: #555; margin-top: auto; padding-left: 20px; padding-top: 20px; border-top: 1px solid #222; }

/* === MENU ACORDEÃO === */
.nav-group { list-style: none; margin-bottom: 5px; border-radius: 8px; background: transparent; transition: 0.3s; }
.nav-group-header { padding: 12px 15px; color: #888; cursor: pointer; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; transition: 0.2s; font-weight: 600; font-size: 0.95rem; }
.nav-group-header:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-group-header i:first-child { width: 25px; text-align: center; color: var(--gold); }
.arrow-icon { font-size: 0.8rem; transition: transform 0.3s ease; opacity: 0.5; }
.nav-group.open .nav-group-header { color: #fff; background: rgba(255, 255, 255, 0.03); }
.nav-group.open .arrow-icon { transform: rotate(90deg); color: var(--gold); opacity: 1; }
.nav-submenu { list-style: none; max-height: 0; overflow: hidden; opacity: 0; transition: all 0.3s ease-in-out; background: rgba(0, 0, 0, 0.3); border-radius: 0 0 8px 8px; }
.nav-group.open .nav-submenu { max-height: 500px; opacity: 1; padding-bottom: 10px; }
.nav-submenu .nav-item { padding-left: 20px !important; font-size: 0.9rem; border-left: 2px solid transparent !important; margin-left: 15px; }
.nav-submenu .nav-item:hover { border-left-color: var(--gold) !important; }

/* === BOTÃO DE RECOLHER SIDEBAR === */
.sidebar { position: relative; overflow: visible !important; }
.sidebar-floating-toggle {
    position: absolute; right: -12px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px; background: #222; border: 1px solid #444; border-radius: 50%;
    color: #888; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 0.7rem; z-index: 1000; transition: all 0.2s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.2);
}
.sidebar-floating-toggle:hover { background: var(--gold); color: #000; transform: translateY(-50%) scale(1.2); }

/* === ÁREA PRINCIPAL === */
.main-content { 
    flex: 1; display: flex; flex-direction: column; position: relative; 
    overflow: hidden; height: 100%; min-width: 0; 
}
.top-bar { height: 60px; min-height: 60px; border-bottom: 1px solid #222; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; background: rgba(10, 14, 18, 0.95); flex-shrink: 0; }
.view-title { font-size: 1.2rem; color: #fff; font-weight: 600; }
.view-section { display: none; padding: 20px; overflow-y: auto; height: 100%; animation: fadeIn 0.3s ease; padding-bottom: 80px; -webkit-overflow-scrolling: touch; }
.view-section.active { display: flex; flex-direction: column; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================================
   🎨 FORNARTE UI KIT (ESSENCIAL PARA LOGÍSTICA E GESTÃO)
   Adicionado para corrigir telas "quebradas"
   ========================================================================= */

/* 1. Header de Módulo */
.erp-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--border-color);
}
.erp-header h2 { font-size: 1.5rem; color: var(--gold); display: flex; align-items: center; gap: 10px; }
.erp-header .erp-actions { display: flex; gap: 10px; }

/* 2. Cards (Container padrão) */
.erp-card {
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 20px; margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.erp-card h3 { color: #fff; margin-bottom: 15px; font-size: 1.1rem; border-left: 3px solid var(--gold); padding-left: 10px; }

/* 3. Formulários */
.erp-form-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 15px; }
.erp-form-group { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 5px; margin-bottom: 15px; }
.erp-form-group label { font-size: 0.85rem; color: #aaa; font-weight: 600; }
.erp-form-group input, 
.erp-form-group select, 
.erp-form-group textarea {
    background: #0f0f0f; border: 1px solid #333; color: #fff;
    padding: 10px; border-radius: 4px; font-size: 0.95rem; transition: 0.2s;
}
.erp-form-group input:focus, .erp-form-group select:focus { border-color: var(--gold); }

/* 4. Tabelas */
.erp-table-container { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 6px; }
.erp-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.erp-table th { background: #222; color: #aaa; font-weight: 600; text-align: left; padding: 12px 15px; font-size: 0.85rem; text-transform: uppercase; }
.erp-table td { border-top: 1px solid #333; padding: 12px 15px; color: #ddd; font-size: 0.95rem; }
.erp-table tr:hover { background: rgba(255,255,255,0.02); }

/* 5. Botões Padrão */
.erp-btn-primary, .erp-btn-success, .erp-btn-danger, .erp-btn-icon {
    border: none; border-radius: 4px; padding: 8px 16px; cursor: pointer;
    font-weight: 600; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 8px; transition: 0.2s;
}
.erp-btn-primary { background: var(--gold); color: #000; }
.erp-btn-primary:hover { background: var(--gold-hover); }
.erp-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.erp-btn-success { background: var(--accent-green); color: #fff; }
.erp-btn-success:hover { filter: brightness(1.1); }

.erp-btn-danger { background: var(--accent-red); color: #fff; }
.erp-btn-danger:hover { background: #d63031; }

.erp-btn-icon { background: transparent; color: #aaa; padding: 5px; font-size: 1.1rem; }
.erp-btn-icon:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* 6. Modais do UI Kit */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.85); backdrop-filter: blur(4px); z-index: 20000;
    display: none; align-items: center; justify-content: center;
}
.modal-content {
    background: #1a1a1a; border: 1px solid var(--gold); border-radius: 8px;
    padding: 25px; width: 90%; max-width: 500px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* === BOTÕES GERAIS E STATUS === */
.btn-gold { background: var(--gold); color: #000; border: none; padding: 10px 20px; border-radius: 4px; font-weight: bold; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 5px; }
.btn-gold:hover { background: #f0c040; }
.store-status-control { display: flex; align-items: center; gap: 10px; margin-right: 20px; background: #222; padding: 5px 15px; border-radius: 30px; border: 1px solid #444; }
.erp-status-text { font-size: 0.8rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }
.status-open { color: var(--accent-green); display: none; } 
.status-closed { color: var(--accent-red); }

/* SWITCH TOGGLE */
.switch { position: relative; display: inline-block; width: 40px; height: 20px; flex-shrink: 0; } 
.switch input { opacity: 0; width: 0; height: 0; } 
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #555; transition: .4s; border-radius: 34px; } 
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background: white; transition: .4s; border-radius: 50%; } 
input:checked + .slider { background-color: var(--accent-green); } 
input:checked + .slider:before { transform: translateX(20px); }

/* === PRODUTOS GRID (PDV) === */
#products-grid, .shopping-list-container, .erp-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; padding-bottom: 40px; }
.prod-card { background: #151515; border: 1px solid #333; border-radius: 12px; padding: 15px; display: flex; flex-direction: column; align-items: center; text-align: center; transition: transform 0.2s, border-color 0.2s; position: relative; overflow: hidden; }
.prod-card:hover { border-color: var(--gold); transform: translateY(-5px); background: #1a1a1a; }
.prod-img { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; border: 2px solid #333; margin-bottom: 10px; background: #000; }
.prod-name { font-weight: bold; color: #fff; font-size: 1rem; margin-bottom: 8px; min-height: 40px; display: flex; align-items: center; }
.prod-price-tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.price-tag { background: #222; padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; color: #ccc; border: 1px solid #333; }
.btn-edit-prod { background: transparent; border: 1px solid #444; color: #ccc; width: 100%; padding: 8px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; text-transform: uppercase; margin-top: auto; }
.btn-edit-prod:hover { border-color: var(--gold); color: var(--gold); }

/* === POS BOARD (KDS) === */
.pos-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; flex: 1; min-height: 0; padding-bottom: 5px; }
.pos-col { background: #111; border-radius: 8px; border: 1px solid #222; display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.pos-col-header { padding: 10px 15px; font-weight: bold; font-size: 1rem; display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); flex-shrink: 0; }
.pos-col-body { padding: 10px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.pos-card { background: #1a1a1a; border-radius: 6px; padding: 12px; position: relative; box-shadow: 0 4px 8px rgba(0,0,0,0.4); border-left: 4px solid #555; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* === MODO MENU RETRÁTIL (DESKTOP) === */
@media screen and (min-width: 1024px) {
    body.mini-sidebar .sidebar { width: 80px; }
    body.mini-sidebar .brand { justify-content: center; margin-bottom: 30px; padding-left: 0; }
    body.mini-sidebar .brand span { display: none; }
    body.mini-sidebar .brand i { font-size: 1.8rem; filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.5)); }
    body.mini-sidebar .nav-text, body.mini-sidebar .arrow-icon, body.mini-sidebar .user-mini { display: none !important; }
    body.mini-sidebar .nav-group-header, body.mini-sidebar .nav-item { justify-content: center !important; padding: 18px 0 !important; width: 100%; }
    body.mini-sidebar .nav-group-header i:first-child, body.mini-sidebar .nav-item i { font-size: 1.4rem !important; margin: 0 !important; width: auto !important; text-align: center; }
    body.mini-sidebar .nav-group.open, body.mini-sidebar .nav-item.active { border-left: 4px solid var(--gold); background: rgba(212, 175, 55, 0.05); }
    body.mini-sidebar .nav-submenu { display: none !important; }
    body.mini-sidebar .sidebar-floating-toggle i { transform: rotate(180deg); }
}

/* === MOBILE & TABLET (RESPONSIVE FIX) === */
@media screen and (max-width: 1024px) {
    body { padding-bottom: 70px; }
    
    .sidebar {
        position: fixed !important; top: 0 !important; left: 0 !important; bottom: 0 !important;
        width: 80% !important; max-width: 300px !important; height: 100vh !important;
        background: #151515 !important; border-right: 1px solid #333 !important; z-index: 30005 !important;
        transform: translateX(-100%) !important; transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
        display: flex !important; flex-direction: column !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important;
    }
    .sidebar.mobile-open { transform: translateX(0) !important; box-shadow: 10px 0 50px rgba(0,0,0,0.8) !important; }
    
    .sidebar .brand { padding: 20px !important; margin-bottom: 0 !important; background: #111; }
    .nav-menu { flex: 1 !important; display: flex !important; flex-direction: column !important; overflow-y: auto !important; padding: 10px !important; }
    .nav-group, .nav-item { display: block !important; width: 100% !important; margin: 0 !important; }
    .nav-group-header, .nav-item { display: flex !important; align-items: center !important; padding: 15px !important; border-radius: 8px !important; color: #ccc !important; width: 100% !important; background: transparent !important; }
    .nav-group-header:active, .nav-item:active { background: rgba(255,255,255,0.05) !important; }
    .nav-text, .arrow-icon, .user-mini { display: inline-block !important; }
    .nav-item i, .nav-group-header i { width: 30px !important; text-align: center !important; font-size: 1.1rem !important; margin: 0 !important; margin-right: 10px !important; }
    
    .nav-submenu { background: rgba(0,0,0,0.3) !important; margin-top: 2px !important; }
    .nav-submenu .nav-item { padding-left: 50px !important; font-size: 0.9rem !important; }
    
    .sidebar-floating-toggle, .sidebar-toggle-btn { display: none !important; }
    
    #mobile-menu-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.8); z-index: 30004; display: none; backdrop-filter: blur(2px); }
    #mobile-menu-overlay.active { display: block; }
    
    .mobile-bottom-bar { display: flex; position: fixed; bottom: 0; left: 0; width: 100%; height: 65px; background: #111; border-top: 1px solid #333; z-index: 30000; justify-content: space-around; align-items: center; padding-bottom: env(safe-area-inset-bottom, 0px); }
    .mobile-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #666; height: 100%; }
    .mobile-nav-item span { font-size: 0.65rem; margin-top: 4px; font-weight: 600; text-transform: uppercase; }
    .mobile-nav-item i { font-size: 1.4rem; }
    .mobile-nav-item.active, .mobile-nav-item:active { color: var(--gold); }
    
    .main-content { padding-bottom: 80px !important; }
}

@media screen and (min-width: 1025px) {
    .mobile-bottom-bar { display: none; }
    #mobile-menu-overlay { display: none; }
}