/* ==============================
   HOTEL ASTURIAS · Dashboard CSS
   ============================== */

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

:root {
  --bg:         #0d0f1a;
  --bg2:        #131629;
  --bg3:        #1a1e35;
  --card:       #1e2340;
  --card2:      #242848;
  --border:     rgba(255,255,255,0.07);
  --accent:     #6c63ff;
  --accent2:    #a78bfa;
  --accent3:    #38bdf8;
  --gold:       #f59e0b;
  --green:      #10b981;
  --red:        #ef4444;
  --orange:     #f97316;
  --text:       #e2e8f0;
  --text2:      #94a3b8;
  --text3:      #64748b;
  --radius:     14px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.5);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

/* ======= HEADER ======= */
.header {
  background: linear-gradient(135deg, #0d0f1a 0%, #1a1535 100%);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-icon { font-size: 26px; flex-shrink: 0; }
.logo-name {
  display: block; font-size: 17px; font-weight: 700;
  background: linear-gradient(90deg, #a78bfa, #38bdf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.logo-sub { display: block; font-size: 11px; color: var(--text3); font-weight: 400; }
.header-badge {
  font-size: 11px; font-weight: 600;
  background: var(--card); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 20px; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}

/* ======= UPLOAD ======= */
.upload-section {
  min-height: calc(100vh - 58px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  background: radial-gradient(ellipse at 60% 40%, rgba(108,99,255,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(56,189,248,0.08) 0%, transparent 50%);
}
.upload-card {
  background: var(--card);
  border: 2px dashed rgba(108,99,255,0.4);
  border-radius: 22px;
  padding: 40px 32px;
  text-align: center;
  max-width: 580px; width: 100%;
  transition: border-color .3s, box-shadow .3s;
  cursor: pointer;
}
.upload-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 40px rgba(108,99,255,0.25);
}
.upload-icon { font-size: 56px; margin-bottom: 16px; }
.upload-title { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.upload-desc { color: var(--text2); font-size: 14px; margin-bottom: 20px; line-height: 1.6; }

/* Guía de tipos de archivo */
.file-types-guide {
  display: flex; gap: 10px; margin-bottom: 24px;
  flex-wrap: wrap; justify-content: center;
}
.file-type-item {
  display: flex; align-items: flex-start; gap: 10px; text-align: left;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  flex: 1; min-width: 180px; max-width: 240px;
  font-size: 12px; color: var(--text2); line-height: 1.5;
}
.file-type-item small { color: var(--text3); font-size: 11px; }
.file-type-badge {
  display: inline-block; padding: 3px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  white-space: nowrap; flex-shrink: 0;
}
.file-type-badge.monthly  { background: rgba(56,189,248,.2); color: #38bdf8; border: 1px solid rgba(56,189,248,.3); }
.file-type-badge.reservas { background: rgba(108,99,255,.2); color: #a78bfa; border: 1px solid rgba(108,99,255,.3); }

.upload-btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 600; font-size: 15px;
  padding: 14px 32px; border-radius: 12px;
  cursor: pointer; transition: opacity .2s, transform .2s;
  font-family: inherit; touch-action: manipulation;
}
.upload-btn:hover { opacity: .9; transform: translateY(-2px); }
.upload-hint { margin-top: 14px; font-size: 12px; color: var(--text3); }

/* ======= LOADING ======= */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(13,15,26,0.88);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.loading-box {
  background: var(--card); border-radius: 20px;
  padding: 36px 32px; text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
}
.spinner {
  width: 48px; height: 48px; margin: 0 auto 16px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======= DASHBOARD ======= */
.dashboard {
  max-width: 1400px; margin: 0 auto;
  padding: 20px 20px 80px;
}
.dash-topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 14px; flex-wrap: wrap;
}
.dash-left { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.dash-title {
  font-size: 20px; font-weight: 700;
  background: linear-gradient(90deg, var(--accent2), var(--accent3));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.dash-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0;
}

/* ======= DETECTED BANNER ======= */
.detected-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; color: var(--text2);
  max-width: 600px;
}
.detected-banner .det-icon { font-size: 20px; flex-shrink: 0; }
.detected-banner .det-type {
  font-weight: 700; font-size: 11px; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 5px; margin-right: 4px;
}
.det-type.monthly  { background: rgba(56,189,248,.2); color: #38bdf8; }
.det-type.reservas { background: rgba(108,99,255,.2); color: #a78bfa; }
.detected-banner .det-text { line-height: 1.4; }
.det-filename { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ======= KPI GRID ======= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.kpi-card.green::before  { background: linear-gradient(90deg, var(--green), #34d399); }
.kpi-card.blue::before   { background: linear-gradient(90deg, var(--accent3), #818cf8); }
.kpi-card.gold::before   { background: linear-gradient(90deg, var(--gold), #fcd34d); }
.kpi-card.orange::before { background: linear-gradient(90deg, var(--orange), #fbbf24); }
.kpi-label { font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 800; color: var(--text); }
.kpi-sub   { font-size: 11px; color: var(--text2); margin-top: 4px; }
.kpi-icon  { position: absolute; top: 14px; right: 14px; font-size: 20px; opacity: .4; }

/* ======= SECTION CARD ======= */
.section-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.section-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.section-icon { font-size: 18px; }
.section-header h2 { font-size: 15px; font-weight: 700; }
.badge-count {
  margin-left: auto; font-size: 12px; font-weight: 600;
  background: var(--card2); border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 20px; color: var(--accent2);
}
.filter-active-badge {
  font-size: 11px; font-weight: 600;
  background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.3);
  color: var(--gold); padding: 3px 10px; border-radius: 20px;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ======= FILTERS ======= */
.filters-card { padding: 16px 20px; }
.filters-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 130px; flex: 1; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; }
.filter-group select,
.filter-group input[type="date"],
.filter-group input[type="text"] {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .2s;
  min-height: 38px;
}
.filter-group select:focus,
.filter-group input:focus { border-color: var(--accent); }
option { background: var(--bg3); }

/* ======= BUTTONS ======= */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 600; font-size: 14px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  border: none; cursor: pointer; font-family: inherit;
  transition: opacity .2s, transform .2s; align-self: flex-end;
  touch-action: manipulation; white-space: nowrap;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary:active { transform: scale(.97); }

.btn-secondary {
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); font-weight: 600; font-size: 13px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit;
  transition: background .2s, color .2s;
  touch-action: manipulation; white-space: nowrap;
}
.btn-secondary:hover { background: var(--card); color: var(--text); }
.btn-secondary:active { transform: scale(.97); }

.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text3); font-size: 13px; font-weight: 500;
  padding: 9px 14px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit;
  transition: border-color .2s, color .2s; align-self: flex-end;
  touch-action: manipulation; white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-ghost.small { padding: 6px 12px; font-size: 12px; align-self: unset; margin-left: auto; }

.btn-pdf {
  background: linear-gradient(135deg, #1a1535, #2d1f5e);
  border: 1px solid rgba(167,139,250,.4);
  color: var(--accent2); font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit;
  transition: all .25s;
  box-shadow: 0 0 12px rgba(108,99,255,.15);
  touch-action: manipulation; white-space: nowrap;
}
.btn-pdf:hover {
  border-color: var(--accent2);
  box-shadow: 0 0 20px rgba(108,99,255,.35);
  color: #fff;
}
.btn-pdf:active { transform: scale(.97); }

/* ======= CHARTS ======= */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.chart-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 8px;
}
.chart-header h3 {
  font-size: 12px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: .04em;
  flex: 1; min-width: 0;
}
.btn-dl-chart {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text3); font-size: 11px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px;
  cursor: pointer; font-family: inherit;
  transition: all .2s; flex-shrink: 0;
  touch-action: manipulation;
}
.btn-dl-chart:hover { border-color: var(--accent2); color: var(--accent2); }

.chart-card canvas { max-height: 220px; }

/* Chart insight text below chart */
.chart-insight {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text3); line-height: 1.6;
}
.chart-insight strong { color: var(--accent2); }
.chart-insight .ins-row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.chart-insight .ins-val { color: var(--text2); font-weight: 600; }

/* ======= DATA TABLE ======= */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--bg3); color: var(--text3); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.data-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  color: var(--text); white-space: nowrap;
  transition: background .15s;
}
.data-table tr:hover td { background: var(--card2); }
.data-table tr:last-child td { border-bottom: none; }

/* Status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-checkout  { background: rgba(16,185,129,.15); color: #10b981; }
.badge-checkin   { background: rgba(56,189,248,.15);  color: #38bdf8; }
.badge-reserva   { background: rgba(108,99,255,.15);  color: #a78bfa; }
.badge-cancelada { background: rgba(239,68,68,.15);   color: #ef4444; }
.badge-noshow    { background: rgba(249,115,22,.15);  color: #f97316; }
.badge-pendiente { background: rgba(245,158,11,.15);  color: #f59e0b; }
.badge-default   { background: rgba(100,116,139,.15); color: #94a3b8; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.highlight { color: var(--accent2); font-weight: 600; }

/* ======= PAGINATION ======= */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 5px; padding: 14px 0 4px; flex-wrap: wrap;
}
.page-btn {
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); font-size: 13px; font-weight: 500;
  min-width: 36px; height: 36px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
  padding: 0 6px; touch-action: manipulation;
}
.page-btn:hover, .page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ======= MOBILE STICKY ACTIONS BAR ======= */
/* Hidden on desktop, shown on mobile */
.mobile-fab-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: linear-gradient(to top, var(--bg) 80%, transparent);
  padding: 12px 16px 20px;
  gap: 10px;
}

/* ======= FILTERS TOGGLE (mobile) ======= */
.btn-toggle-filters {
  display: none; /* shown via media query */
  background: var(--card2); border: 1px solid var(--border);
  color: var(--text2); font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit;
  transition: background .2s, color .2s;
  align-items: center; gap: 8px;
  touch-action: manipulation;
  width: 100%; justify-content: center;
}
.btn-toggle-filters:hover { background: var(--card); color: var(--text); }

/* ======= RESPONSIVE — TABLET ======= */
@media (max-width: 900px) {
  .dashboard { padding: 16px 16px 80px; }
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .header-badge { max-width: 160px; font-size: 10px; }
}

/* ======= RESPONSIVE — MOBILE ======= */
@media (max-width: 600px) {

  /* Header */
  .header-inner { padding: 10px 14px; }
  .logo-icon { font-size: 22px; }
  .logo-name { font-size: 15px; }
  .logo-sub { display: none; }
  .header-badge { display: none; } /* shown in banner below instead */

  /* Upload */
  .upload-section { padding: 20px 14px; align-items: flex-start; padding-top: 32px; }
  .upload-card { padding: 28px 18px; border-radius: 18px; }
  .upload-icon { font-size: 48px; margin-bottom: 12px; }
  .upload-title { font-size: 19px; }
  .upload-desc { font-size: 13px; }
  .file-types-guide { flex-direction: column; align-items: stretch; }
  .file-type-item { max-width: none; }
  .upload-btn { font-size: 14px; padding: 13px 24px; }

  /* Dashboard */
  .dashboard { padding: 14px 14px 90px; }

  /* Top bar: stack vertically, hide action buttons (moved to mobile bar) */
  .dash-topbar { flex-direction: column; gap: 10px; margin-bottom: 16px; }
  .dash-title { font-size: 18px; }
  .dash-actions { display: none; } /* moved to sticky bottom bar */

  /* Mobile FAB bar: always visible when dashboard is open */
  .mobile-fab-bar {
    display: flex;
    flex-direction: row;
    justify-content: stretch;
  }
  .mobile-fab-bar .btn-pdf,
  .mobile-fab-bar .btn-secondary {
    flex: 1; text-align: center; justify-content: center;
    font-size: 12px; padding: 11px 8px;
    display: flex; align-items: center; gap: 5px;
  }

  /* Detected banner: compact */
  .detected-banner { padding: 8px 12px; font-size: 12px; }
  .detected-banner .det-icon { font-size: 16px; }

  /* KPIs: 2 columns on mobile */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 9px; }
  .kpi-sub { font-size: 10px; }
  .kpi-icon { font-size: 18px; top: 10px; right: 10px; }

  /* Section cards */
  .section-card { padding: 14px; border-radius: 12px; }
  .section-header { margin-bottom: 12px; gap: 8px; }
  .section-header h2 { font-size: 14px; }

  /* Filters: collapsible */
  .filters-card { padding: 14px; }
  .btn-toggle-filters { display: flex; margin-bottom: 0; }
  .filters-body {
    max-height: 0; overflow: hidden;
    transition: max-height 0.35s ease, padding 0.35s ease;
    padding-top: 0;
  }
  .filters-body.open {
    max-height: 600px;
    padding-top: 14px;
  }
  .filters-row { gap: 8px; }
  .filter-group { min-width: unset; flex: 1 1 100%; }
  .filter-group select,
  .filter-group input[type="date"],
  .filter-group input[type="text"] {
    font-size: 16px; /* prevents iOS zoom */
    padding: 10px 12px;
  }
  .btn-primary, .btn-ghost { align-self: stretch; width: 100%; text-align: center; }

  /* Charts: 1 column, larger canvas */
  .charts-grid { grid-template-columns: 1fr; gap: 12px; margin-bottom: 14px; }
  .chart-card { padding: 14px; border-radius: 12px; }
  .chart-card canvas { max-height: 260px; }
  .chart-insight { font-size: 11px; }

  /* Table: horizontal scroll with hint */
  .table-wrapper { border-radius: 8px; }
  .data-table { font-size: 12px; }
  .data-table th { padding: 8px 10px; font-size: 10px; }
  .data-table td { padding: 8px 10px; }

  /* Pagination */
  .pagination { gap: 4px; padding: 10px 0 4px; }
  .page-btn { min-width: 34px; height: 34px; font-size: 12px; }

  /* Badge count inline */
  .badge-count { font-size: 11px; padding: 3px 10px; }

  /* Export CSV button */
  .btn-ghost.small { margin-left: 0; }

  /* Section header on mobile: wrap */
  .section-header { align-items: flex-start; }
  .badge-count { margin-left: 0; width: 100%; text-align: center; margin-top: 4px; }
}

/* ======= RESPONSIVE — VERY SMALL ======= */
@media (max-width: 360px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 22px; }
  .logo-name { font-size: 14px; }
}
