@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;700&display=swap');

/* --- DESIGN SYSTEM & CSS VARIABLES (IDÊNTICO À FOTO 2 DO DESKTOP) --- */
:root {
  --font-sans: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --sidebar-width: 280px;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.1);
  --success: #10b981;
  --success-hover: #059669;
  --success-light: rgba(16, 185, 129, 0.12);
  --danger: #f43f5e;
  --danger-hover: #e11d48;
  --danger-light: rgba(244, 63, 94, 0.12);
  --warning: #f97316;
  --warning-hover: #ea580c;
  --warning-light: rgba(249, 115, 22, 0.12);
}

[data-theme="light"] {
  --bg-app: #f3f4f6;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f9fafb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-sidebar: #111827;
  --bg-card: #1f2937;
  --bg-input: #374151;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
}

/* RESET & BASE */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-normal);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* LAYOUT CONTAINER */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* --- SIDEBAR DESKTOP (100% FIEL À FOTO 2) --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition-normal), background-color var(--transition-normal);
}

.sidebar-header {
  margin-bottom: 24px;
  padding: 0 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
}
.brand-name .highlight { color: var(--primary); }

.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
  overflow-y: auto;
}

/* MENU ITEM DESTAQUE IDÊNTICO À FOTO 2 */
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: var(--border-radius-md);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
}

.menu-item:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.menu-item.active {
  background-color: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.menu-item.active .menu-icon {
  stroke: #ffffff !important;
}

.menu-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.2px;
  flex-shrink: 0;
}

/* SIDEBAR FOOTER & USER WIDGET */
.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-input);
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.9rem;
}

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

.user-name-display {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.user-role-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-fast);
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
}

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

.sidebar-copyright {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* --- MAIN WRAPPER --- */
.main-wrapper {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOP BAR (IDÊNTICO À FOTO 2) */
.top-bar {
  height: 64px;
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-mobile-menu {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 6px;
}

.mobile-brand { display: none; }

.page-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.caixa-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.caixa-status-badge.open {
  background-color: var(--success-light);
  color: var(--success);
}

.caixa-status-badge.closed {
  background-color: var(--danger-light);
  color: var(--danger);
}

.badge-dot {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
}

.header-clock {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* CONTENT BODY */
.content-body {
  padding: 24px;
  flex-grow: 1;
}

.content-panel {
  display: none;
  animation: fadeIn 0.25s ease;
}

.content-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- TOP 3 KPI CARDS (100% IDÊNTICO À FOTO 2) --- */
.kpi-grid-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card-white {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card-white:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-left {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.kpi-value-big {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-sub-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-icon-pill {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.kpi-icon-pill.blue { background: rgba(99, 102, 241, 0.12); color: var(--primary); }
.kpi-icon-pill.green { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.kpi-icon-pill.orange { background: rgba(249, 115, 22, 0.12); color: var(--warning); }

/* GRID CENTRAL */
.grid-two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

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

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.quick-actions-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--border-radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-block { width: 100%; }
.btn-lg { min-height: 48px; font-size: 1rem; }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  min-height: 32px;
  border-radius: 20px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-outline {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-outline:hover { background-color: var(--bg-input); }

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background-color: #e5e7eb; }

/* TABLES (IDÊNTICAS À FOTO 2) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.data-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
  color: var(--text-main);
}

.data-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.015);
}

.prod-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 28px !important;
}

/* BADGES & UTILS */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-success { background: var(--success-light); color: var(--success); }

.text-danger { color: var(--danger) !important; font-weight: 700; }
.text-success { color: var(--success) !important; font-weight: 700; }
.text-muted { color: var(--text-muted); }

.table-summary-bar {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  background-color: var(--bg-input);
  border-radius: var(--border-radius-md);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.search-input-box {
  position: relative;
  flex-grow: 1;
  max-width: 500px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
  width: 100%;
  min-height: 42px;
}

.form-control.pl-icon { padding-left: 40px; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
  min-width: 180px;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.filter-buttons { display: flex; gap: 8px; }

/* DRE CONTAINER */
.dre-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dre-line {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  background-color: var(--bg-input);
  border-radius: var(--border-radius-md);
  font-size: 0.9rem;
}

.dre-line.highlight {
  border-left: 4px solid var(--warning);
  font-weight: 600;
}

.dre-line.total {
  background-color: rgba(16, 185, 129, 0.1);
  border-left: 4px solid var(--success);
  font-weight: 700;
  font-size: 1.05rem;
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-dialog.modal-lg { max-width: 760px; }

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { font-size: 1.2rem; font-weight: 700; }
.btn-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 20px; overflow-y: auto; flex-grow: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* MOBILE TOUCH NAVIGATION */
.mobile-touch-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background-color: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  z-index: 200;
  justify-content: space-around;
  align-items: center;
}

.touch-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  gap: 3px;
  cursor: pointer;
  flex-grow: 1;
  height: 100%;
}

.touch-nav-item i { font-size: 1.2rem; }
.touch-nav-item.active { color: var(--primary); font-weight: 700; }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 10px 0 30px rgba(0,0,0,0.3); }
  .main-wrapper { margin-left: 0; padding-bottom: 70px; }
  .btn-mobile-menu { display: block; }
  .mobile-brand { display: block; }
  .top-bar { padding: 0 16px; }
  .content-body { padding: 16px; }
  .mobile-touch-nav { display: flex; }
  .kpi-grid-three { grid-template-columns: 1fr; }
  .grid-two-columns { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
