/* ===================================================
   A13 - Mobile-first PWA Styles
   =================================================== */

:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light:#dbeafe;
  --success:      #16a34a;
  --success-light:#dcfce7;
  --danger:       #dc2626;
  --danger-light: #fee2e2;
  --warning:      #d97706;
  --warning-light:#fef3c7;
  --info:         #0891b2;
  --info-light:   #cffafe;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-300:     #d1d5db;
  --gray-400:     #9ca3af;
  --gray-500:     #6b7280;
  --gray-600:     #4b5563;
  --gray-700:     #374151;
  --gray-800:     #1f2937;
  --gray-900:     #111827;
  --white:        #ffffff;
  --nav-h:        64px;
  --header-h:     56px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:    0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition:   .2s ease;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── Header ─────────────────────────────────────── */
#app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
#app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
}
#app-header .header-actions { display: flex; gap: 8px; align-items: center; }
#app-header .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  cursor: pointer;
}

/* ── Main content ────────────────────────────────── */
#app-main {
  padding-top: calc(var(--header-h) + 12px);
  padding-bottom: calc(var(--nav-h) + 16px);
  padding-left: 12px;
  padding-right: 12px;
  min-height: 100vh;
}

/* ── Bottom Navigation ───────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--gray-400);
  font-size: .65rem;
  font-weight: 500;
  transition: color var(--transition);
  padding: 6px 2px;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--primary); }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* ── Sections ────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--gray-700);
}

/* ── Stat cards (dashboard) ──────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card .stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.stat-card .stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
}
.stat-card .stat-label {
  font-size: .75rem;
  color: var(--gray-500);
}
.stat-bg-blue   { background: var(--primary-light); }
.stat-bg-green  { background: var(--success-light); }
.stat-bg-red    { background: var(--danger-light); }
.stat-bg-yellow { background: var(--warning-light); }

/* ── Room grid ───────────────────────────────────── */
.rooms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.room-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 2px solid transparent;
}
.room-card:active { transform: scale(.97); }
.room-card.occupied { border-color: var(--primary-light); }
.room-card.full     { border-color: var(--success-light); }
.room-card .room-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}
.room-card .room-label {
  font-size: .7rem;
  color: var(--gray-500);
  margin-top: 2px;
}
.room-card .room-price {
  font-size: .9rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 8px;
}
.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .65rem;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 600;
  margin-top: 6px;
}
.badge-free     { background: var(--gray-100); color: var(--gray-500); }
.badge-occupied { background: var(--primary-light); color: var(--primary-dark); }
.badge-full     { background: var(--success-light); color: var(--success); }

/* ── List items ──────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item .item-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
  flex-shrink: 0;
}
.list-item .item-body { flex: 1; min-width: 0; }
.list-item .item-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .item-sub {
  font-size: .75rem;
  color: var(--gray-500);
  margin-top: 2px;
}
.list-item .item-right {
  text-align: right;
  flex-shrink: 0;
}
.list-item .item-amount {
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-800);
}
.list-item .item-date {
  font-size: .72rem;
  color: var(--gray-400);
}

/* ── Tabs ────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-500);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}
.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* ── FAB ─────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  z-index: 99;
  transition: transform var(--transition), box-shadow var(--transition);
}
.fab:active { transform: scale(.93); }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  width: 100%;
  max-height: 92vh;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow-y: auto;
  padding: 20px 16px 32px;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: -8px auto 16px;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--gray-900);
}

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--gray-800);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.form-control:focus { border-color: var(--primary); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 36px; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  text-decoration: none;
}
.btn:active { opacity: .85; transform: scale(.98); }
.btn-primary   { background: var(--primary); color: var(--white); }
.btn-success   { background: var(--success); color: var(--white); }
.btn-danger    { background: var(--danger);  color: var(--white); }
.btn-ghost     { background: var(--gray-100); color: var(--gray-700); }
.btn-outline   { background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-600); }
.btn-sm        { padding: 7px 14px; font-size: .8rem; }
.btn-block     { width: 100%; }
.btn-group     { display: flex; gap: 8px; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-gray    { background: var(--gray-100); color: var(--gray-500); }

/* ── Upload area ─────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-area input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.upload-icon { font-size: 2rem; margin-bottom: 6px; }
.upload-text { font-size: .8rem; color: var(--gray-500); }
.upload-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}
.upload-preview .file-icon { font-size: 1.5rem; }
.upload-preview .file-name { font-size: .8rem; color: var(--gray-700); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-preview .file-del  { color: var(--danger); cursor: pointer; font-size: 1rem; }

/* ── Toggle password ─────────────────────────────── */
.password-field {
  position: relative;
}
.password-field .form-control { padding-right: 42px; }
.password-toggle {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--gray-400);
  font-size: 1rem; padding: 4px;
}

/* ── Filter bar ──────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}
.filter-bar .form-control { flex: 1; }
.search-input {
  padding: 9px 12px 9px 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239ca3af'%3E%3Cpath fill-rule='evenodd' d='M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 16px;
}

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ── Alert ───────────────────────────────────────── */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger  { background: var(--danger-light);  color: var(--danger); }
.alert-info    { background: var(--info-light);    color: var(--info); }

/* ── Progress bar ────────────────────────────────── */
.progress {
  background: var(--gray-200);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width .4s ease;
}

/* ── Chart placeholder ───────────────────────────── */
.chart-container {
  width: 100%;
  height: 200px;
  position: relative;
}

/* ── Login page ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-logo {
  font-size: 3rem;
  margin-bottom: 8px;
}
.login-title {
  color: var(--white);
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.login-subtitle {
  color: rgba(255,255,255,.7);
  font-size: .9rem;
  margin-bottom: 32px;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

/* ── Spinner ─────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ───────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 12px; right: 12px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease, toastOut .25s ease 2.5s forwards;
  pointer-events: all;
}
.toast-success { background: var(--gray-900); color: var(--white); }
.toast-error   { background: var(--danger);   color: var(--white); }
@keyframes toastIn  { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(-8px); } }

/* ── Document viewer ─────────────────────────────── */
.doc-thumb {
  width: 70px; height: 70px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--gray-200);
}
.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.doc-item {
  position: relative;
  cursor: pointer;
}
.doc-item .doc-label {
  font-size: .65rem;
  color: var(--gray-500);
  text-align: center;
  margin-top: 4px;
}
.doc-del {
  position: absolute;
  top: -5px; right: -5px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--white);
  border: none; cursor: pointer;
  font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
}

/* ── Divider ─────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gray-100);
  margin: 12px 0;
}

/* ── Accesos categories ──────────────────────────── */
.acceso-category {
  font-size: .7rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 0 4px;
}
.acceso-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--white);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.acceso-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.acceso-body { flex: 1; min-width: 0; }
.acceso-name { font-size: .9rem; font-weight: 600; color: var(--gray-800); }
.acceso-user { font-size: .75rem; color: var(--gray-500); margin-top: 1px; }
.acceso-pass {
  font-size: .8rem;
  font-family: monospace;
  color: var(--gray-600);
  letter-spacing: .05em;
}

/* ── Responsive tweaks ───────────────────────────── */
@media (min-width: 480px) {
  #app-main { padding-left: 16px; padding-right: 16px; }
}
