/* Reset e configurações gerais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}
/* Ajuste global de tipografia e mídia */
html { font-size: clamp(14px, 1vw + 12px, 16px); }
img, video, canvas { max-width: 100%; height: auto; }
input, select, textarea, button { font-size: inherit; }

/* Paleta e tema global */
:root {
    --brand-start: #667eea;
    --brand-end: #764ba2;
    --accent: #ff8c00;
    --text-primary: #333;
    --text-secondary: #666;
    --bg-light: #f8f9fa;
    --border: #e9ecef;
    --card-bg: #ffffff;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.1);
}

.header {
    background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 28px; height: 28px; }
.site-title { font-size: 18px; color: #fff; }
.header-right { display: flex; align-items: center; gap: 10px; color: #fff; }

.card-icon, .btn-primary {
    background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);
}

.accent { color: var(--accent); }

/* Componentes compartilhados (padronização com Dashboard) */
.nav-menu {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-x: auto; /* garante uma única linha, com scroll se necessário */
    white-space: nowrap;
}

.nav-menu .nav-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
    color: #fff;
}

.nav-menu .nav-item.active {
    background: rgba(255,255,255,0.12);
}

.nav-menu .nav-item i { color: #fff; }
.topbar { flex: 1; display: flex; }
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 12px 0;
    flex-wrap: wrap;
}

.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.auto-fit-250 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid.auto-fit-300 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 6px; font-size: 16px; color: var(--text-primary); }
.card .value { font-size: 20px; font-weight: 600; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid #ddd; padding: 8px; text-align: left; }

.badge { padding: 4px 8px; border-radius: 12px; font-size: 12px; display: inline-block; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #cce5ff; color: #0c5460; }

.btn { background: #f5f5f5; border: none; border-radius: 6px; padding: 8px 12px; cursor: pointer; }
.btn-light { background: #efefef; }
.btn:hover { background: #e0e0e0; }

.tabs { display: flex; gap: 8px; margin: 10px 0; }
.tab { padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; background: var(--bg-light); cursor: pointer; }
.tab.active { background: #e9ecef; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Utilitários de visibilidade */
.d-none { display: none !important; }

/* Dashboard-specific helpers replicados para consistência */
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background-color: #fff; border-radius: 8px; padding: 20px; box-shadow: var(--shadow-sm); }
.stat-card .icon { font-size: 32px; margin-bottom: 15px; color: var(--accent); }
.stat-card .value { font-size: 28px; font-weight: bold; margin-bottom: 5px; }
.stat-card .label { color: var(--text-secondary); font-size: 14px; }
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: clamp(14px, 2vw, 24px); }
.dashboard-card { background-color: #fff; border-radius: 8px; padding: 20px; box-shadow: var(--shadow-sm); }
.dashboard-card h3 { margin-top: 0; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 15px; color: var(--text-primary); }

/* Telas */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Tela de Login */
#loginScreen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-header i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 15px;
}

.login-header h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.login-header p {
    color: #666;
    font-size: 0.9rem;
}

.login-form {
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Botões */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.1rem;
    width: 100%;
    margin-bottom: 10px;
}

/* Dashboard */
#dashboardScreen {
    display: grid;
    grid-template-areas: 
        "header"
        "main";
    grid-template-rows: 80px 1fr;
    min-height: 100vh;
    background: #f8f9fa;
}

/* Header */
.header {
    grid-area: header;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

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

.header-logo {
    height: 45px;
    margin-right: 20px;
}

.header-left h1 {
    color: white;
    font-size: 1.8rem;
    margin-right: 40px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#userInfo {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Sidebar - agora integrada no header */
.sidebar {
    display: flex;
    align-items: center;
    gap: 0;
    flex: 2;
}

.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0;
    padding: 0;
    width: 100%;
    flex-wrap: wrap;
}

.nav-item {
    display: flex;
    align-items: center;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 12px 20px;
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 0 5px;
    font-weight: 500;
    font-size: 0.95rem;
    position: relative;
    overflow: hidden;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nav-item i {
    margin-right: 8px;
    width: 18px;
    font-size: 1rem;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.nav-item:hover::before {
    left: 100%;
}

/* Main Content */
.main-content {
    grid-area: main;
    padding: clamp(12px, 2vw, 24px);
    overflow-y: auto;
}

/* Responsividade da barra e cabeçalho */
@media (max-width: 900px) {
    .header {
        flex-wrap: wrap;
        padding: 10px 16px;
    }
    .header-left h1 { font-size: 1.4rem; margin-right: 20px; }
    .header-right { width: 100%; justify-content: flex-end; margin-top: 8px; }
    .nav-item { padding: 10px 14px; margin: 3px; }
}

.module {
    display: none;
}

.module.active {
    display: block;
}

.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.module-header h2 {
    color: #333;
    font-size: 1.8rem;
}

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
}

.card-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-content h3 {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.card-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

/* Charts */
.dashboard-charts {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chart-container h3 {
    margin-bottom: 15px;
    color: #333;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-bar input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
}

.search-bar input:focus {
    outline: none;
    border-color: #667eea;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8f9fa;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e9ecef;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
}

tr:hover {
    background: #f8f9fa;
}

/* PDV */
.pdv-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    height: calc(100vh - 120px);
}

.pdv-left,
.pdv-right {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-produto {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-produto input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
}

.carrinho {
    height: calc(100% - 80px);
    overflow-y: auto;
}

.carrinho h3 {
    margin-bottom: 15px;
    color: #333;
}

.carrinho-itens {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    min-height: 200px;
    padding: 10px;
}

.carrinho-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #e9ecef;
}

.carrinho-item:last-child {
    border-bottom: none;
}

.item-info {
    flex: 1;
}

.item-nome {
    font-weight: 500;
    color: #333;
}

.item-preco {
    color: #666;
    font-size: 0.9rem;
}

.item-quantidade {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 15px;
}

.qty-btn {
    background: #667eea;
    color: white;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
}

.qty-input {
    width: 50px;
    text-align: center;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    padding: 5px;
}

.remove-item {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.total-venda {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.total-venda h3 {
    font-size: 1.5rem;
    color: #333;
}

.total-venda span {
    color: #28a745;
    font-weight: bold;
}

.pagamento,
.cliente-venda {
    margin-bottom: 20px;
}

.pagamento h4,
.cliente-venda h4 {
    margin-bottom: 10px;
    color: #333;
}

.pagamento select,
.cliente-venda input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    color: #333;
    margin: 0;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

.modal form {
    padding: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-actions button {
    min-width: 100px;
}

/* Responsividade */
@media (max-width: 768px) {
    #dashboardScreen {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    table { display: block; overflow-x: auto; white-space: nowrap; }
    
    .pdv-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* Animações */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.module.active {
    animation: fadeIn 0.3s ease-out;
}

/* Estados de loading */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Alertas e notificações */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 15px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* === Navegação Lanchonete: linha única e submenu Financeiro === */
body[data-module="lanchonete"] .header .nav-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow-x: auto;
}

body[data-module="lanchonete"] .nav-menu > li {
  position: relative;
}

/* Submenu oculto por padrão */
body[data-module="lanchonete"] .nav-menu > li.has-submenu > .submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: var(--menu-bg, rgba(0,0,0,0.08));
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.2);
}

/* Itens do submenu herdando estilo base */
body[data-module="lanchonete"] .nav-menu > li.has-submenu > .submenu .nav-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
}

/* Mostrar submenu apenas quando interagir com Financeiro */
body[data-module="lanchonete"] .nav-menu > li.has-submenu:hover > .submenu,
body[data-module="lanchonete"] .nav-menu > li.has-submenu:focus-within > .submenu {
  display: block;
}