/* ═══════════════════════════════════════════════════════════════
   Rainfall Data Portal — Premium Dark Glassmorphism Design
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Variables ─────────────────────────────────────────────── */

:root {
  --bg-base:     #090e1a;
  --bg-surface:  #0f1829;
  --bg-card:     #141f35;
  --bg-elevated: #1a2842;
  --border:      rgba(99, 155, 255, 0.12);
  --border-glow: rgba(99, 155, 255, 0.35);

  --accent-blue:  #4f9cf9;
  --accent-cyan:  #22d3ee;
  --accent-green: #34d399;
  --accent-amber: #fbbf24;
  --accent-red:   #f87171;

  --text-primary:   #e8f0ff;
  --text-secondary: #8ba3cc;
  --text-muted:     #4a6280;

  --gradient-hero: linear-gradient(135deg, #0f1829 0%, #0a1628 50%, #0d1f3c 100%);
  --gradient-card: linear-gradient(145deg, rgba(79,156,249,0.06) 0%, rgba(34,211,238,0.03) 100%);
  --gradient-btn:  linear-gradient(135deg, #4f9cf9 0%, #22d3ee 100%);
  --gradient-success: linear-gradient(135deg, #059669 0%, #34d399 100%);
  --gradient-export:  linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4), 0 1px 0 rgba(99,155,255,0.08) inset;
  --shadow-glow: 0 0 30px rgba(79,156,249,0.15);
}

/* ─── Reset & Base ──────────────────────────────────────────── */

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Animated Background ───────────────────────────────────── */

body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(79,156,249,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(34,211,238,0.06) 0%, transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(124,58,237,0.04) 0%, transparent 60%);
}

/* ─── Layout ─────────────────────────────────────────────────── */

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ─── Header ─────────────────────────────────────────────────── */

.site-header {
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(9,14,26,0.85);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 100;
}

.logo {
  display: flex; align-items: center; gap: 12px;
}

.logo-icon {
  width: 38px; height: 38px;
  background: var(--gradient-btn);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 15px rgba(79,156,249,0.3);
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.logo-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.header-badge {
  background: rgba(79,156,249,0.12);
  border: 1px solid rgba(79,156,249,0.25);
  color: var(--accent-blue);
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ─── Main Container ────────────────────────────────────────── */

.main-container { flex: 1; padding: 40px 32px; max-width: 1600px; margin: 0 auto; width: 100%; }

/* ─── Hero Section ──────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: 60px 0 48px;
}

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(79,156,249,0.1);
  border: 1px solid rgba(79,156,249,0.2);
  color: var(--accent-blue);
  padding: 6px 16px; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #e8f0ff 30%, #4f9cf9 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─── Steps ─────────────────────────────────────────────────── */

.steps-row {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 36px; flex-wrap: wrap;
}

.step {
  display: flex; align-items: center; gap: 10px;
  background: var(--gradient-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  font-size: 0.82rem; color: var(--text-secondary);
  transition: border-color 0.2s, transform 0.2s;
}

.step:hover { border-color: var(--border-glow); transform: translateY(-2px); }

.step-num {
  width: 24px; height: 24px;
  background: var(--gradient-btn);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: white;
  flex-shrink: 0;
}

/* ─── Upload Section ────────────────────────────────────────── */

#upload-section {
  display: flex; justify-content: center; padding: 24px 0 60px;
}

.drop-zone {
  width: 100%; max-width: 680px;
  border: 2px dashed rgba(79,156,249,0.25);
  border-radius: var(--radius-xl);
  padding: 56px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--gradient-card);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(79,156,249,0.06) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-glow);
  transform: scale(1.01);
}

.drop-zone:hover::before, .drop-zone.drag-over::before { opacity: 1; }

.drop-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  display: block;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.drop-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.drop-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.drop-sub strong { color: var(--accent-blue); }

.upload-btn {
  background: var(--gradient-btn);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(79,156,249,0.3);
}

.upload-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(79,156,249,0.4); }

.drop-note {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ─── Processing Section ─────────────────────────────────────── */

#processing-section {
  display: none; flex-direction: column; align-items: center;
  padding: 40px 0 60px; gap: 32px;
}

.processing-header {
  text-align: center;
}

.processing-header h2 {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 8px;
}

.processing-header p { color: var(--text-secondary); font-size: 0.9rem; }

.spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(79,156,249,0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

#file-list {
  width: 100%; max-width: 640px;
  display: flex; flex-direction: column; gap: 12px;
}

.file-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex; gap: 14px; align-items: flex-start;
  transition: border-color 0.3s;
}

.file-item.file-done  { border-color: rgba(52,211,153,0.3); }
.file-item.file-error { border-color: rgba(248,113,113,0.3); }

.file-icon { font-size: 1.8rem; flex-shrink: 0; }

.file-info { flex: 1; }

.file-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }

.file-size { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 8px; }

.file-progress-bar {
  height: 4px; background: rgba(79,156,249,0.15); border-radius: 99px; overflow: hidden; margin-bottom: 6px;
}

.file-progress-fill {
  height: 100%; background: var(--gradient-btn); border-radius: 99px;
  transition: width 0.3s ease; width: 0%;
}

.file-status { font-size: 0.8rem; color: var(--text-secondary); }

/* ─── Results Section ─────────────────────────────────────────── */

#results-section { display: none; }

.results-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

/* ─── Filter Panel ───────────────────────────────────────────── */

.filter-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  position: sticky; top: 88px;
  box-shadow: var(--shadow-card);
}

.filter-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.filter-sidebar-header h3 {
  font-size: 0.95rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

.clear-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.72rem;
  padding: 4px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s;
}

.clear-btn:hover { border-color: var(--accent-red); color: var(--accent-red); }

/* ─── Peak Rainfall Day Widget ──────────────────────────────── */

.peak-widget {
  margin-top: 20px;
  padding: 18px 16px;
  background: linear-gradient(135deg, rgba(251,191,36,0.08) 0%, rgba(251,191,36,0.03) 100%);
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: var(--radius-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.peak-widget::before {
  content: '';
  position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px;
  background: radial-gradient(circle, rgba(251,191,36,0.15) 0%, transparent 70%);
  border-radius: 50%;
}

.peak-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-amber);
  margin-bottom: 10px;
}

.peak-day-num {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent-amber);
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 4px;
}

.peak-day-val {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.peak-day-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ─── Sidebar Action Buttons ────────────────────────────────── */

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─── Multi-PDF tip on upload ───────────────────────────────── */

.multi-tip {
  display: inline-block;
  background: rgba(52,211,153,0.08);
  border: 1px solid rgba(52,211,153,0.2);
  color: var(--accent-green);
  font-size: 0.75rem;
  padding: 6px 14px;
  border-radius: 99px;
  margin: 10px 0 6px;
}

#filter-panel { display: flex; flex-direction: column; gap: 16px; }

.filter-group label {
  display: block; font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 8px;
}

/* ─── Multi-select Dropdown ──────────────────────────────────── */

.multi-select-container { position: relative; }

.multi-select-trigger {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.85rem; color: var(--text-primary);
  transition: border-color 0.2s;
  user-select: none;
}

.multi-select-trigger:hover { border-color: var(--border-glow); }

.trigger-arrow { color: var(--text-muted); transition: transform 0.2s; font-size: 0.7rem; }

.multi-select-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.multi-select-dropdown.open { display: block; }

.dropdown-search {
  width: 100%;
  background: rgba(79,156,249,0.06);
  border: none; border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  padding: 9px 14px; font-size: 0.82rem;
  outline: none; font-family: inherit;
}

.dropdown-option {
  padding: 8px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  font-size: 0.84rem; color: var(--text-secondary);
  transition: background 0.15s;
  user-select: none;
}

.dropdown-option:hover { background: rgba(79,156,249,0.1); color: var(--text-primary); }

.dropdown-option.select-all {
  border-bottom: 1px solid var(--border);
  font-weight: 600; color: var(--accent-blue);
}

.dropdown-option input[type="checkbox"] {
  accent-color: var(--accent-blue);
  flex-shrink: 0;
}

/* Day range */
.day-range-row {
  display: flex; align-items: center; gap: 8px;
}

.day-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 10px; font-size: 0.85rem;
  text-align: center; outline: none;
  transition: border-color 0.2s; font-family: inherit;
}

.day-input:focus { border-color: var(--accent-blue); }

.range-sep { color: var(--text-muted); font-size: 0.8rem; }

/* ─── Data Panel ─────────────────────────────────────────────── */

.data-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0; /* Prevents flex items from expanding beyond parent */
  max-width: 100%;
}

.data-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.data-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stat-chip strong { color: var(--accent-cyan); }

.toolbar-actions { display: flex; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-export {
  background: var(--gradient-export);
  color: white;
  box-shadow: 0 4px 15px rgba(124,58,237,0.3);
}

.btn-export:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(124,58,237,0.45); }

.btn-reset {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-reset:hover { border-color: var(--border-glow); color: var(--text-primary); }

.btn-outline {
  background: transparent;
  color: var(--accent-blue);
  border: 1px solid rgba(79,156,249,0.3);
}

.btn-outline:hover { background: rgba(79,156,249,0.08); }

/* ─── Table ──────────────────────────────────────────────────── */

.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  max-width: 100%;
}

.table-scroll {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
}

thead { background: var(--bg-elevated); position: sticky; top: 0; z-index: 10; }

th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(99,155,255,0.05);
  white-space: nowrap;
  transition: background 0.1s;
}

tr:hover td { background: rgba(79,156,249,0.04); }

.row-even td { background: rgba(0,0,0,0.08); }
.row-odd  td { background: transparent; }
.row-even:hover td, .row-odd:hover td { background: rgba(79,156,249,0.06); }

.row-summary td {
  background: rgba(79,156,249,0.08) !important;
  border-top: 1px solid rgba(79,156,249,0.2);
  font-weight: 700;
  color: var(--accent-cyan);
}

td.cell-null  { color: var(--text-muted); }
td.cell-zero  { color: var(--text-muted); }
td.cell-num   { color: var(--text-primary); }

/* Peak day column highlight */
th.th-peak {
  background: rgba(251,191,36,0.12) !important;
  color: var(--accent-amber) !important;
  border-bottom-color: rgba(251,191,36,0.4) !important;
}
td.cell-peak-col { background: rgba(251,191,36,0.04); }
td.cell-peak-highlight {
  color: var(--accent-amber) !important;
  font-weight: 700;
}

.empty-row { text-align: center; color: var(--text-muted); padding: 48px; }

/* ─── Pagination ─────────────────────────────────────────────── */

#pagination {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.page-btn {
  min-width: 34px; height: 34px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.82rem;
  transition: all 0.15s; font-family: inherit;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent-blue); color: var(--accent-blue);
  background: rgba(79,156,249,0.08);
}

.page-btn.active {
  background: var(--gradient-btn); border-color: transparent;
  color: white; font-weight: 700;
}

.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-ellipsis { color: var(--text-muted); padding: 0 4px; }

/* ─── Toast ──────────────────────────────────────────────────── */

#toast-container {
  position: fixed; bottom: 28px; right: 28px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 0.85rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  max-width: 360px;
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.35s ease;
}

.toast.show { opacity: 1; transform: translateX(0); }

.toast-success { border-color: rgba(52,211,153,0.35); color: var(--accent-green); }
.toast-error   { border-color: rgba(248,113,113,0.35); color: var(--accent-red); }
.toast-info    { border-color: rgba(79,156,249,0.35); color: var(--accent-blue); }

/* ─── Footer ─────────────────────────────────────────────────── */

.site-footer {
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ─── Scrollbar ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: rgba(79,156,249,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(79,156,249,0.4); }

/* ─── Responsive ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  .results-layout { grid-template-columns: 1fr; }
  .filter-sidebar { position: static; }
  .main-container { padding: 24px 16px; }
  .site-header { padding: 12px 16px; }
}

@media (max-width: 600px) {
  .hero-title { font-size: 1.8rem; }
  .steps-row { flex-direction: column; align-items: center; }
  .data-toolbar { flex-direction: column; align-items: stretch; }
}
