/* OnTrak - studio-style dark theme */

:root {
  --bg-0: #0A0A0A;
  --bg-1: #111111;
  --bg-2: #1A1A1A;
  --bg-3: #222222;
  --border: #2A2A2A;
  --border-hover: #3A3A3A;
  --text: #FFFFFF;
  --text-dim: #A0A0A0;
  --text-faint: #6A6A6A;
  --accent: #C8FF00;
  --accent-hover: #B5E600;
  --danger: #FF4D4D;
  --instagram: #E1306C;
  --tiktok: #FE2C55;
  --success: #4DFF88;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

/* ============================== Auth screens ============================== */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
}

.brand {
  text-align: center;
  margin-bottom: 32px;
}

.brand-mark {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-mark .dot {
  color: var(--accent);
}

.brand-tag {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
  transition: background 120ms ease, border-color 120ms ease;
}

.btn:hover { background: var(--bg-2); border-color: var(--border-hover); }

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(255, 77, 77, 0.1); }

.btn-block { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

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

.auth-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

.error-msg {
  background: rgba(255, 77, 77, 0.1);
  border: 1px solid rgba(255, 77, 77, 0.3);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ============================== Dashboard ============================== */

.dash {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
  padding: 0 8px;
}
.sidebar-brand .dot { color: var(--accent); }

.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  padding: 0 8px;
  margin-bottom: 8px;
}

.artist-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
}

.artist-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 2px 0;
  cursor: pointer;
  color: var(--text-dim);
  font-weight: 500;
  transition: background 100ms ease;
}

.artist-tab:hover { background: var(--bg-2); color: var(--text); }

.artist-tab.active {
  background: var(--bg-2);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.artist-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.add-artist-btn {
  margin: 12px 4px 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 100ms, color 100ms;
}
.add-artist-btn:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  padding: 0 8px;
}

.user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

/* Main pane */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  flex-shrink: 0;
  background: var(--bg-0);
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-right: 32px;
}

.tabs {
  display: flex;
  gap: 4px;
  height: 100%;
}

.tab {
  display: flex;
  align-items: center;
  padding: 0 18px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  height: 100%;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 18px;
  right: 18px;
  height: 2px;
  background: var(--accent);
}

.pane {
  flex: 1;
  overflow: auto;
  display: none;
}
.pane.active { display: flex; flex-direction: column; }

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  color: var(--text-dim);
  padding: 48px 24px;
}

.empty-state h2 {
  color: var(--text);
  font-size: 20px;
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0 0 16px;
  max-width: 360px;
}

/* ============================== Accounts pane ============================== */

.accounts-pane {
  padding: 24px;
  flex: 1;
}

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

.accounts-header h2 {
  font-size: 20px;
  margin: 0;
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.account-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-3);
  overflow: hidden;
  flex-shrink: 0;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }

.account-meta { flex: 1; min-width: 0; }
.account-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-platform {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.platform-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.platform-badge.instagram { background: rgba(225, 48, 108, 0.15); color: #FF7AAB; }
.platform-badge.tiktok { background: rgba(254, 44, 85, 0.15); color: #FF6B8A; }

.connect-buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ============================== Chat & Schedule pane ============================== */

.chat-pane {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-col {
  width: 40%;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.chat-msg {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-msg.user .chat-bubble {
  background: var(--accent);
  color: #000;
}

.chat-msg.assistant .chat-bubble {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.chat-msg-meta {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chat-input {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 160px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 100ms, color 100ms;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

.upload-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  margin: 0 12px 8px;
}

/* Calendar */
.calendar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.calendar-title {
  font-size: 16px;
  font-weight: 600;
}

.calendar-nav {
  display: flex;
  gap: 6px;
}

.calendar-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}

.cal-day {
  border-right: 1px solid var(--border);
  padding: 10px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cal-day:last-child { border-right: none; }

.cal-day-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}
.cal-day-name {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.cal-day-num {
  font-size: 18px;
  font-weight: 700;
}
.cal-day.today .cal-day-num { color: var(--accent); }

.post-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  cursor: pointer;
  position: relative;
  transition: border-color 100ms;
}

.post-card:hover { border-color: var(--border-hover); }

.post-card.instagram { border-left: 3px solid var(--instagram); }
.post-card.tiktok { border-left: 3px solid var(--tiktok); }

.post-card.scheduled { background: rgba(200, 255, 0, 0.06); }
.post-card.failed { background: rgba(255, 77, 77, 0.06); border-color: rgba(255, 77, 77, 0.3); }

.post-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 6px;
}

.post-type-badge {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 3px;
}

.post-time {
  font-size: 10px;
  color: var(--text-faint);
}

.post-thumb {
  width: 100%;
  height: 60px;
  background: var(--bg-3);
  border-radius: 4px;
  margin-bottom: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-faint);
}
.post-thumb img { width: 100%; height: 100%; object-fit: cover; }

.post-caption {
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.post-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  margin-right: 4px;
}
.post-status-dot.scheduled { background: var(--success); }
.post-status-dot.failed { background: var(--danger); }
.post-status-dot.planned { background: transparent; border: 1px solid var(--text-faint); }

.calendar-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  gap: 12px;
}

.calendar-footer-info {
  font-size: 12px;
  color: var(--text-dim);
}

/* Edit post drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 440px;
  max-width: 90vw;
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  z-index: 101;
  transform: translateX(100%);
  transition: transform 200ms ease;
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.drawer-header h3 { margin: 0; font-size: 16px; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

.drawer-footer {
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.media-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.media-pick {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--bg-3);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
}

.media-pick.selected { border-color: var(--accent); }
.media-pick img { width: 100%; height: 100%; object-fit: cover; }
.media-pick .video-tag {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-3);
}

/* ============================== Media library pane ============================== */

.media-pane { padding: 24px; flex: 1; }

.media-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.media-toolbar h2 { font-size: 20px; margin: 0; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.media-tile {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.media-tile-preview {
  aspect-ratio: 1;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-dim);
}
.media-tile-preview img { width: 100%; height: 100%; object-fit: cover; }

.media-tile-meta {
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.media-tile-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  color: var(--text-dim);
}

.dropzone {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 20px;
  transition: border-color 100ms, background 100ms;
}
.dropzone.over {
  border-color: var(--accent);
  background: rgba(200, 255, 0, 0.04);
  color: var(--text);
}

/* ============================== Modal ============================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  padding: 28px;
}

.modal h3 { margin: 0 0 18px; font-size: 18px; }

.modal-footer {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================== Misc ============================== */

.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-faint);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.thinking {
  color: var(--text-faint);
  font-size: 12px;
  padding: 0 20px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hidden { display: none !important; }
