/* ===========================
   ADRI DIVINO SABOR – STYLES
   =========================== */

:root {
  --primary: #C0392B;
  --primary-dark: #922B21;
  --primary-light: #E74C3C;
  --accent: #D35400;
  --warm: #E8927C;
  --cream: #FDF6F0;
  --cream-dark: #F5E6DC;
  --brown: #5D2E1F;
  --text: #2C1810;
  --text-muted: #8B6355;
  --white: #FFFFFF;
  --success: #27AE60;
  --warning: #F39C12;
  --danger: #E74C3C;
  --border: #E8D5CC;
  --shadow: 0 2px 12px rgba(192,57,43,0.1);
  --shadow-md: 0 4px 24px rgba(192,57,43,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 40%, var(--accent) 100%);
  z-index: 0;
}

.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 70%, rgba(255,255,255,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 20%, rgba(255,200,150,0.12) 0%, transparent 50%);
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--white);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  margin: 1rem;
}

.login-logo { text-align: center; margin-bottom: 2rem; }

.logo-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 1rem;
  overflow: hidden;
  border: 3px solid var(--primary);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-circle img { width: 100%; height: 100%; object-fit: cover; }
.logo-fallback { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.logo-emoji { font-size: 2.5rem; }

.login-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  color: var(--primary-dark);
  font-weight: 700;
}
.login-brand span { color: var(--accent); font-style: italic; }
.login-tagline { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  background: var(--cream);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
  background: var(--white);
}

.login-error {
  background: #FFF0EE;
  color: var(--danger);
  border: 1px solid #FCCAC5;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.btn-login {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(192,57,43,0.35);
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(192,57,43,0.45); }
.btn-login:active { transform: translateY(0); }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
  background: var(--cream);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; }
.sb-fallback { font-size: 1.5rem; }

.sidebar-brand { flex: 1; }
.brand-name { display: block; font-family: 'Playfair Display', serif; font-weight: 700; color: var(--white); font-size: 1rem; }
.brand-sub { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.6); font-style: italic; }

.sidebar-close {
  display: none;
  background: none; border: none;
  color: rgba(255,255,255,0.6); font-size: 1.1rem;
  cursor: pointer; padding: 0.25rem;
}

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active { background: rgba(255,255,255,0.12); color: var(--white); border-left-color: var(--warm); }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--warm); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
}
.user-name { display: block; font-size: 0.85rem; color: var(--white); font-weight: 600; }
.user-role { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.5); }
.btn-logout {
  width: 100%; padding: 0.5rem;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  font-size: 0.8rem; cursor: pointer;
  transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); color: var(--white); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left 0.3s;
}

.topbar {
  background: var(--white);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: relative;
}

.hamburger {
  display: none;
  background: none; border: none;
  font-size: 1.4rem; cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem;
}

.page-title { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--primary-dark); flex: 1; }
.date-display { font-size: 0.8rem; color: var(--text-muted); }

/* ===== TABS ===== */
.tab-content { display: none; padding: 1.5rem; }
.tab-content.active { display: block; }

.tab-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.75rem; }
.section-title { font-family: 'Playfair Display', serif; font-size: 1.3rem; color: var(--primary-dark); }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.success { border-left-color: var(--success); }

.stat-icon { font-size: 1.8rem; }
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat-label { display: block; font-size: 0.75rem; color: var(--text-muted); }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-title { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); margin-bottom: 1rem; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th { background: var(--cream-dark); color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.75rem 1rem; text-align: left; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--cream); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-success { background: #D5F5E3; color: #1E8449; }
.badge-warning { background: #FEF9E7; color: #B7770D; }
.badge-danger { background: #FADBD8; color: #C0392B; }
.badge-info { background: #D6EAF8; color: #1A5276; }
.badge-neutral { background: var(--cream-dark); color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 0.6rem 1.2rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(192,57,43,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(192,57,43,0.4); }

.btn-secondary {
  padding: 0.6rem 1.2rem;
  background: var(--cream-dark);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border); }

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
}
.btn-edit { background: #EBF5FB; color: #1A5276; }
.btn-edit:hover { background: #D6EAF8; }
.btn-delete { background: #FADBD8; color: var(--primary-dark); }
.btn-delete:hover { background: #F1948A; color: var(--white); }
.btn-view { background: #EAFAF1; color: #1E8449; }
.btn-view:hover { background: #D5F5E3; }

/* ===== FORM LAYOUT ===== */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-bar select {
  padding: 0.5rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.filter-bar select:focus { border-color: var(--primary); }

/* ===== ORDER ITEMS SELECTOR ===== */
.products-selector { background: var(--cream); border-radius: var(--radius-sm); padding: 1rem; margin: 1rem 0; }
.products-selector h4 { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

.product-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--white); border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem; margin-bottom: 0.5rem;
  border: 1.5px solid var(--border);
}
.product-item:last-child { margin-bottom: 0; }
.product-item-name { flex: 1; font-size: 0.88rem; font-weight: 500; }
.product-item-price { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.product-item input[type="number"] {
  width: 60px; padding: 0.3rem 0.5rem;
  border: 1.5px solid var(--border); border-radius: 6px;
  text-align: center; font-size: 0.88rem;
  background: var(--white);
}
.product-item input[type="number"]:focus { border-color: var(--primary); outline: none; }

.order-total-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--primary-dark); color: var(--white);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  font-weight: 600; margin-bottom: 1rem;
}
.total-value { font-size: 1.2rem; font-family: 'Playfair Display', serif; }

/* ===== MODALS ===== */
.modal {
  position: fixed; inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  }
.modal-box {
  position: relative;
  z-index: 100000;
  background: var(--white); border-radius: 16px;
  width: 100%; max-width: 480px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.25s ease;
  
}
.modal-box.large { max-width: 680px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.97); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-family: 'Playfair Display', serif; color: var(--primary-dark); font-size: 1.15rem; }
.modal-header button { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); padding: 0.2rem; }
.modal-header button:hover { color: var(--text); }

.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ===== FINANCE ===== */
.finance-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.5rem;
}
.finance-card {
  background: var(--white); border-radius: var(--radius); padding: 1.1rem;
  box-shadow: var(--shadow); text-align: center;
}
.finance-card .fin-value { font-size: 1.3rem; font-weight: 700; font-family: 'Playfair Display', serif; color: var(--text); display: block; }
.finance-card .fin-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.finance-card.profit .fin-value { color: var(--success); }
.finance-card.expense .fin-value { color: var(--danger); }

.finance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ===== OVERLAY ===== */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 90; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  background: var(--primary-dark); color: var(--white);
  padding: 0.75rem 1.25rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== LOW STOCK LIST ===== */
.low-stock-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.low-stock-item:last-child { border-bottom: none; }
.low-stock-qty { font-weight: 700; color: var(--danger); }

/* ===== RECENT ORDERS ===== */
.recent-order-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.recent-order-item:last-child { border-bottom: none; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .overlay.open { display: block; }
  .hamburger { display: block; }
  .main-content { margin-left: 0; }
  .tab-content { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .finance-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal { padding: 0.5rem; align-items: flex-end; }
  .modal-box { border-radius: 16px 16px 0 0; max-height: 95vh; }
  .modal-box.large { max-width: 100%; }
  .stat-value { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 0.85rem; }
  .stat-icon { font-size: 1.4rem; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.6rem 0.6rem; }
}

/* ===== RANKING ===== */
.ranking-bar { margin-bottom: 1.5rem; }
.ranking-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.ranking-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  border-bottom: 3px solid var(--primary);
  transition: transform 0.15s;
}
.ranking-card:first-child { border-bottom-color: #FFD700; }
.ranking-card:nth-child(2) { border-bottom-color: #C0C0C0; }
.ranking-card:nth-child(3) { border-bottom-color: #CD7F32; }
.ranking-card:hover { transform: translateY(-2px); }
.rank-medal { font-size: 2rem; line-height: 1; }
.rank-info { display: flex; flex-direction: column; gap: 0.1rem; }
.rank-info strong { font-size: 0.95rem; color: var(--text); }
.rank-info span { font-size: 0.75rem; color: var(--text-muted); }
.rank-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-dark);
  font-family: 'Playfair Display', serif;
  margin-top: 0.25rem;
}

@media (max-width: 600px) {
  .ranking-grid { grid-template-columns: 1fr; }
  .ranking-card { flex-direction: row; text-align: left; }
  .rank-medal { font-size: 1.5rem; }
}

/* ===== BADGE INFO ===== */
.badge-info { background: #D6EAF8; color: #1A5276; }
