/* =========================================================
   IVR Manager - Main Stylesheet  (v2 – dark/light mode)
   ========================================================= */

/* ---------- CSS custom properties (light default) ---------- */
:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1e2a38;
  --sidebar-header-bg: #162030;
  --sidebar-text: #c8d0d8;
  --sidebar-active: #3498db;
  --sidebar-hover: #253547;
  --sidebar-divider: #2d3f54;
  --accent: #3498db;

  /* Content area (light) */
  --body-bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f8f9fa;
  --text: #212529;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --thead-bg: #f8f9fa;
  --stat-value-color: #1e2a38;
}

/* ---------- Dark mode overrides ---------- */
[data-bs-theme="dark"] {
  --body-bg: #0f1923;
  --surface: #1a2332;
  --surface2: #1e2a3a;
  --text: #dee2e6;
  --text-muted: #8fa3b1;
  --border: #2d3f54;
  --thead-bg: #1e2a3a;
  --stat-value-color: #dee2e6;
}

/* ---------- Base ---------- */
body {
  background: var(--body-bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  transition: background 0.2s, color 0.2s;
}

/* ---------- Sidebar (always dark, unaffected by theme) ---------- */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: .75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid var(--sidebar-divider);
  background: var(--sidebar-header-bg);
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
}
.sidebar-header img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: left center;
}
.sidebar-header span { color: #fff; }

#sidebar .nav-link {
  color: var(--sidebar-text);
  padding: .5rem 1.2rem;
  font-size: .875rem;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  transition: background .15s, color .15s;
}
#sidebar .nav-link:hover  { background: var(--sidebar-hover); color: #fff; }
#sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }

.sidebar-divider { border-color: var(--sidebar-divider); margin: .4rem 1rem; }

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid var(--sidebar-divider);
  margin-top: auto;
}

/* Language switcher in sidebar */
.lang-switcher { display: flex; gap: 4px; margin-top: .5rem; }
.lang-switcher a {
  flex: 1;
  text-align: center;
  padding: 2px 0;
  font-size: .7rem;
  font-weight: 600;
  border-radius: 4px;
  text-decoration: none;
  color: var(--sidebar-text);
  border: 1px solid var(--sidebar-divider);
  transition: background .15s;
}
.lang-switcher a:hover  { background: var(--sidebar-hover); color: #fff; }
.lang-switcher a.active { background: var(--sidebar-active); color: #fff; border-color: var(--sidebar-active); }

/* ---------- Main content ---------- */
#page-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Page header */
.page-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.4rem; margin: 0; font-weight: 600; }

/* Content padding */
.content-body { padding: 0 1.5rem 2rem; flex: 1; }

/* ---------- Cards ---------- */
.stat-card {
  background: var(--surface);
  border-radius: .5rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-left: 4px solid var(--accent);
  transition: background .2s;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--stat-value-color); }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

.table-card {
  background: var(--surface);
  border-radius: .5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow: hidden;
  transition: background .2s;
}
.table-card .table { margin: 0; }
.table-card .table thead th {
  background: var(--thead-bg);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

/* ---------- Badges ---------- */
.badge-did { background: #e8f4fd; color: #1a7abf; font-weight: 500; }
.badge-any { background: #f0f0f0; color: #666; font-weight: 500; }

[data-bs-theme="dark"] .badge-did { background: #1a3a50; color: #5fb8f5; }
[data-bs-theme="dark"] .badge-any { background: #2a2a2a; color: #9aafbb; }

/* Count badge – visible in both light and dark modes */
.badge-count {
  background-color: #e9ecef;
  color: #495057;
}
[data-bs-theme="dark"] .badge-count {
  background-color: #2d3f54 !important;
  color: #c8d0d8 !important;
  border-color: #3d5068 !important;
}

/* ---------- API key display ---------- */
.api-key-display {
  font-family: 'Courier New', monospace;
  font-size: .8rem;
  background: var(--surface2);
  padding: .3rem .6rem;
  border-radius: .3rem;
  border: 1px solid var(--border);
  letter-spacing: .02em;
  word-break: break-all;
}

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  flex-direction: column;
  gap: 0;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: .75rem;
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo img {
  width: 100%;
  max-width: 260px;
  height: auto;
  border-radius: 14px;
  margin-bottom: .75rem;
}
.login-logo h4 { font-size: 1.3rem; font-weight: 700; margin: 0; }
.login-logo p  { color: var(--text-muted); font-size: .875rem; margin: .25rem 0 0; }

/* Login lang switcher */
.login-lang {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 1.25rem;
}
.login-lang a {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: background .15s;
}
.login-lang a:hover  { background: var(--surface2); }
.login-lang a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- No empresa warning ---------- */
.no-empresa-warning {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.no-empresa-warning i {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
  color: var(--border);
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  padding: .75rem 1rem;
  font-size: .75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Login footer */
.login-footer {
  color: rgba(200,210,220,.5);
  font-size: .72rem;
  margin-top: 1rem;
  text-align: center;
}

/* ---------- Dark mode toggle button ---------- */
#theme-toggle {
  background: none;
  border: 1px solid var(--sidebar-divider);
  color: var(--sidebar-text);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .75rem;
  cursor: pointer;
  transition: background .15s;
  width: 100%;
  margin-top: .4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
#theme-toggle:hover { background: var(--sidebar-hover); color: #fff; }

/* ---------- Misc ---------- */
.btn-delete { transition: all .15s; }

/* Audit collapse rows */
[data-bs-theme="dark"] .bg-light { background: var(--surface2) !important; }

/* Ensure form controls inherit theme in dark mode */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: var(--surface);
}

/* XAPI section in empresa form */
.xapi-section {
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
  background: var(--surface2);
}
.xapi-section h6 {
  margin-bottom: .75rem;
  color: var(--accent);
  font-weight: 700;
}
