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

:root {
  --gold: #B8860B;
  --gold-dark: #8B6508;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --border: rgba(0,0,0,.10);
  --text: #1a1a1a;
  --text-muted: #666;
  --pend-bg: #FFF3CD; --pend-text: #7d5a00;
  --conf-bg: #d4edda; --conf-text: #155724;
  --canc-bg: #f8d7da; --canc-text: #721c24;
  --sidebar-w: 260px;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── LOGIN ── */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem 2rem; width: 100%; max-width: 380px; text-align: center;
}
.login-card .brand { font-family: 'Playfair Display', serif; font-size: 26px; margin-bottom: 4px; }
.login-card .brand span { color: var(--gold); }
.login-card .subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 2rem; }
.login-field { display: flex; flex-direction: column; gap: 5px; text-align: left; margin-bottom: 14px; }
.login-field label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.login-field input { font-family: 'Poppins', sans-serif; font-size: 14px; padding: 10px 13px; border: 1px solid var(--border); border-radius: 8px; outline: none; }
.login-field input:focus { border-color: var(--gold); }
.btn-login { width: 100%; padding: 11px; background: var(--gold); color: #fff; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; margin-top: 6px; }
.btn-login:hover { opacity: .88; }
.login-error { font-size: 13px; color: #721c24; background: #f8d7da; border-radius: 7px; padding: 8px 12px; margin-top: 12px; display: none; }

/* ── LAYOUT SPA ── */
#adminPanel { display: none; height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 10;
}
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border); }
.sidebar-header .brand { font-family: 'Playfair Display', serif; font-size: 22px; }
.sidebar-header .brand span { color: var(--gold); }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-item {
  width: 100%; text-align: left; background: none; border: none;
  padding: 12px 1.5rem; font-family: 'Poppins', sans-serif; font-size: 13px;
  color: var(--text-muted); cursor: pointer; transition: .2s;
  display: flex; align-items: center; gap: 10px;
}
.nav-item i { width: 20px; text-align: center; font-size: 15px; }
.nav-item:hover { background: #faf8f2; color: var(--gold-dark); }
.nav-item.active { background: #f5f0e8; color: var(--gold-dark); font-weight: 600; border-right: 3px solid var(--gold); }
.nav-divider { padding: 1rem 1.5rem 5px; font-size: 11px; font-weight: 600; color: #999; text-transform: uppercase; letter-spacing: 1px; }

.sidebar-footer { padding: 1.5rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.user-pill { font-size: 11px; background: #f5f0e8; border: 1px solid #e2d5b0; border-radius: 999px; padding: 4px 10px; color: var(--gold-dark); font-weight: 600; width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { font-size: 12px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: transparent; cursor: pointer; color: var(--text-muted); transition: .2s; width: 100%; }
.btn-logout:hover { background: #f8d7da; border-color: #f0b8bb; color: #721c24; }

.main-content {
  margin-left: var(--sidebar-w);
  padding: 2rem;
  height: 100vh;
  overflow-y: auto;
}

.view-section { display: none; animation: fadeIn .3s ease; }
.view-section.active { display: block; }

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

.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.view-header h2 { font-family: 'Playfair Display', serif; font-size: 28px; }

/* ── STATS & TABS & TOOLBAR ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.02); }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-val { font-size: 28px; font-weight: 600; }
.stat-val.pend { color: #7d5a00; }
.stat-val.conf { color: #155724; }
.stat-val.canc { color: #721c24; }

.tabs { display: flex; gap: 8px; margin-bottom: 1rem; }
.tabs button { padding: 7px 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 13px; cursor: pointer; transition: .2s; }
.tabs button.active { background: var(--gold); color: #fff; border-color: var(--gold); }
.tabs button:hover:not(.active) { border-color: var(--gold); color: var(--gold); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; flex-wrap: wrap; }
.toolbar input, .toolbar select { font-family: 'Poppins', sans-serif; font-size: 13px; padding: 9px 15px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: .2s; }
.toolbar input { min-width: 250px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--gold); }
.btn-new { margin-left: auto; background: var(--gold); color: #fff; border: none; border-radius: 8px; padding: 10px 20px; font-weight: 600; cursor: pointer; transition: .2s; }
.btn-new:hover { opacity: .88; }

/* ── TABLE ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; max-height: calc(100vh - 350px); overflow-y: auto; box-shadow: 0 4px 15px rgba(0,0,0,0.02); }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; padding: 14px 18px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; background: #fafaf8; position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid rgba(0,0,0,.05); transition: background .1s; }
tbody tr:hover { background: #faf8f2; }
td { padding: 14px 18px; vertical-align: middle; font-size: 13px; }
.td-name { font-weight: 600; color: var(--text); }
.td-tel, .td-obs { color: var(--text-muted); }
.td-obs { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.chip.pend { background: var(--pend-bg); color: var(--pend-text); }
.chip.conf { background: var(--conf-bg); color: var(--conf-text); }
.chip.canc { background: var(--canc-bg); color: var(--canc-text); }
.actions { display: flex; gap: 6px; }
.btn-act { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: transparent; cursor: pointer; transition: .2s; }
.btn-act:hover { background: #f5f0e8; border-color: var(--gold); }
.btn-act.conf-btn { color: #155724; border-color: #b8dfc0; }
.btn-act.conf-btn:hover { background: var(--conf-bg); }
.btn-act.canc-btn { color: #721c24; border-color: #f0b8bb; }
.btn-act.canc-btn:hover { background: var(--canc-bg); }
.btn-act.del-btn:hover { background: var(--canc-bg); border-color: #f0b8bb; color: #721c24; }
.loading-row td { text-align: center; padding: 3rem; color: var(--text-muted); }

/* ── MENUS GRID ── */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.menu-admin-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.menu-admin-img { width: 100%; height: 160px; object-fit: cover; background: #eee; }
.menu-admin-content { padding: 1.2rem; flex: 1; }
.menu-admin-content h3 { font-family: 'Playfair Display', serif; font-size: 18px; margin-bottom: 10px; color: var(--gold-dark); }
.menu-admin-stats { font-size: 12px; color: var(--text-muted); margin-bottom: 15px; }
.menu-admin-actions { display: flex; gap: 8px; border-top: 1px solid var(--border); padding: 1rem 1.2rem; background: #fafaf8; }
.menu-admin-actions button { flex: 1; padding: 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: .2s; font-size: 12px; font-weight: 600; }
.menu-admin-actions button:hover { border-color: var(--gold); color: var(--gold-dark); }
.menu-admin-actions button.del-btn:hover { border-color: #f0b8bb; color: #721c24; background: var(--canc-bg); }

/* ── MODALS ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border-radius: 16px; border: 1px solid var(--border); padding: 2rem; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.1); }
.modal.modal-lg { max-width: 700px; }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-header h3 { font-family: 'Playfair Display', serif; font-size: 22px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea { font-family: inherit; font-size: 13px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; outline: none; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--gold); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 2rem; }
.btn-secondary { padding: 10px 20px; border: 1px solid var(--border); border-radius: 8px; background: transparent; cursor: pointer; }
.btn-primary { padding: 10px 20px; background: var(--gold); color: #fff; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* ── DYNAMIC MENU ITEMS EDITOR ── */
.menu-items-editor { background: #fdfdfc; border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem; }
.editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.editor-header h4 { font-size: 15px; color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 11px; border: 1px solid var(--gold); background: #fffcf5; color: var(--gold-dark); border-radius: 6px; cursor: pointer; font-weight: 600; }
.menu-item-row { display: grid; grid-template-columns: 1.5fr 1fr 2fr auto; gap: 10px; margin-bottom: 10px; background: var(--surface); padding: 10px; border: 1px solid #eaeaea; border-radius: 8px; align-items: start; }
.menu-item-row input { font-size: 12px; padding: 8px; width: 100%; border: 1px solid var(--border); border-radius: 6px; }
.menu-item-row .btn-remove { padding: 8px 12px; background: #f8d7da; color: #721c24; border: none; border-radius: 6px; cursor: pointer; }

/* ── MOBILE HEADER BAR ── */
.mobile-header-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 15;
}
.mobile-header-bar .brand {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 600;
}
.mobile-header-bar .brand span {
  color: var(--gold);
}
.btn-toggle-sidebar {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── RESPONSIVE MEDIA QUERIES ── */
@media (max-width: 900px) {
  .mobile-header-bar {
    display: flex;
  }
  
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    height: 100vh;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  }
  
  .sidebar.sidebar-open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
    padding-top: 80px; /* Leaves space for mobile header bar */
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .table-wrap table {
    min-width: 850px; /* Ensures table remains legible with horizontal scroll */
  }
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .modal {
    padding: 1.5rem 1.2rem;
  }
  
  .modal-footer {
    margin-top: 1.5rem;
    flex-direction: column;
    gap: 8px;
  }
  
  .modal-footer button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stats {
    grid-template-columns: 1fr;
  }
  
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .toolbar input, .toolbar select, .btn-new {
    width: 100%;
    margin-left: 0;
  }
  
  .tabs {
    flex-wrap: wrap;
  }
  
  .tabs button {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }
}

/* Mismo sistema visual que la landing: crema, café, acento naranja y serif. */
:root {--gold:var(--santes-orange);--gold-dark:var(--santes-orange-hover);--bg:var(--santes-cream);--surface:var(--santes-paper);--border:var(--santes-border);--text:var(--santes-coffee);--text-muted:var(--santes-muted)}
body {font-family:var(--fuente-cuerpo)}
#loginScreen {background:linear-gradient(#30231d99,#30231dc9),url('../img/optimized/hero.webp') center 57%/cover}
.login-card {max-width:430px;padding:36px;border-radius:var(--santes-radius);box-shadow:0 20px 80px #0003}
.login-home img {border-radius:50%;margin-bottom:14px}.login-card .brand{font-size:32px}
.back-link{display:inline-block;margin-top:24px;font-size:13px;color:var(--gold-dark);text-underline-offset:4px}
.sidebar {background:var(--santes-coffee);color:var(--santes-paper);border-color:#ffffff26}
.sidebar-header {display:flex;gap:12px;align-items:center;border-color:#ffffff26}.sidebar-logo img{border-radius:50%;display:block;min-width:44px}
.sidebar-header .brand {font-size:21px}.sidebar-header .brand span{color:var(--santes-gold)}
.sidebar-nav{padding:20px 12px}.nav-item{color:#ecdfce;border-radius:10px;margin-bottom:7px;padding:14px 12px}.nav-item:hover{background:#ffffff12;color:#ffddb1}.nav-item.active{background:#a64d12;color:white;border-right:0}.nav-divider{color:#d6b995;padding-left:12px}
.sidebar-footer{border-color:#ffffff26}.btn-logout{color:#f6e5d2;border-color:#ffffff50}.user-pill{background:#49362b;color:#f3d0a0;border-color:#705742}
.admin-welcome{background:var(--santes-coffee);color:white;border-radius:var(--santes-radius);padding:32px;margin-bottom:30px;display:flex;justify-content:space-between;gap:20px;align-items:center}
.admin-welcome p{font-size:10px;letter-spacing:2px;color:#e5bc87;margin-bottom:10px}.admin-welcome h1{font:700 clamp(24px,3vw,36px)/1.25 var(--fuente-titulos)}.admin-welcome a{color:#f3d0a0;white-space:nowrap}
#admin-status:not(:empty){padding:16px;background:#fff3cd;color:#735000;border-radius:10px;margin-bottom:20px}
.stat-card,.table-wrap,.menu-admin-card,.modal{border-radius:var(--santes-radius)}.stat-card{border-top:3px solid #d6af73}.stat-label{font-size:12px}.stat-val{font-family:var(--fuente-titulos);font-size:34px}
button {min-height:44px}.btn-act{min-width:44px}.login-field input,.toolbar input,.toolbar select,.form-group input,.form-group select,.form-group textarea{min-height:46px;font-size:16px}
.login-field input:focus-visible,.toolbar input:focus-visible,.toolbar select:focus-visible,.form-group input:focus-visible,.form-group select:focus-visible,.form-group textarea:focus-visible{outline:3px solid #be6c2f;outline-offset:3px}
.table-wrap{max-height:65vh}.menu-grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,280px),1fr))}.empty-row td{text-align:center;padding:40px;color:var(--text-muted)}
.view-header{gap:16px;flex-wrap:wrap}.view-header h2{font-size:26px}.toolbar input{min-width:0;flex:1}.menu-item-row>*{min-width:0}.editor-header{gap:12px;flex-wrap:wrap}
@media(max-width:900px){.sidebar{top:60px;height:calc(100dvh - 60px);visibility:hidden}.sidebar.sidebar-open{visibility:visible}.mobile-header-bar{background:var(--santes-coffee);color:white}.btn-toggle-sidebar{color:white}.mobile-header-bar .brand span{color:var(--santes-gold)}.main-content{height:100dvh}.admin-welcome{padding:24px}}
@media(max-width:600px){.main-content{padding-inline:16px}.admin-welcome{align-items:start;flex-direction:column}.stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.stat-card{padding:16px}.menu-item-row{grid-template-columns:1fr}.menu-items-editor{padding:12px}.login-card{padding:28px 24px}.modal{max-height:90dvh}}
/* Subida de fotografías, confirmación y avisos (sustituyen a SweetAlert). */
.image-picker{display:flex;gap:14px;align-items:flex-start;flex-wrap:wrap}
.image-preview{width:160px;height:110px;object-fit:cover;border-radius:12px;border:1px solid var(--border);background:#f3ece1}
.image-picker-actions{display:flex;flex-direction:column;gap:8px;flex:1;min-width:200px}
#btnQuitarImagen{align-self:flex-start;padding-inline:16px}
.image-picker-actions input[type=file]{min-height:auto;padding:8px;font-size:14px}
.image-help{font-size:12px;color:var(--text-muted)}
.image-help.is-error,.form-error{color:var(--canc-text)}
.form-error{font-size:13px;margin-top:1rem}
.btn-danger{background:#a3262f}.btn-danger:hover{background:#861d25}
.toast{position:fixed;right:1rem;bottom:1rem;z-index:300;max-width:min(380px,calc(100% - 2rem));padding:14px 18px;border-radius:12px;background:var(--santes-coffee);color:#fff;font-size:14px;box-shadow:0 10px 30px #0003}
.toast.is-error{background:#721c24}
.menu-admin-img.sin-imagen{display:flex;align-items:center;justify-content:center;color:var(--text-muted);font-size:13px}
.menu-empty{grid-column:1/-1;text-align:center;padding:2rem;color:var(--text-muted)}
