/* Social Auto-Pilot SaaS - High Density Design Theme */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-canvas: #05060b;
  --bg-sidebar: #0a0c1a;
  --bg-panel: rgba(255, 255, 255, 0.04);
  --bg-panel-hover: rgba(255, 255, 255, 0.06);
  --bg-card-secondary: #0a0c1a;
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-medium: rgba(255, 255, 255, 0.10);
  --border-focus: rgba(59, 130, 246, 0.5);

  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-highlight: #ffffff;

  --accent-blue: #2563eb;
  --accent-blue-hover: #3b82f6;
  --accent-blue-light: #60a5fa;
  --accent-purple: #a855f7;
  --accent-purple-light: #c084fc;
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-xl: 16px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Base Monospace Typography */
.font-mono {
  font-family: var(--font-mono);
}

.tracking-tighter {
  letter-spacing: -0.05em;
}

/* Micro Header & Label Styling */
.micro-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 700;
}

/* High Density App Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: 250px;
  min-width: 250px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb 0%, #9333ea 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #ffffff;
  font-size: 1.05rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.sidebar-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  font-weight: 600;
}

.sidebar-link .icon {
  font-size: 1rem;
  width: 18px;
  text-align: center;
}

/* Sidebar Active Tenant Box */
.tenant-status-box {
  margin: 0.75rem;
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
}

.tenant-status-header {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.tenant-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-blue-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tenant-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
  flex-shrink: 0;
}

/* Main Viewport Container */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(circle at top right, rgba(30, 58, 138, 0.20) 0%, #05060b 60%, #05060b 100%);
}

/* Header */
.app-header {
  height: 56px;
  min-height: 56px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
}

.header-breadcrumbs .crumb-muted {
  color: var(--text-dim);
}

.header-breadcrumbs .crumb-divider {
  width: 1px;
  height: 14px;
  background-color: rgba(255, 255, 255, 0.15);
}

.header-breadcrumbs .crumb-active {
  color: #ffffff;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-provider-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border-medium);
  font-size: 0.75rem;
}

.ai-provider-pill .label {
  color: var(--text-dim);
}

.ai-provider-pill .provider {
  font-weight: 700;
  color: var(--accent-purple-light);
}

.user-avatar-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #334155;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.user-avatar-badge:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

/* Main Content Workspace */
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Metrics 4-Column Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.5rem 1.5rem 1rem 1.5rem;
}

@media (max-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-medium);
  padding: 1.1rem;
  border-radius: var(--radius-xl);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.metric-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-title {
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.04em;
  color: #ffffff;
}

.metric-trend {
  font-size: 10px;
  margin-top: 0.35rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.metric-trend.trend-up { color: var(--accent-emerald-light); }
.metric-trend.trend-neutral { color: var(--text-dim); }
.metric-trend.trend-info { color: var(--accent-blue-light); }
.metric-trend.trend-warning { color: var(--accent-amber); }

/* Panels & Workspace Containers */
.workspace-grid {
  padding: 0 1.5rem 1.5rem 1.5rem;
  display: flex;
  gap: 1.25rem;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1024px) {
  .workspace-grid {
    flex-direction: column;
  }
}

/* Left Panel (AI Generator / Composer) */
.tool-panel {
  width: 360px;
  min-width: 340px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.tool-panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ffffff;
}

.accent-bar-purple {
  width: 6px;
  height: 16px;
  background: var(--accent-purple);
  border-radius: 2px;
  display: inline-block;
}

.accent-bar-blue {
  width: 6px;
  height: 16px;
  background: var(--accent-blue);
  border-radius: 2px;
  display: inline-block;
}

/* Right Panel (Queue / Table) */
.table-panel {
  flex: 1;
  background: var(--bg-card-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.table-panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-medium);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
}

.table-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

/* High Density Data Table */
.dense-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.dense-table thead {
  background: rgba(255, 255, 255, 0.04);
  position: sticky;
  top: 0;
  z-index: 10;
}

.dense-table th {
  padding: 0.65rem 1.25rem;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.dense-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s ease;
}

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

.dense-table td {
  padding: 0.85rem 1.25rem;
  font-size: 0.82rem;
  vertical-align: middle;
}

/* Status Bar Footer */
.app-statusbar {
  margin-top: auto;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.status-indicator-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-indicator-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 10px;
  color: var(--text-muted);
}

.status-dot-emerald {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.8);
  display: inline-block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--accent-blue);
  color: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: var(--accent-blue-hover);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-pill {
  border-radius: 9999px;
  font-size: 10px;
  padding: 0.3rem 0.75rem;
}

.btn-tiktok {
  background: #000000;
  border: 1px solid rgba(254, 44, 85, 0.4);
  color: #ffffff;
}

.btn-tiktok:hover {
  border-color: rgba(254, 44, 85, 0.8);
  box-shadow: 0 0 14px rgba(254, 44, 85, 0.25);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.25);
}

/* Forms & High Density Inputs */
.glass-input, .glass-select, .glass-textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  font-size: 0.82rem;
  outline: none;
  font-family: inherit;
  transition: all 0.15s ease;
}

.glass-input:focus, .glass-select:focus, .glass-textarea:focus {
  border-color: var(--border-focus);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.glass-select option {
  background-color: var(--bg-sidebar);
  color: var(--text-main);
}

/* Platform Badges */
.badge-platform-tiktok {
  background: #000000;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-platform-instagram {
  background: rgba(131, 24, 67, 0.3);
  color: #f472b6;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(244, 114, 182, 0.2);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-platform-youtube {
  background: rgba(153, 27, 27, 0.3);
  color: #f87171;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(248, 113, 113, 0.2);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-pill.status-pending { color: #60a5fa; }
.status-pill.status-pending .status-dot { background-color: #60a5fa; }

.status-pill.status-published { color: #34d399; }
.status-pill.status-published .status-dot { background-color: #34d399; box-shadow: 0 0 6px rgba(52, 211, 153, 0.6); }

.status-pill.status-failed { color: #f87171; }
.status-pill.status-failed .status-dot { background-color: #f87171; }

/* Existing Badge Compatibility */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-published {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-failed {
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.badge-tenant {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue-light);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

/* Glass Panel and Card standard classes */
.glass-panel {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.glass-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.25rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent-blue-light);
  background: rgba(59, 130, 246, 0.05);
}

/* Media preview */
.media-preview-box {
  width: 100%;
  aspect-ratio: 16/9;
  max-height: 180px;
  background: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
}

.media-preview-box video, .media-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Platform toggle group */
.platform-toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.platform-btn {
  padding: 0.5rem 0.4rem;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  transition: all 0.15s ease;
}

.platform-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.platform-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
  color: #ffffff;
}

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: #0a0c1a;
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.82rem;
  animation: toastIn 0.2s ease-out forwards;
}

.toast-success { border-color: rgba(16, 185, 129, 0.5); }
.toast-error { border-color: rgba(244, 63, 94, 0.5); }
.toast-info { border-color: rgba(59, 130, 246, 0.5); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Mobile Navbar Styles */
#navbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1.5rem;
    border-radius: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

#nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

#nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

/* Mobile breakpoint */
@media (max-width: 640px) {
    #nav-toggle {
        display: block;
    }
    #nav-links {
        display: none;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        padding: 1rem 0;
        gap: 0.75rem;
        border-top: 1px solid rgba(255,255,255,0.06);
        margin-top: 0.5rem;
    }
    #nav-links.open {
        display: flex;
    }
    #nav-links a,
    #nav-links button {
        width: 100%;
        text-align: center;
        padding: 0.6rem 0;
        border-radius: 8px;
        background: rgba(255,255,255,0.02);
    }
    #nav-links a:hover,
    #nav-links button:hover {
        background: rgba(255,255,255,0.06);
    }
    #nav-links .btn {
        justify-content: center;
    }
    .db-badge {
        display: none !important;
    }
}

/* Hide DB badge on small screens */
.db-badge {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

@media (max-width: 640px) {
    .db-badge {
        display: none;
    }
}