/* ==========================================================================
   Social Dashboard — Premium Dark Theme
   Inspired by Linear, Vercel, and Stripe dashboard aesthetics.
   Every class referenced by app.js is styled here.
   ========================================================================== */

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

/* ==========================================================================
   1. RESET & GLOBAL
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background: #111827;
  color: rgba(255, 255, 255, 0.9);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: #7c3aed;
  color: white;
}

/* ---- Scrollbar (thin, dark) ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

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

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

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

/* ==========================================================================
   2. TYPOGRAPHY
   ========================================================================== */

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: white;
  margin: 0;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: white;
}

p {
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
}

/* ==========================================================================
   3. LAYOUT — Sidebar + Main
   ========================================================================== */

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

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 240px;
  height: 100vh;
  background: #0f0f1a;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}

.nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: white;
  border-left: 3px solid #7c3aed;
}

.nav-icon {
  margin-right: 12px;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: 240px;
  padding: 32px;
  min-height: 100vh;
  background: #111827;
  flex: 1;
  transition: margin-left 0.3s ease;
}

/* ==========================================================================
   4. LOGIN PAGE
   ========================================================================== */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #0f0f1a 0%, #1e1b4b 100%);
  padding: 20px;
}

.login-card {
  max-width: 420px;
  width: 100%;
  padding: 40px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
}

.login-subtitle {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.95rem;
  margin-top: 6px;
}

.login-hint {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 6px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ==========================================================================
   5. PAGE HEADER
   ========================================================================== */

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

/* ==========================================================================
   6. STATS GRID
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 58, 237, 0.25);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.stat-icon {
  font-size: 2.5rem;
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

/* ==========================================================================
   7. SECTION
   ========================================================================== */

.section {
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   8. TABLE
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  white-space: nowrap;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   9. BADGES
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.badge-secondary {
  background: rgba(156, 163, 175, 0.2);
  color: #9ca3af;
}

/* ==========================================================================
   10. ACTIVITY
   ========================================================================== */

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-time {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
  min-width: 140px;
  flex-shrink: 0;
}

.activity-text {
  flex: 1;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

/* ==========================================================================
   11. CALENDAR
   ========================================================================== */

.cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
}

.cal-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.cal-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-grid {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cal-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: rgba(124, 58, 237, 0.15);
}

.cal-grid-header div {
  padding: 12px;
  text-align: center;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
}

.cal-grid-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-cell {
  min-height: 90px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.cal-cell:hover {
  background: rgba(124, 58, 237, 0.1);
}

.cal-cell.empty {
  background: transparent;
  cursor: default;
}

.cal-cell.empty:hover {
  background: transparent;
}

.cal-cell.today {
  background: rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.4);
}

.cal-day-num {
  font-weight: 600;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

.cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 6px;
}

.cal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ==========================================================================
   12. COMPOSER (Post Editor)
   ========================================================================== */

.composer {
  max-width: 700px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: white;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  transition: all 0.3s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
  outline: none;
}

.form-group textarea {
  min-height: 160px;
  resize: vertical;
}

.form-group select option {
  background: #1a1a2e;
  color: white;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.char-count {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
  margin-top: 4px;
}

.composer-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.media-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.media-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(239, 68, 68, 0.8);
  border: none;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s ease;
}

.media-remove:hover {
  background: #ef4444;
}

/* ==========================================================================
   13. AI TOOLS
   ========================================================================== */

.ai-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.ai-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
}

.ai-card:hover {
  transform: translateY(-3px);
  border-color: #7c3aed;
  box-shadow: 0 8px 25px rgba(124, 58, 237, 0.15);
}

.ai-card-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
}

.ai-card h3 {
  font-size: 1rem;
  color: white;
  margin: 0 0 8px;
}

.ai-card p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}

.ai-form-section {
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-result {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 20px;
}

.ai-result pre {
  white-space: pre-wrap;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
  font-family: 'Inter', sans-serif;
}

/* ==========================================================================
   14. ACCOUNTS
   ========================================================================== */

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

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

.account-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: all 0.3s ease;
}

.account-card:hover {
  border-color: rgba(124, 58, 237, 0.25);
}

.account-card .platform-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.account-card h3 {
  font-size: 1.1rem;
  margin: 0 0 4px;
}

.account-card .account-platform {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: capitalize;
}

.account-card .account-status {
  margin-top: 12px;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: rgba(255, 255, 255, 0.4);
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  display: block;
}

.empty-state p {
  font-size: 1.1rem;
  margin-bottom: 20px;
  color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   15. SETTINGS
   ========================================================================== */

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.settings-section {
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.api-key-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.api-key-group input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: white;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  transition: all 0.3s ease;
}

.api-key-group input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
  outline: none;
}

/* ==========================================================================
   16. BUTTONS
   ========================================================================== */

.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

.btn-danger {
  background: #ef4444;
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-outline:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
}

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

/* ==========================================================================
   17. LOADING & SPINNER
   ========================================================================== */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 16px;
  color: rgba(255, 255, 255, 0.5);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0%   { transform: rotate(0deg);   }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   18. MODAL
   ========================================================================== */

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
}

.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  min-width: 400px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 101;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 0;
}

.modal-post-item {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 8px;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.modal-post-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   19. UTILITIES
   ========================================================================== */

.text-muted {
  color: rgba(255, 255, 255, 0.4);
}

.hidden {
  display: none;
}

/* ==========================================================================
   20. RESPONSIVE
   ========================================================================== */

/* ---- Tablet / small desktop ---- */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .ai-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .ai-grid {
    grid-template-columns: 1fr;
  }

  .cal-cell {
    min-height: 60px;
  }

  .cal-day-num {
    font-size: 0.75rem;
  }

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

  .modal-content {
    min-width: auto;
    width: calc(100% - 32px);
    max-width: calc(100% - 32px);
  }

  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .composer-actions {
    flex-wrap: wrap;
  }
}
