/* ═══════════════════════════════════════════════════════════
   Console Layout — Soniox-style Account Dashboard
   ═══════════════════════════════════════════════════════════ */

/* ─── Layout ─── */
.console-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ─── */
.console-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.sidebar-logo img {
  border-radius: 6px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 400;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
  text-align: left;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-item.active {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid #3b82f6;
  font-weight: 500;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg {
  opacity: 1;
  stroke: #3b82f6;
}

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 18px;
}

.nav-section-label {
  padding: 8px 18px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.project-selector {
  padding: 6px 18px 4px;
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: 500;
}

.project-name {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

/* Sidebar footer (user) */
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Main Content ─── */
.console-main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-primary);
  padding: 0;
}

.console-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--text-secondary);
  gap: 12px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-light);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── Sections ─── */
.console-section {
  display: none;
  padding: 28px 32px;
  max-width: 960px;
}

.console-section.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.15s;
}

.header-back-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ─── Dashboard Cards ─── */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.dash-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.dash-card.plan-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.02));
  border-color: rgba(59, 130, 246, 0.2);
}

.dash-card-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.dash-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dash-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dash-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.dash-value.accent-green {
  color: var(--success);
}

.dash-value.plan-free { color: var(--text-secondary); }
.dash-value.plan-starter { color: #60a5fa; }
.dash-value.plan-pro { color: #a78bfa; }
.dash-value.plan-business { color: #f59e0b; }

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

/* ─── Dashboard Row ─── */
.dashboard-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ─── Panel ─── */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* ─── Usage Bars ─── */
.usage-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.usage-bar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.usage-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.usage-bar-track {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.usage-bar-fill.stt-fill {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.usage-bar-fill.tts-fill {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

/* ─── Info Rows ─── */
.info-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.info-value {
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ─── Limits ─── */
.limits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.limit-item {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.limit-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.limit-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.limit-value.accent-green {
  color: var(--success);
}

/* ─── Badge ─── */
.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.provider-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.provider-badge.soniox {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.provider-badge.elevenlabs {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.status-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(74, 222, 128, 0.15);
  color: var(--success);
}

.status-badge.inactive {
  background: rgba(248, 113, 113, 0.15);
  color: var(--error);
}

.service-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.service-badge.stt {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.service-badge.tts {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

/* ─── Tables ─── */
.table-wrap {
  overflow-x: auto;
}

.console-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.console-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
}

.console-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.console-table tr:last-child td {
  border-bottom: none;
}

.console-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 12px !important;
}

/* ─── Pagination ─── */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ─── Settings Forms ─── */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 400px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-field input {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-field input:focus {
  border-color: #3b82f6;
}

.form-field input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.form-msg {
  font-size: 0.8rem;
}

.form-msg.success {
  color: var(--success);
}

.form-msg.error {
  color: var(--error);
}

/* ─── Buttons ─── */
.btn-primary {
  padding: 9px 20px;
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  padding: 6px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── Usage Filters ─── */
.usage-filters select {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
}

/* ─── Nav Group (expandable sub-items) ─── */
.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-parent {
  position: relative;
}

.nav-parent .nav-chevron {
  margin-left: auto;
  opacity: 0.5;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.nav-parent.expanded .nav-chevron {
  transform: rotate(90deg);
}

.nav-sub-items {
  display: none;
  flex-direction: column;
}

.nav-sub-items.open {
  display: flex;
}

.nav-item.nav-sub {
  padding-left: 48px;
  font-size: 0.82rem;
}

.nav-item.nav-sub.active {
  border-left: 3px solid #3b82f6;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
  font-weight: 500;
}

/* ─── Date Range Picker ─── */
.date-range-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-glass);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 4px 10px;
}

.date-range-picker input[type="date"] {
  background: transparent;
  border: none;
  color: #3b82f6;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding: 2px 0;
}

.date-range-picker input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
  filter: invert(0.5);
}

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

/* ─── Chart Section ─── */
.chart-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 24px 0 12px;
}

.chart-section-title:first-of-type {
  margin-top: 8px;
}

.chart-group {
  display: grid;
  gap: 14px;
  margin-bottom: 8px;
}

.chart-group.chart-row-2 {
  grid-template-columns: 1fr 1fr;
}

.chart-group.chart-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.chart-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
}

.chart-panel.chart-panel-full {
  grid-column: 1 / -1;
}

.chart-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chart-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

.chart-title strong {
  color: var(--text-primary);
  font-weight: 700;
}

.chart-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-container {
  position: relative;
  height: 180px;
}

.chart-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-yaxis-label {
  position: absolute;
  top: 0;
  right: 4px;
  font-size: 0.65rem;
  color: #9ca3af;
  font-weight: 500;
}

/* ─── Mobile ─── */
.mobile-topbar {
  display: none;
}

@media (max-width: 768px) {
  .console-sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: none;
  }

  .console-sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
  }

  .mobile-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .mobile-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    padding: 4px 8px;
  }

  .console-section {
    padding: 16px;
  }

  .dashboard-cards {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-row {
    grid-template-columns: 1fr;
  }

  .chart-group.chart-row-2,
  .chart-group.chart-row-3 {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 140px;
  }

  .date-range-picker {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
}

/* ═══════════ Transcribe Section ═══════════ */
.section-desc {
  color: var(--text-secondary, #94a3b8);
  font-size: 0.9rem;
  margin-top: -8px;
}

.transcribe-upload-area {
  border: 2px dashed var(--border, #334155);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.transcribe-upload-area:hover,
.transcribe-upload-area.drag-over {
  border-color: var(--accent, #3b82f6);
  background: rgba(59, 130, 246, 0.05);
}
.transcribe-upload-area p {
  margin: 8px 0 0;
  color: var(--text-secondary, #94a3b8);
}
.upload-link {
  color: var(--accent, #3b82f6);
  cursor: pointer;
  text-decoration: underline;
}
.upload-hint {
  font-size: 0.8rem;
  opacity: 0.6;
}

.transcribe-options {
  margin-top: 16px;
}
.transcribe-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface, #1e293b);
  border-radius: 8px;
  margin-bottom: 12px;
}
.transcribe-file-preview .file-icon { font-size: 1.3rem; }
.transcribe-file-preview .file-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.transcribe-file-preview .file-size {
  color: var(--text-secondary, #94a3b8);
  font-size: 0.85rem;
}
.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary, #94a3b8);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }

.transcribe-form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.transcribe-form-row .form-group {
  flex: 1;
}
.transcribe-form-row label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 4px;
}
.transcribe-form-row select {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 6px;
  color: var(--text-primary, #e2e8f0);
  font-size: 0.9rem;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.btn-sm {
  font-size: 0.8rem;
  padding: 4px 10px;
}

.transcribe-result-text {
  background: var(--surface, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 8px;
  padding: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text-primary, #e2e8f0);
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 500;
}
.status-pending   { background: #f59e0b22; color: #f59e0b; }
.status-processing{ background: #3b82f622; color: #3b82f6; }
.status-completed { background: #22c55e22; color: #22c55e; }
.status-failed    { background: #ef444422; color: #ef4444; }

/* Transcribe action buttons */
.tj-actions { display: flex; gap: 4px; }
.tj-actions button {
  background: none;
  border: 1px solid var(--border, #334155);
  color: var(--text-secondary, #94a3b8);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 0.78rem;
  cursor: pointer;
}
.tj-actions button:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary, #e2e8f0);
}

@media (max-width: 640px) {
  .transcribe-form-row { flex-direction: column; }
}

.file-name-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
