/* Base light theme variables */
:root {
  --bg: #f8fafc;
  --text: #1e293b;
  --card: #ffffff;
  --muted: #94a3b8;
  --primary: #1e3a8a;
  --accent: #2563eb;
  --surface: #e2e8f0;
  --panel: #f1f5f9;
}

:root.dark {
  --bg: #0b1220;
  --text: #e5e7eb;
  --card: #111827;
  --muted: #64748b;
  --primary: #334155;
  --accent: #60a5fa;
  --surface: #1f2937;
  --panel: #111827;
}

html { background: var(--bg); }
body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--text);
}

/* Header */
header {
  background: #87CEEB;
  color: white;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 { font-size: 1.2rem; margin: 0; color: #1a1a2e; }
nav a {
  color: #1a1a2e;
  margin-left: 1rem;
  text-decoration: none;
  font-weight: 600;
}
nav a:hover { text-decoration: underline; color: #000; }
#theme-toggle {
  margin-left: 1rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  padding: .35rem .6rem;
  border-radius: 8px;
  cursor: pointer;
}

/* Main layout */
main { padding: 2rem; max-width: 900px; margin: auto; }
.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }

/* Upload Form */
.upload-card {
  background: var(--card);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

#drop-zone {
  border: 2px dashed var(--muted);
  border-radius: 10px;
  padding: 2rem;
  margin-bottom: 1rem;
  transition: border-color 0.3s, background 0.3s;
}
#drop-zone.dragover { border-color: var(--accent); background: rgba(37, 99, 235, 0.08); }

.privacy-note { margin: 0 0 1rem; color: #0f766e; font-weight: 600; }

.progress-container {
  margin-top: 1rem;
  background: var(--surface);
  border-radius: 6px;
  height: 12px;
  overflow: hidden;
  display: none;
}
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.message { margin-top: .6rem; min-height: 1.2rem; }

/* ===== Download History Panel ===== */
#history-panel {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 260px;
  background: var(--card);
  border: 1px solid var(--surface);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 0.9rem;
  transition: transform 0.3s;
  overflow: hidden;
  z-index: 999;
}
#history-panel.collapsed { transform: translateY(calc(100% - 30px)); }
#history-header {
  background: var(--primary);
  color: white;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#toggle-history {
  background: transparent;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
}
#history-list { max-height: 200px; overflow-y: auto; padding: 8px; list-style: none; margin: 0; }
#history-list li { border-bottom: 1px solid var(--surface); padding: 4px 0; }
#clear-history {
  width: 100%;
  border: none;
  background: var(--panel);
  padding: 6px;
  cursor: pointer;
  border-top: 1px solid var(--surface);
  color: var(--text);
}
#clear-history:hover { filter: brightness(1.1); }

.btn-primary{
  margin-top: 5px!important;
}

/* Mobile / Responsive fixes */
html, body {
  height: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure main area can scroll and doesn't get clipped by other elements */
main {
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

/* Drop zone should allow vertical pans (scroll) while still accepting taps */
#drop-zone {
  touch-action: pan-y;
}

/* Header should not block scrolling */
header { position: relative; z-index: 20; }

/* Make header stack on small screens and increase tappable areas */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: .6rem;
  }
  header h1 { font-size: 1rem; }
  nav {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
  }
  nav a, .back-btn {
    display: inline-block;
    padding: .5rem .6rem;
    margin: 0;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    color: #1a1a2e;
  }
  nav a:hover {
    background: rgba(255,255,255,0.3);
  }
  main { padding: 1rem; }
  .upload-card { padding: 1rem; }
  #drop-zone { padding: 1rem; }
}

/* Medium screens adjustments */
@media (max-width: 900px) {
  main { max-width: 100%; padding: 1.2rem; }
}

/* Ensure history panel doesn't intercept touch when collapsed */
#history-panel.collapsed {
  transform: translateY(calc(100% - 30px));
  pointer-events: none;
}
#history-panel { touch-action: pan-y; }

/* Ensure when history panel is visible it accepts pointer events */
#history-panel:not(.collapsed) { pointer-events: auto; }

/* Footer */
footer {
  background: #000;
  color: #fff;
  padding: 2rem 1rem 0;
  margin-top: 3rem;
}
.footer-content {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}
.footer-section h3, .footer-section h4 {
  margin-bottom: 1rem;
  color: #fff;
}
.footer-section p {
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.6;
}
.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-section ul li {
  margin-bottom: 0.5rem;
}
.footer-section ul li a {
  color: #ccc;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.footer-section ul li a:hover {
  color: #fff;
  text-decoration: underline;
}
.footer-bottom {
  text-align: center;
  padding: 1.5rem 0;
  margin-top: 2rem;
  border-top: 1px solid #333;
}
.footer-bottom p {
  margin: 0;
  color: #888;
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  footer { padding: 1.5rem 1rem 0; }
  .footer-content { grid-template-columns: 1fr; text-align: center; }
}

