/* ============================================================
   Pollos Betania · Sistema de diseno (basado en MesaOS v2)
   ============================================================ */

:root {
  --mesa-primary: #2563eb;
  --mesa-primary-hover: #1d4ed8;
  --mesa-primary-light: #eff6ff;
  --mesa-success: #16a34a;
  --mesa-danger: #dc2626;
  --mesa-warning: #f59e0b;
  --mesa-dark: #1e293b;
  --mesa-light: #f8fafc;
  --mesa-border: #e2e8f0;
  --mesa-text: #1e293b;
  --mesa-text-muted: #64748b;
  --mesa-radius: 10px;
  --mesa-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --mesa-shadow-lg: 0 10px 25px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.05);
  --mesa-transition: all .2s ease;
  --sidebar-width: 250px;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--mesa-text);
  overflow-x: hidden;
  font-size: 14px;
  margin: 0;
}

a { color: var(--mesa-primary); }
a:hover { color: var(--mesa-primary-hover); }

/* ============================================================
   LOGIN
   ============================================================ */
.bg-login {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border: 1px solid var(--mesa-border);
  border-radius: 14px;
  padding: 2.5rem 2rem;
  box-shadow: var(--mesa-shadow-lg);
}

.login-logo {
  width: 160px;
  height: 70px;
  background: #fff;
  border: 1px solid var(--mesa-border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  overflow: hidden;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

/* ============================================================
   SIDEBAR LAYOUT
   ============================================================ */
.mesa-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.mesa-sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--mesa-border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .3s ease;
}

.mesa-sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--mesa-border);
}

.mesa-sidebar-header .brand-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--mesa-text);
}

.mesa-sidebar-header .brand-subtitle {
  font-size: 12px;
  color: var(--mesa-text-muted);
  margin-top: 2px;
}

.mesa-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mesa-sidebar-brand .brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--mesa-border);
  object-fit: contain;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}

/* Navigation */
.mesa-sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.mesa-sidebar-nav .nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--mesa-text-muted);
  font-weight: 600;
  padding: 16px 20px 6px;
}

.mesa-sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--mesa-text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--mesa-transition);
  margin: 1px 8px;
  border-radius: 8px;
}

.mesa-sidebar-nav .nav-link:hover {
  background: var(--mesa-primary-light);
  color: var(--mesa-primary);
}

.mesa-sidebar-nav .nav-link.active {
  background: var(--mesa-primary);
  color: #fff;
}

.mesa-sidebar-nav .nav-link .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  flex-shrink: 0;
}

.mesa-sidebar-nav .nav-link.active .nav-icon svg {
  stroke: #fff;
}

/* Sidebar footer */
.mesa-sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--mesa-border);
  text-align: center;
  font-size: 12px;
  color: var(--mesa-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.mesa-sidebar-footer .heart-icon {
  color: var(--mesa-danger);
}

.mesa-sidebar-footer a {
  color: var(--mesa-primary);
  text-decoration: none;
  font-weight: 600;
}

.mesa-sidebar-footer a:hover {
  text-decoration: underline;
}

/* ---- Topbar ---- */
.mesa-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--mesa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1030;
}

.mesa-topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--mesa-text);
}

.mesa-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mesa-topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--mesa-text-muted);
}

.mesa-topbar-user .user-name {
  font-weight: 500;
  color: var(--mesa-text);
}

.mesa-topbar-user .user-role {
  background: var(--mesa-primary-light);
  color: var(--mesa-primary);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

/* ---- Main content ---- */
.mesa-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: 56px;
  min-height: 100vh;
  background: var(--mesa-light);
}

.mesa-content {
  padding: 24px;
}

/* ---- Mobile sidebar toggle ---- */
.mesa-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--mesa-text);
  padding: 4px 8px;
  cursor: pointer;
}

.mesa-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1039;
}

/* ============================================================
   COMPONENTES
   ============================================================ */

/* ---- Cards ---- */
.card {
  border: 1px solid var(--mesa-border);
  border-radius: var(--mesa-radius);
  box-shadow: var(--mesa-shadow);
  background: #fff;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid var(--mesa-border);
  font-weight: 600;
  padding: 14px 20px;
  font-size: 14px;
}

.card-body {
  padding: 20px;
}

/* ---- Stat Cards ---- */
.stat-card {
  background: #fff;
  border: 1px solid var(--mesa-border);
  border-radius: var(--mesa-radius);
  padding: 16px 20px;
  box-shadow: var(--mesa-shadow);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--mesa-text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
}

.stat-card-primary .stat-value { color: var(--mesa-primary); }
.stat-card-warning .stat-value { color: var(--mesa-warning); }
.stat-card-success .stat-value { color: var(--mesa-success); }
.stat-card-danger .stat-value  { color: var(--mesa-danger); }

/* ---- Buttons ---- */
.btn {
  transition: var(--mesa-transition);
  position: relative;
  border-radius: 8px;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--mesa-primary);
  border-color: var(--mesa-primary);
}

.btn-primary:hover {
  background: var(--mesa-primary-hover);
  border-color: var(--mesa-primary-hover);
}

/* ---- Tables ---- */
.table { font-size: 14px; }

.table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--mesa-text-muted);
  font-weight: 600;
  border-bottom-width: 1px;
}

.table td {
  vertical-align: middle;
}

/* ---- Forms ---- */
.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--mesa-border);
  transition: var(--mesa-transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--mesa-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--mesa-text-muted);
}

/* ---- Badges / Status ---- */
.badge {
  font-weight: 500;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
}

.badge-estado {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
}

.badge-pendiente     { background: #fef9c3; color: #854d0e; }
.badge-surtiendo     { background: #dbeafe; color: #1e40af; }
.badge-surtido       { background: #e0e7ff; color: #3730a3; }
.badge-pesado        { background: #d1fae5; color: #065f46; }
.badge-en_ruta       { background: #cffafe; color: #155e75; }
.badge-entregado     { background: #dcfce7; color: #166534; }
.badge-cobrado       { background: #dcfce7; color: #166534; }
.badge-facturado     { background: #dcfce7; color: #166534; }
.badge-cancelado     { background: #fee2e2; color: #991b1b; }

/* ---- Alerts ---- */
.alert {
  border-radius: var(--mesa-radius);
  font-size: 14px;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--mesa-text-muted);
}

.empty-state p {
  margin: 0.5rem 0 0;
  font-size: 14px;
}

/* ---- Modales ---- */
.modal-content {
  border: none;
  border-radius: 14px;
  box-shadow: var(--mesa-shadow-lg);
  overflow: hidden;
}

.modal-header {
  background: var(--mesa-light);
  border-bottom: 1px solid var(--mesa-border);
  padding: 16px 20px;
}

.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }

.modal-footer {
  background: var(--mesa-light);
  border-top: 1px solid var(--mesa-border);
  padding: 12px 20px;
}

/* ---- Animations ---- */
.fade-in {
  animation: fadeIn .35s ease;
}

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  .mesa-sidebar {
    transform: translateX(-100%);
  }
  .mesa-sidebar.open {
    transform: translateX(0);
  }
  .mesa-sidebar-overlay.open {
    display: block;
  }
  .mesa-sidebar-toggle {
    display: block;
  }
  .mesa-topbar {
    left: 0;
  }
  .mesa-main {
    margin-left: 0;
  }
  :root {
    --sidebar-width: 260px;
  }
}

@media (max-width: 575px) {
  .mesa-content {
    padding: 16px 12px;
  }
}

/* ---- Print ---- */
@media print {
  .mesa-sidebar, .mesa-topbar, .mesa-sidebar-overlay { display: none !important; }
  .mesa-main {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }
}