:root {
  --bg: #ffffff;
  --text: #0f172a;        /* slate-900 */
  --muted: #64748b;       /* slate-500 */
  --surface: #f8fafc;     /* slate-50 */
  --border: #e5e7eb;      /* gray-200 */
  --accent: #2563eb;      /* blue-600 */
  --accent-700: #1d4ed8;  /* blue-700 */
  --success: #065f46;
  --error: #b91c1c;

  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 6px 24px rgba(2,6,23,.08);

  --maxw: 960px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px;
}
@media (min-width: 768px) {
  .container { padding: 40px 24px; }
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text);
}

.brand-logo {
  display: block;
  max-height: 40px;
  width: auto;
  height: auto;
}

.hero {
  padding: 44px 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7ff 100%);
  color: var(--text);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.hero h1 {
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  margin: 0 0 8px;
}
.hero-logo {
  display: block;
  width: 100%;
  max-width: 733px;
  height: auto;
  margin: 0 auto 16px;
}
@media (min-width: 768px) {
  .hero-logo {
    width: 733px;
  }
}
.tagline {
  font-size: clamp(18px, 2.2vw, 22px);
  color: #e5edff;
  font-weight: 600;
  margin: 0 0 8px;
}
.lead {
  color: var(--muted);
  max-width: 733px; /* poravnanje s logom (733x199) */
  margin: 20px auto 0;
  font-size: clamp(18px, 2.6vw, 24px);
  line-height: 1.6;
  font-weight: 500;
}

.search { margin-top: 20px; }
.search-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
@media (min-width: 768px) {
  .search-bar {
    grid-template-columns: 1fr 140px 140px auto auto auto;
    gap: 12px;
    padding: 16px;
  }
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Inputs */
.input, .select {
  height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}
.input::placeholder { color: #9aa3b2; }
.input:focus, .select:focus,
.input:focus-visible, .select:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* Button */
.btn {
  height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--accent-700); }
.btn:focus, .btn:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

/* Status */
.status { display: block; margin: 10px 0 14px; color: var(--success); }
.status.error { color: var(--error); }

/* Results table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.grid {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px; /* allow horizontal scroll on small screens */
}
.grid th, .grid td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
}
.grid th { background: var(--surface); text-align: left; font-weight: 600; }
.grid tr:last-child td { border-bottom: 0; }

/* Generic section spacing */
.section { margin-top: 16px; }

/* Small screens tweaks */
@media (max-width: 640px) {
  .container { padding: 20px 16px; }
  .grid th, .grid td { font-size: 13px; padding: 8px; }
}

/* Results card layout (2-row) */
.grid { min-width: 0; } /* override previous min-width to allow fluid layout */
.grid thead { display: table-header-group; } /* show header by default (desktop) */
.grid th, .grid td { padding: 0; border: 0; } /* cards handle spacing and separators */

.result-card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.result-card:last-child { border-bottom: 0; }

.row-top,
.row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.title { font-weight: 700; font-size: 16px; }
.meta { color: var(--muted); font-size: 14px; }
.desc { color: var(--muted); font-size: 14px; }

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.wave-wrap { flex: 1 1 260px; min-width: 220px; }
.wave { width: 100%; }

/* Audio error message */
.audio-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px; /* Reduced from 48px to minimize empty space */
  background: #fef2f2; /* red-50 */
  border: 1px solid #fecaca; /* red-200 */
  border-radius: 6px;
  text-align: center;
  padding: 0 8px; /* Small horizontal padding for text breathing room */
}
.error-message {
  color: var(--error);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2; /* Tighter line height */
}

.btn-play {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn-play:hover { background: var(--accent-700); }

.btn-share {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  font-size: 14px;
}
.btn-share:hover { 
  background: #eef2ff; 
  border-color: #c7d2fe;
}

/* Share container and tooltip */
.share-container {
  position: relative;
  display: inline-block;
}

.share-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  background: var(--success);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.share-tooltip.show {
  opacity: 1;
}

.tooltip-arrow {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--success);
}

@media (max-width: 640px) {
  .title { font-size: 15px; }
  .meta, .desc { font-size: 13px; }
  .player { flex-wrap: wrap; }
}

/* Desktop header and grid alignment */
.result-header {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1.2fr 1fr 120px;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.row-top.row-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1.2fr 1fr 120px;
  gap: 12px;
  align-items: center;
}
.date { white-space: nowrap; }

/* Hide table header on small screens; stack row-top */
@media (max-width: 640px) {
  .grid thead { display: none; }
  .row-top.row-grid { grid-template-columns: 1fr; }
}

/* Variant buttons */
.btn-light {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-light:hover { background: #eef2ff; }

.btn-secondary {
  background: #475569; /* slate-600 */
  color: #fff;
}
.btn-secondary:hover { background: #334155; } /* slate-700 */

/* Autocomplete */
.search-input-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
}

.autocomplete-container {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow-md);
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
  display: none; /* Hidden by default */
}
.autocomplete-container.open {
  display: block;
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
}
.autocomplete-item:hover {
  background: var(--surface);
}
.autocomplete-item.selected {
  background: var(--accent);
  color: #fff;
}

/* Help overlay */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5); /* slate-900/50 */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.help-overlay.open { display: flex; }

.help-panel {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px;
}
.help-panel h3 {
  margin: 0 0 8px;
  font-size: 18px;
}
.help-desc {
  color: var(--muted);
  margin: 0 0 12px;
}
.help-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.help-examples button {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.help-examples button:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}
.help-actions {
  display: flex;
  justify-content: flex-end;
}

/* Intro panel */
.info-panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.info-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}
.info-body {
  margin: 0 0 8px;
  color: var(--muted);
}

/* Features list */
.features-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.features-list li {
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

/* Footer */
.footer {
  margin-top: 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.footer .container {
  padding-top: 16px;
  padding-bottom: 16px;
  font-size: 14px;
  color: var(--muted);
}
.footer a {
  color: var(--accent);
  text-decoration: none;
}
.footer a:hover {
  text-decoration: underline;
}

/* CTA */
.cta-hero {
  margin-top: 6px;
  font-size: 14px;
  color: var(--muted);
}
.cta-after {
  margin-top: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  color: var(--text);
}
.cta-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.cta-link:hover {
  text-decoration: underline;
}

/* Layout compaction: reduce excess whitespace around hero and top of page */
.header:empty {
  padding-top: 0;
  padding-bottom: 0;
}

/* Reduce top padding for main content container */
main.container { padding-top: 8px; }
@media (min-width: 768px) {
  main.container { padding-top: 16px; }
}

/* Make hero padding asymmetric: less space below CTA */
.hero { padding-top: 36px; padding-bottom: 10px; }
@media (min-width: 768px) {
  .hero { padding-top: 56px; padding-bottom: 12px; }
}

/* Loading overlay and spinner */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7); /* slate-900/70 */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px 32px;
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: var(--text);
  font-weight: 600;
  font-size: 16px;
  margin: 0;
}

/* Hide loading overlay by default */
.loading-overlay {
  display: none;
}
.loading-overlay.show {
  display: flex;
}
