/* ==========================================================================
   PilotPost Design System — base.css
   Light theme with Salesforce-style blue gradient accents
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- Variables ---------- */
:root {
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --bg-hover: rgba(1, 118, 211, 0.04);
  --bg-sidebar: #f8fafc;

  /* Gradient accent */
  --accent: #0176D3;
  --accent-start: #0176D3;
  --accent-end: #1B96FF;
  --gradient: linear-gradient(135deg, #0176D3, #1B96FF);
  --gradient-subtle: linear-gradient(135deg, rgba(1,118,211,0.08), rgba(27,150,255,0.08));
  --gradient-bg: linear-gradient(135deg, rgba(1,118,211,0.03), rgba(27,150,255,0.03));

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-disabled: #cbd5e1;
  --text-on-gradient: #ffffff;

  /* Semantic */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.08);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.08);

  /* Borders & shadows */
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 0.9375rem;
}
a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-end); }
img { max-width: 100%; display: block; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; color: var(--text-primary); }
h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; letter-spacing: -0.01em; }
h3 { font-size: 1.125rem; }
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Container ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm); font-size: 0.875rem;
  font-weight: 600; font-family: inherit; cursor: pointer; border: none;
  transition: all 0.2s; text-decoration: none; line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--gradient); color: var(--text-on-gradient);
  box-shadow: 0 2px 8px rgba(1,118,211,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(1,118,211,0.35); }

.btn-secondary {
  background: var(--bg-primary); color: var(--text-primary);
  border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-secondary); }

.btn-danger {
  background: var(--error-bg); color: var(--error);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.12); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: 6px; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 24px;
  box-shadow: var(--shadow-sm);
}
.post-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px; margin-bottom: 12px;
  transition: all 0.2s; box-shadow: var(--shadow-xs);
}
.post-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.status-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px;
  box-shadow: var(--shadow-xs);
}
.status-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.status-value { font-size: 1.5rem; font-weight: 700; }
.status-value.green { color: var(--success); }
.status-value.red { color: var(--error); }
.status-value.accent { color: var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 20px; font-size: 0.75rem; font-weight: 600;
}
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--error-bg); color: var(--error); }
.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-gray { background: rgba(148,163,184,0.1); color: var(--text-muted); }
.badge-accent { background: rgba(1,118,211,0.1); color: var(--accent); }

/* Post status badges */
.post-status { font-size: 0.75rem; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.status-approved { background: var(--success-bg); color: var(--success); }
.status-needs_review { background: var(--warning-bg); color: var(--warning); }
.status-published { background: var(--info-bg); color: var(--info); }
.status-failed { background: var(--error-bg); color: var(--error); }

/* ---------- Forms ---------- */
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="search"], input[type="number"], textarea, select {
  width: 100%; padding: 10px 14px;
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.9rem; font-family: inherit; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(1,118,211,0.12);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }

/* Custom select */
.flat-select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}

/* Toggle switch */
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle { position: relative; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; box-shadow: var(--shadow-xs);
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; }
.alert-success { background: var(--success-bg); border: 1px solid rgba(16,185,129,0.2); color: #065f46; }
.alert-warning { background: var(--warning-bg); border: 1px solid rgba(245,158,11,0.2); color: #92400e; }
.alert-error { background: var(--error-bg); border: 1px solid rgba(239,68,68,0.2); color: #991b1b; }
.alert-info { background: var(--info-bg); border: 1px solid rgba(59,130,246,0.2); color: #1e40af; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 20px;
  box-shadow: var(--shadow-lg); display: none;
  max-width: 380px; font-size: 0.9rem;
}
#toast.success { border-left: 3px solid var(--success); }
#toast.error { border-left: 3px solid var(--error); }
#toast.info { border-left: 3px solid var(--info); }

/* ---------- Modal ---------- */
#modal-overlay {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(15,23,42,0.5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-content {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.modal-text { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ---------- Sidebar Layout ---------- */
.sidebar {
  width: 240px; position: fixed; top: 0; left: 0; height: 100vh;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  padding: 24px 16px; display: flex; flex-direction: column;
  z-index: 50;
}
.sidebar .logo {
  font-size: 1.15rem; font-weight: 700; color: var(--accent);
  margin-bottom: 32px; padding: 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  text-decoration: none; transition: all 0.15s; margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.6; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item:hover svg { opacity: 0.85; }
.nav-item.active { background: rgba(1,118,211,0.08); color: var(--accent); font-weight: 600; }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.user-email { font-size: 0.78rem; color: var(--text-muted); padding: 8px 12px; word-break: break-all; }

/* ---------- Main Content ---------- */
.content { margin-left: 240px; padding: 32px 40px; min-height: 100vh; }
.page-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; }
.page-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 28px; }

/* ---------- Section ---------- */
.section { margin-bottom: 28px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

/* ---------- Grid ---------- */
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }

/* ---------- Post Elements ---------- */
.post-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.post-scheduled { font-size: 0.8rem; color: var(--text-muted); }
.post-text { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.7; white-space: pre-wrap; }
.post-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Action buttons */
.action-btn {
  padding: 7px 14px; border-radius: 6px; font-size: 0.8rem;
  cursor: pointer; border: none; font-weight: 600;
  transition: all 0.15s; font-family: inherit;
}
.action-btn:hover { transform: translateY(-1px); }
.btn-approve { background: var(--gradient); color: #fff; }
.btn-reject { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.btn-reject:hover { background: rgba(239,68,68,0.12); }
.btn-edit { background: var(--info-bg); color: var(--info); border: 1px solid rgba(59,130,246,0.2); }
.btn-edit:hover { background: rgba(59,130,246,0.12); }
.btn-postnow { background: #0077b5; color: #fff; }

/* Edit area */
.post-edit-area {
  display: none; width: 100%; min-height: 120px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.9rem; line-height: 1.6; padding: 12px;
  font-family: inherit; resize: vertical; outline: none;
  margin-bottom: 4px; transition: border-color 0.2s;
}
.post-edit-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(1,118,211,0.12); }
.post-edit-msg { font-size: 0.8rem; min-height: 1.2em; margin-bottom: 4px; }

/* ---------- Row layout (account page) ---------- */
.row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row-label { font-size: 0.875rem; color: var(--text-secondary); font-weight: 500; }
.row-value { font-size: 0.875rem; color: var(--text-primary); }

/* ---------- Confidence colors ---------- */
.confidence-high { color: var(--success); }
.confidence-mid { color: var(--warning); }
.confidence-low { color: #f97316; }

/* ---------- Calendar grid ---------- */
.calendar-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 24px; }
.calendar-day {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; min-height: 80px;
}
.calendar-day-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile Bottom Nav ---------- */
.mobile-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-primary); border-top: 1px solid var(--border);
  z-index: 100; padding: 6px 0 env(safe-area-inset-bottom, 6px);
}
.mobile-nav-inner {
  display: flex; justify-content: space-around; align-items: center;
}
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 8px; font-size: 0.65rem; color: var(--text-muted);
  text-decoration: none; transition: color 0.15s;
}
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item span { font-size: 1.2rem; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 20px 16px 80px; }
  .mobile-nav { display: block; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar-grid { grid-template-columns: repeat(2, 1fr); }
  .page-title { font-size: 1.3rem; }
}
@media (max-width: 480px) {
  .status-grid { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: 1fr; }
  .post-actions { flex-direction: column; }
  .post-actions .action-btn { width: 100%; text-align: center; }
}
