/* =========================================================
   Orbita — Dashboard shell
   ========================================================= */

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--sp-5) var(--sp-4);
  font-weight: 800;
  font-size: var(--fs-lg);
}
.sidebar-nav { flex: 1; padding: var(--sp-2) var(--sp-3); overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--fs-sm);
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--surface-sunken); text-decoration: none; color: var(--text-primary); }
.sidebar-nav a.active { background: var(--brand-wash); color: var(--brand-strong); }
.sidebar-nav .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-section-label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); padding: var(--sp-4) 14px var(--sp-2);
}
.sidebar-footer {
  padding: var(--sp-4);
  border-top: 1px solid var(--border-hairline);
}
.plan-card {
  background: var(--brand-wash);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--brand-strong);
  margin-bottom: var(--sp-3);
}
.plan-card strong { display: block; font-size: var(--fs-sm); margin-bottom: 2px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--series-1), var(--series-7));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px;
}
.user-meta { min-width: 0; }
.user-name { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main column */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--border-hairline);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-6);
  background: var(--surface-page);
  position: sticky; top: 0; z-index: 10;
  gap: var(--sp-4);
}
.app-topbar h1 { font-size: var(--fs-xl); margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }
.mobile-nav-toggle { display: none; }

.app-content { padding: var(--sp-6); max-width: 1280px; width: 100%; margin: 0 auto; }

/* Stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.stat-tile { padding: var(--sp-5); }
.stat-tile .label { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--sp-2); }
.stat-tile .value { font-size: var(--fs-2xl); font-weight: 800; }
.stat-tile .delta { font-size: var(--fs-xs); font-weight: 700; margin-top: 6px; }
.delta-up { color: var(--status-good-text); }
.delta-down { color: var(--status-critical); }

.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--sp-5); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-hairline);
}
.panel-head h3 { margin: 0; font-size: var(--fs-md); }
.panel-body { padding: var(--sp-5); }

/* Post list items */
.post-row {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-hairline);
}
.post-row:last-child { border-bottom: none; }
.post-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.post-title { font-size: var(--fs-sm); font-weight: 600; }
.post-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

/* Platform badges */
.pill-instagram { color: #c2255c; background: color-mix(in srgb, #e87ba4 20%, transparent); }
.pill-tiktok    { color: var(--text-primary); background: var(--surface-sunken); }
.pill-youtube   { color: #b91c1c; background: color-mix(in srgb, #e34948 18%, transparent); }
.pill-facebook  { color: var(--brand-strong); background: var(--brand-wash); }
.pill-x         { color: var(--text-primary); background: var(--surface-sunken); }
.pill-linkedin  { color: #0a5c9e; background: color-mix(in srgb, #2a78d6 16%, transparent); }

/* Calendar */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); flex-wrap: wrap; gap: var(--sp-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--border-hairline); border-radius: var(--radius-md); overflow: hidden; }
.cal-dow { background: var(--surface-2); padding: 10px; font-size: var(--fs-xs); font-weight: 700; text-align: center; color: var(--text-muted); border-bottom: 1px solid var(--border-hairline); }
.cal-cell {
  min-height: 118px;
  border-right: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-hairline);
  padding: 8px;
  background: var(--surface-1);
  position: relative;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other-month { background: var(--surface-2); }
.cal-cell.today { background: var(--brand-wash); }
.cal-daynum { font-size: var(--fs-xs); font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.cal-post-chip {
  font-size: 10.5px; padding: 3px 6px; border-radius: 6px; margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
  font-weight: 600;
}
.cal-add-btn {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: var(--surface-sunken); color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 13px; opacity: 0;
  transition: opacity .1s;
}
.cal-cell:hover .cal-add-btn { opacity: 1; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border-hairline); }
.table td { padding: 12px; border-bottom: 1px solid var(--border-hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* Account cards */
.accounts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.account-card { padding: var(--sp-5); text-align: center; }
.account-logo {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto var(--sp-3);
  display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff;
}
.account-card h4 { margin-bottom: 4px; }
.account-status { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--sp-4); }
.account-stats { display: flex; justify-content: center; gap: var(--sp-5); margin: var(--sp-4) 0; font-size: var(--fs-xs); color: var(--text-muted); }
.account-stats strong { display: block; font-size: var(--fs-md); color: var(--text-primary); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11,11,11,.5);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: var(--sp-4);
}
.modal { background: var(--surface-1); border-radius: var(--radius-lg); max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-5); border-bottom: 1px solid var(--border-hairline); }
.modal-head h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 4px; }
.modal-body { padding: var(--sp-5); }
.modal-foot { padding: var(--sp-5); border-top: 1px solid var(--border-hairline); display: flex; justify-content: flex-end; gap: var(--sp-3); }

/* Chart legend / table-view toggle (dataviz skill) */
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.chart-legend { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-secondary); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.view-toggle { display: flex; gap: 2px; background: var(--surface-sunken); border-radius: var(--radius-pill); padding: 3px; }
.view-toggle button {
  border: none; background: transparent; padding: 6px 12px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-secondary); cursor: pointer;
}
.view-toggle button.active { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* Empty / drop zones */
.dropzone {
  border: 2px dashed var(--border-grid);
  border-radius: var(--radius-lg);
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--brand); background: var(--brand-wash); }
.dropzone .dz-icon { font-size: 40px; margin-bottom: var(--sp-3); }

/* Shorts pipeline */
.pipeline-steps { display: flex; gap: var(--sp-3); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.pipeline-step {
  flex: 1; min-width: 140px; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline); background: var(--surface-1); font-size: var(--fs-xs);
  display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-weight: 700;
}
.pipeline-step.active { border-color: var(--brand); color: var(--brand-strong); background: var(--brand-wash); }
.pipeline-step.done { color: var(--status-good-text); }
.pipeline-step .step-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface-sunken); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0;
}
.pipeline-step.active .step-num { background: var(--brand); color: #fff; }
.pipeline-step.done .step-num { background: var(--status-good); color: #fff; }

.clip-card { border: 1px solid var(--border-hairline); border-radius: var(--radius-md); overflow: hidden; background: var(--surface-1); }
.clip-preview { aspect-ratio: 9/16; background: var(--surface-sunken); position: relative; }
.clip-preview video { width: 100%; height: 100%; object-fit: cover; }
.clip-body { padding: var(--sp-3); }
.clip-score { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 700; color: var(--brand-strong); }
.clips-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--sp-4); }

.progress-bar { height: 8px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--brand); transition: width .2s ease; border-radius: 999px; }

.key-status { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); font-weight: 700; }
.key-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.key-ok { color: var(--status-good-text); } .key-ok .dot { background: var(--status-good); }
.key-missing { color: var(--text-muted); } .key-missing .dot { background: var(--border-axis); }

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .accounts-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -100%; top: 0; z-index: 100; transition: left .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .mobile-nav-toggle { display: inline-flex; }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .accounts-grid { grid-template-columns: 1fr; }
  .app-content { padding: var(--sp-4); }
  .cal-grid { grid-template-columns: 1fr; }
  .cal-dow:not(:first-child) { display:none; }
}
