@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --cream: #faf7f2;
  --blush: #f2e4dc;
  --rose: #c9847a;
  --rose-dark: #a8635a;
  --rose-light: #f5e6e3;
  --sage: #8a9e8c;
  --sage-light: #d4e0d5;
  --charcoal: #2c2c2c;
  --charcoal-soft: #3d3d3d;
  --mid: #6b6b6b;
  --light: #b0b0b0;
  --lighter: #d8d8d8;
  --white: #ffffff;
  --success: #6aaa7a;
  --success-light: #e8f5e9;
  --warning: #e8a857;
  --warning-light: #fff8ee;
  --danger: #c0392b;
  --danger-light: #fdecea;
  --admin: #5b7fa6;
  --admin-light: #e8f0f8;
  --border: #e8e0d8;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--charcoal);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* TYPOGRAPHY */
.font-display { font-family: 'Cormorant Garamond', serif; }
h1 { font-family: 'Cormorant Garamond', serif; font-size: 28px; font-weight: 500; }
h2 { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 500; }
h3 { font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 500; }

/* HEADER */
.app-header {
  background: var(--charcoal);
  color: var(--cream);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.brand-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-style: italic;
  color: var(--blush);
  white-space: nowrap;
}
.brand-dot { width: 5px; height: 5px; background: var(--rose); border-radius: 50%; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-link:hover { color: white; background: rgba(255,255,255,0.08); }
.nav-link.active { color: var(--cream); background: rgba(255,255,255,0.12); }
.nav-link .nav-icon { font-size: 14px; }

.header-right { display: flex; align-items: center; gap: 8px; }
.sync-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  color: var(--light);
  transition: all 0.3s;
}
.sync-pill.ok { color: var(--success); background: rgba(106,170,122,0.15); }
.sync-pill.err { color: #e07070; background: rgba(224,112,112,0.15); }

.user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 4px 12px 4px 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 12px;
}
.user-pill:hover { background: rgba(255,255,255,0.14); }
.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--rose);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.role-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
}
.role-admin { background: var(--admin); color: white; }
.role-emp { background: var(--sage); color: white; }

.fullscreen-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: rgba(255,255,255,0.08);
  border-radius: 6px; cursor: pointer; color: rgba(255,255,255,0.6);
  font-size: 13px; transition: all 0.2s;
}
.fullscreen-btn:hover { background: rgba(255,255,255,0.14); color: white; }

/* INPUTS */
.input, input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--charcoal);
  background: var(--cream);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  appearance: none;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--rose);
  background: white;
}
.input-sm { padding: 7px 11px; font-size: 12px; }
.input-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
  display: block;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--charcoal); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--charcoal-soft); }
.btn-rose { background: var(--rose); color: white; }
.btn-rose:hover:not(:disabled) { background: var(--rose-dark); }
.btn-ghost { background: transparent; color: var(--mid); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--charcoal); color: var(--charcoal); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-admin { background: var(--admin); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 24px; font-size: 15px; width: 100%; }
.btn-icon { padding: 8px; border-radius: 50%; aspect-ratio: 1; }

/* CARDS */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: var(--rose); box-shadow: var(--shadow); }
.card-flat { background: var(--cream); border: none; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-pending { background: #fff3cd; color: #856404; }
.badge-prod { background: #cfe2ff; color: #084298; }
.badge-ready { background: var(--success-light); color: #0f5132; }
.badge-sent { background: var(--sage-light); color: #2d5a3d; }
.badge-delivered { background: #e8f5e9; color: #2e7d32; }
.badge-cancelled { background: #fdecea; color: #c0392b; }

/* DIFICULTAD */
.dif-sf { background: #e8f5e9; color: #4caf50; }
.dif-f  { background: #e3f2fd; color: #2196f3; }
.dif-m  { background: #fff3e0; color: #ff9800; }
.dif-d  { background: #fce4ec; color: #e91e63; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s;
  box-shadow: var(--shadow-lg);
}
.modal-overlay.show .modal-box { transform: scale(1) translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: 'Cormorant Garamond', serif; font-size: 22px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--light); padding: 4px; border-radius: 6px; }
.modal-close:hover { color: var(--charcoal); background: var(--cream); }

/* SIDE DRAWER */
.drawer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 400;
  display: flex; justify-content: flex-end;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.drawer.show { opacity: 1; pointer-events: all; }
.drawer-content {
  width: 460px; max-width: 100%;
  background: white;
  height: 100%;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex; flex-direction: column;
}
.drawer.show .drawer-content { transform: translateX(0); }
.drawer-header {
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 2;
}
.drawer-body { padding: 20px 22px; flex: 1; }

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--charcoal);
  color: white;
  padding: 11px 20px;
  border-radius: 30px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s;
  max-width: 320px;
  text-align: center;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warning); color: var(--charcoal); }

/* LOADING */
.loading-screen {
  position: fixed; inset: 0;
  background: rgba(250,247,242,0.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1000;
  gap: 16px;
  transition: opacity 0.3s;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--rose);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* STATUS ESTADOS */
.est-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.est-btn {
  flex: 1; min-width: 60px;
  padding: 6px 4px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 11px; font-weight: 500;
  color: var(--mid);
  transition: all 0.2s;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
}
.est-btn.active { color: white; border-color: transparent; }
.est-btn[data-est="pendiente"].active  { background: var(--warning); }
.est-btn[data-est="produccion"].active { background: #5b9bd5; }
.est-btn[data-est="listo"].active      { background: var(--success); }
.est-btn[data-est="enviado"].active    { background: var(--sage); }
.est-btn[data-est="entregado"].active  { background: #2e7d32; }
.est-btn[data-est="cancelado"].active  { background: var(--danger); }

/* FORM GRID */
.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-full { grid-column: 1 / -1; }

/* TABS */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--cream);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.tab-item {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px; font-weight: 500;
  color: var(--mid);
  transition: all 0.2s;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
}
.tab-item.active { background: white; color: var(--charcoal); box-shadow: var(--shadow-sm); }

/* SEARCH BAR */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 36px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--light); font-size: 14px; pointer-events: none;
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--light);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 13px; color: var(--mid); }

/* RESPONSIVE */
@media (max-width: 768px) {
  .header-nav { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .drawer-content { width: 100%; }
}
@media (max-width: 480px) {
  .app-header { padding: 0 14px; }
  .brand-name { font-size: 16px; }
}

/* ===== MOBILE NAV SIDEBAR ===== */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 20px;
  width: 46px;
  height: 46px;
  background: var(--charcoal);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.mobile-nav-toggle:hover { background: var(--charcoal-soft); transform: scale(1.05); }

.mobile-sidebar {
  position: fixed;
  inset: 0;
  z-index: 350;
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.mobile-sidebar.show { opacity: 1; pointer-events: all; }
.mobile-sidebar-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.mobile-sidebar-content {
  position: relative;
  width: 260px;
  background: var(--charcoal);
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 1;
}
.mobile-sidebar.show .mobile-sidebar-content { transform: translateX(0); }
.mobile-sidebar-header {
  padding: 28px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.mobile-sidebar-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-style: italic;
  color: var(--blush);
  margin-bottom: 4px;
}
.mobile-sidebar-user {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}
.mobile-nav-links {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.mobile-nav-link:hover { color: white; background: rgba(255,255,255,0.06); }
.mobile-nav-link.active { color: var(--blush); background: rgba(201,132,122,0.12); border-left-color: var(--rose); }
.mobile-nav-icon { font-size: 18px; width: 24px; text-align: center; }
.mobile-sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* FLOATING PEDIDOS BUTTON */
.fab-pedidos {
  position: fixed;
  bottom: 24px;
  right: 20px;
  background: var(--rose);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(201,132,122,0.45);
  transition: all 0.2s;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 7px;
}
.fab-pedidos:hover { background: var(--rose-dark); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(201,132,122,0.5); }

@media (max-width: 768px) {
  .mobile-nav-toggle { display: flex; }
  .header-nav { display: none !important; }
  .fullscreen-btn { display: none !important; }
}
