/* ============================================================
   DailyBriefer - Main Stylesheet
   ============================================================ */

/* -----------------------------
   CSS Variables
   ----------------------------- */

:root {
  --bg: #eef4ff;
  --card-bg: rgba(244, 248, 255, 0.92);
  --border: rgba(30, 64, 175, 0.16);
  --sidebar-outline: rgba(37, 99, 235, 0.28);

  --text: #0f172a;
  --muted: #475569;

  --btn-bg: #dbeafe;
  --btn-hover: #bfdbfe;
  --btn-primary: #2563eb;
  --btn-primary-hover: #1e40af;

  --table-head: rgba(191, 219, 254, 0.86);
  --table-row: rgba(242, 247, 255, 0.86);
  --table-row-hover: rgba(219, 234, 254, 0.86);

  --focus: rgba(37, 99, 235, 0.5);
}

/* Dark theme */

:root.dark {
  --bg: #020617;
  --card-bg: rgba(17, 24, 39, 0.9);
  --border: rgba(255, 255, 255, 0.08);
  --sidebar-outline: rgba(255, 255, 255, 0.24);

  --text: #e5e7eb;
  --muted: #9ca3af;

  --btn-bg: #1f2933;
  --btn-hover: #374151;
  --btn-primary: #3b82f6;
  --btn-primary-hover: #2563eb;

  --table-head: rgba(55, 65, 81, 0.9);
  --table-row: rgba(17, 24, 39, 0.8);
  --table-row-hover: rgba(55, 65, 81, 0.7);

  --focus: rgba(147, 197, 253, 0.6);
}

/* -----------------------------
   Reset / Base
   ----------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1100px 550px at 12% -8%, rgba(59, 130, 246, 0.20), transparent 62%),
    radial-gradient(1000px 500px at 100% 0%, rgba(56, 189, 248, 0.16), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Ubuntu, Cantarell, sans-serif;
  line-height: 1.5;
  height: 100%;
}

:root.dark body {
  background: var(--bg);
}

a {
  color: #2563eb;
  text-decoration: none;
}

:root.dark a {
  color: #60a5fa;
}

a:hover {
  text-decoration: underline;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============================================================
   Base layout (base.html expects these)
   ============================================================ */

.shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;

  width: 176px;
  min-width: 176px;
  flex: 0 0 176px;

  display: flex;
  flex-direction: column;
  gap: 12px;

  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  backdrop-filter: blur(10px);
}

.main {
  flex: 1 1 auto;
  min-width: 0; /* prevents wide tables pushing sidebar away */
  padding: 24px;
}

/* IMPORTANT: base.html uses <main class="main">.
   Avoid styling bare 'main' with max-width/padding; it can fight layout. */
main {
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Sidebar inner UI */

.logo {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.logo img {
  width: 100px;
  height: 100px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

:root.dark .logo img {
  border-color: rgba(255, 255, 255, 0.15);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 2px;
  flex: 1 1 auto;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  height: 44px;
  padding: 0 10px;
  border-radius: 10px;

  color: var(--text);
  border: 1px solid var(--sidebar-outline);
  background: rgba(255, 255, 255, 0.18);

  transition: background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

:root.dark .nav-item {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.28);
  text-decoration: none;
}

:root.dark .nav-item:hover {
  background: rgba(255, 255, 255, 0.10);
}

.nav-ico {
  width: 22px;
  text-align: center;
  flex: 0 0 22px;
}

.nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-divider {
  height: 2px;
  margin: 2px 10px 6px;
  border-radius: 999px;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.22),
    rgba(255, 255, 255, 0.5)
  );
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2), inset 0 -1px 0 rgba(255, 255, 255, 0.45);
}

:root.dark .nav-divider {
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.55),
    rgba(255, 255, 255, 0.18)
  );
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.55), inset 0 -1px 0 rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.sidebar-footer .btn {
  width: 100%;
  height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--sidebar-outline);
  background: rgba(255, 255, 255, 0.18);
}

:root.dark .sidebar-footer .btn {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-footer .btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

:root.dark .sidebar-footer .btn:hover {
  background: rgba(255, 255, 255, 0.10);
}

.sidebar-userbox {
  margin-top: auto;
  display: grid;
  gap: 6px;
}

.logout-btn {
  width: 100%;
  height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--sidebar-outline);
  background: rgba(255, 255, 255, 0.18);
  justify-content: center;
  gap: 6px;
}

:root.dark .logout-btn {
  background: rgba(255, 255, 255, 0.06);
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

:root.dark .logout-btn:hover {
  background: rgba(255, 255, 255, 0.10);
}

.logout-ico {
  display: none;
}

.ver {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Collapse behavior driven by html.nav-collapsed */

:root.nav-collapsed .sidebar {
  width: 56px;
  min-width: 56px;
  flex: 0 0 56px;
  padding: 14px 8px;
}

:root.nav-collapsed .logo {
  padding: 4px 0;
}

:root.nav-collapsed .logo img {
  width: 36px;
  height: 36px;
}

:root.nav-collapsed .nav-text {
  display: none;
}

:root.nav-collapsed .nav-item {
  justify-content: center;
  padding: 0;
}

:root.nav-collapsed .sidebar-footer {
  grid-template-columns: 1fr;
}

:root.nav-collapsed .ver {
  display: none;
}

:root.nav-collapsed .sidebar-username {
  display: none;
}

:root.nav-collapsed .logout-text {
  display: none;
}

:root.nav-collapsed .logout-ico {
  display: inline-block;
}

:root.nav-collapsed .logout-btn {
  padding: 0;
}

/* -----------------------------
   Card + page components
   ----------------------------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(30, 64, 175, 0.08);
}

.table-card {
  padding: 0;
  overflow-x: auto;
}

/* -----------------------------
   Header / Top Bar
   ----------------------------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.meta {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 6px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
}

.right {
  text-align: right;
}

.scanbox {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 220px;
}

.scanstatus {
  max-width: 320px;
}

/* -----------------------------
   Buttons
   ----------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: var(--btn-bg);
  color: var(--text);

  border: 1px solid var(--border);
  border-radius: 8px;

  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;

  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--btn-hover);
  text-decoration: none;
}

.btn.primary {
  background: var(--btn-primary);
  color: white;
  border-color: transparent;
}

.btn.primary:hover {
  background: var(--btn-primary-hover);
}

.btn.disabled,
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* -----------------------------
   Filters / Forms
   ----------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.filters label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  gap: 4px;
  color: var(--muted);
}

.filters input,
.filters select {
  background: transparent;
  color: var(--text);

  border: 1px solid var(--border);
  border-radius: 8px;

  padding: 6px 8px;
  font-size: 14px;
  min-width: 140px;
}

/* Dropdown menu colors (fix dark select menu readability) */

.filters select option {
  background: #ffffff;
  color: #020617;
}

:root.dark .filters select option {
  background: #111827; /* slightly lighter than bg for readability */
  color: #e5e7eb;
}

.filters input:focus,
.filters select:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus);
}

/* -----------------------------
   Table
   ----------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--table-head);
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

tbody tr {
  background: var(--table-row);
}

tbody tr:hover {
  background: var(--table-row-hover);
}

.urlcell {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* -----------------------------
   Pagination
   ----------------------------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 16px;
}

.pill {
  background: var(--btn-primary);
  color: white;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
}

/* -----------------------------
   Article Page
   ----------------------------- */

.summary {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;

  padding: 16px;
  margin-top: 16px;

  font-family: system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;

  white-space: pre-wrap;
}

:root.dark .summary {
  background: rgba(255, 255, 255, 0.04);
}

/* -----------------------------
   Utility
   ----------------------------- */

.hidden {
  display: none !important;
}

.center {
  text-align: center;
}

/* -----------------------------
   Mobile
   ----------------------------- */

@media (max-width: 900px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    height: auto;
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  :root.nav-collapsed .sidebar {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
  }

  .main {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .scanbox {
    justify-items: start;
  }

  .meta {
    flex-direction: column;
    gap: 4px;
  }

  .filters {
    flex-direction: column;
  }

  .filters input,
  .filters select {
    min-width: 100%;
  }

  th,
  td {
    font-size: 13px;
  }
}

