/* ======================================
   MIPANA DESIGN SYSTEM
   Variáveis CSS e Dark Mode
====================================== */

:root {
  /* Cores primárias - VERMELHO MIPANA */
  --primary: #d32f2f;
  --primary-dark: #b71c1c;
  --primary-light: #ffcdd2;

  /* Cores de status */
  --success: #2e7d32;
  --warning: #f9a825;
  --danger: #d32f2f;

  /* Backgrounds */
  --bg-body: #fafafa;
  --bg-card: #fff;
  --bg-nav: #fff5f5;
  --bg-table-header: #ffebee;

  /* Textos */
  --text-primary: #212121;
  --text-secondary: #666;
  --text-light: #fff;

  /* Bordas e sombras */
  --border-color: #e0e0e0;
  --border-light: #f5f5f5;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);

  /* Transições */
  --transition: all 0.2s ease;
}

/* Dark Mode - Detecta preferência do sistema */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #ef5350;
    --primary-dark: #c62828;
    --primary-light: #4a1a1a;

    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-nav: #2a1a1a;
    --bg-table-header: #2d2020;

    --text-primary: #e0e0e0;
    --text-secondary: #aaa;

    --border-color: #404040;
    --border-light: #333;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

/* Dark Mode manual via atributo */
[data-theme="dark"] {
  --primary: #ef5350;
  --primary-dark: #c62828;
  --primary-light: #4a1a1a;

  --bg-body: #121212;
  --bg-card: #1e1e1e;
  --bg-nav: #2a1a1a;
  --bg-table-header: #2d2020;

  --text-primary: #e0e0e0;
  --text-secondary: #aaa;

  --border-color: #404040;
  --border-light: #333;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Toggle de tema */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 15px;
  border-radius: 50px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  font-size: 1.2rem;
  z-index: 1000;
  transition: var(--transition);
}

.theme-toggle:hover {
  transform: scale(1.1);
}

/* Reset básico */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}



header {
  background: var(--primary);
  color: var(--text-light);
  padding: 1rem;
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: 1px;
}

nav {
  display: none;
  /* Escondido por padrão para evitar FOUC */
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg-nav);
  padding: 0.5rem;
  flex-wrap: wrap;
  max-width: 100%;
}

nav.visible {
  display: flex !important;
  /* Mostrar apenas quando autenticado */
}

nav a {
  display: inline-block;
  /* Garantir que todos os links sejam visíveis */
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 5px;
  transition: var(--transition);
  font-size: 0.9rem;
  white-space: nowrap;
  min-width: fit-content;
}

nav a.active,
nav a:hover {
  background: var(--primary-light);
}

.container {
  max-width: 900px;
  margin: 2rem auto;
  background: var(--bg-card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

input,
select,
button,
textarea {
  font-size: 1rem;
  padding: 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
  width: 100%;
  outline: none;
  transition: var(--transition);
  background: var(--bg-card);
  color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
  border: 1.5px solid var(--primary);
}

button {
  background: var(--primary);
  color: var(--text-light);
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

button:hover {
  background: var(--primary-dark);
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.table th,
.table td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}

.table th {
  background: var(--bg-table-header);
}

.alert {
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-weight: 500;
}

.alert-baixo {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
}

.alert-erro {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-sucesso {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.mesa {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  margin: 12px;
  border-radius: 18px;
  font-size: 1.3em;
  font-weight: bold;
  box-shadow: 0 2px 10px #0001;
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
  user-select: none;
  border: 3px solid #eee;
}

.mesa.livre {
  background: #e8ffe8;
  border-color: #2d6;
  color: #222;
}

.mesa.ocupada {
  background: #fffbe8;
  border-color: #e6b800;
  color: #b8860b;
}

.mesa.fechada {
  background: #ffe8e8;
  border-color: #c00;
  color: #c00;
}

.mesa .status {
  font-size: 1em;
  margin-top: 0.3em;
}

.mesa .valor {
  font-size: 1.1em;
  margin-top: 0.2em;
  color: #222;
}

.btn-grande,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-confirm,
.btn-cancel,
.btn-prod {
  font-size: 1.2em;
  padding: 18px 32px;
  border-radius: 12px;
  margin: 10px 0;
  border: none;
  background: var(--primary);
  color: var(--text-light);
  font-weight: bold;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
}

.btn-grande:active,
.btn-primary:active,
.btn-primary:hover,
.btn-secondary:active,
.btn-secondary:hover,
.btn-success:active,
.btn-success:hover,
.btn-danger:active,
.btn-danger:hover,
.btn-confirm:active,
.btn-cancel:active,
.btn-prod:active {
  background: var(--primary-dark);
  color: var(--text-light);
}

.btn-primary {
  background: var(--primary);
  padding: 12px 24px;
  font-size: 1em;
}

.btn-secondary {
  background: #607d8b;
  padding: 12px 24px;
  font-size: 1em;
}

.btn-success {
  background: var(--success);
  padding: 12px 24px;
  font-size: 1em;
}

.btn-danger {
  background: var(--danger);
  padding: 12px 24px;
  font-size: 1em;
}

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

.btn-cancel {
  background: var(--danger);
}

.btn-prod {
  background: var(--warning);
  color: #222;
  padding: 10px 18px;
  margin: 0 8px;
  font-size: 1.1em;
}

.prod-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 1em 0;
}

.prod-item {
  background: var(--bg-table-header);
  border-radius: 10px;
  padding: 12px 18px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow);
}

.prod-nome {
  font-size: 1.1em;
  font-weight: bold;
  margin-bottom: 8px;
}

.prod-qtd {
  font-size: 1.3em;
  margin: 0 10px;
  min-width: 32px;
  display: inline-block;
  text-align: center;
}

/* Responsividade melhorada */
@media (max-width: 1200px) {
  nav {
    gap: 0.3rem;
  }

  nav a {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 900px) {
  .mesa {
    width: 90px;
    height: 90px;
    font-size: 1em;
  }

  .btn-grande,
  .btn-confirm,
  .btn-cancel,
  .btn-prod {
    font-size: 1em;
    padding: 12px 18px;
  }

  .prod-item {
    min-width: 120px;
    padding: 8px 10px;
  }

  nav {
    gap: 0.2rem;
  }

  nav a {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 600px) {
  .mesa {
    width: 70px;
    height: 70px;
    font-size: 0.9em;
  }

  .btn-grande,
  .btn-confirm,
  .btn-cancel,
  .btn-prod {
    font-size: 0.9em;
    padding: 8px 10px;
  }

  .prod-item {
    min-width: 90px;
    padding: 6px 6px;
  }

  nav {
    flex-direction: column;
    gap: 0.2rem;
    align-items: center;
  }

  nav a {
    width: 90%;
    text-align: center;
    padding: 0.4rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 700px) {
  .container {
    padding: 1rem;
    margin: 1rem;
  }

  header {
    font-size: 1.1rem;
    padding: 0.7rem;
  }
}

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

.modal-content {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}