/* ============================================================
   Freelance Inbox Cockpit — Styles
   ============================================================ */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-sidebar: #1a1d23;
  --bg-sidebar-hover: #2a2d35;
  --bg-sidebar-active: #33363f;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-sidebar: #d1d5db;
  --text-sidebar-active: #ffffff;
  --border: #e5e7eb;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --danger: #ef4444;
  --star: #f59e0b;
  --success: #10b981;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --transition: 150ms ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ---------- Auth Page ---------- */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(135deg, #1a1d23 0%, #2d3748 100%);
}
.auth-card {
  background: var(--bg-primary);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}
.auth-card .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}
.auth-card .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.auth-card .logo svg { width: 28px; height: 28px; }

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color var(--transition);
  outline: none;
  background: var(--bg-secondary);
}
.form-group input:focus {
  border-color: var(--accent);
  background: var(--bg-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 12px;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-secondary); }
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--bg-secondary); color: var(--text-primary); }

.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}
.auth-toggle a { font-weight: 600; }
.auth-error {
  background: #fef2f2;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-header {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-sidebar-active);
}
.sidebar-header svg { width: 22px; height: 22px; color: var(--accent); }

.sidebar-section {
  padding: 0 12px;
  margin-bottom: 8px;
}
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 8px 6px;
}
.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-sidebar);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.folder-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}
.folder-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
}
.folder-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.folder-item .folder-name { flex: 1; }
.folder-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--bg-sidebar-hover);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-sidebar);
  font-size: 13px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  min-height: 56px;
}
.top-bar .menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px;
}
.search-box {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  background: var(--bg-secondary);
  transition: all var(--transition);
}
.search-box input:focus {
  border-color: var(--accent);
  background: var(--bg-primary);
}
.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* ---------- Email Panes ---------- */
.email-panes {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Email List */
.email-list-pane {
  width: 380px;
  min-width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.email-list-header {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.email-list-header h2 {
  font-size: 16px;
  font-weight: 700;
}
.email-list-header .count {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}
.email-list-scroll {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background var(--transition);
}
.email-item:hover { background: #f9fafb; }
.email-item.active { background: var(--accent-light); }
.email-item.unread .email-sender { font-weight: 700; }
.email-item.unread .email-subject { font-weight: 600; color: var(--text-primary); }
.email-item.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.email-item { position: relative; }

.email-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.email-content {
  flex: 1;
  min-width: 0;
}
.email-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.email-sender {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-time {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: 8px;
}
.email-subject {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.email-preview {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.email-star {
  background: none;
  border: none;
  padding: 2px;
  color: #d1d5db;
  cursor: pointer;
  display: flex;
}
.email-star.starred { color: var(--star); }
.email-star svg { width: 14px; height: 14px; }
.email-attachment { color: var(--text-secondary); display: flex; }
.email-attachment svg { width: 14px; height: 14px; }

/* ---------- Email Detail ---------- */
.email-detail-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.email-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 12px;
}
.email-detail-empty svg { width: 48px; height: 48px; color: #d1d5db; }
.email-detail-empty p { font-size: 15px; }

.email-detail-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
}
.email-detail-toolbar .btn-back {
  display: none;
}

.email-detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}
.detail-subject {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 20px;
}
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.detail-sender-info {
  flex: 1;
}
.detail-sender-name {
  font-weight: 600;
  font-size: 15px;
}
.detail-sender-email {
  font-size: 13px;
  color: var(--text-secondary);
}
.detail-recipient {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.detail-date {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-top: 2px;
}
.detail-body {
  font-size: 15px;
  line-height: 1.7;
  color: #374151;
}
.detail-body p { margin-bottom: 14px; }
.detail-body ul, .detail-body ol { margin-bottom: 14px; padding-left: 24px; }
.detail-body li { margin-bottom: 4px; }

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state svg { width: 48px; height: 48px; color: #d1d5db; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }

/* ---------- Loading ---------- */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
}
.toast {
  background: var(--bg-sidebar);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.3s ease;
  margin-top: 8px;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
  .sidebar-overlay.open { display: block; }
  .top-bar .menu-toggle { display: flex; }
  .email-list-pane { width: 100%; min-width: 0; border-right: none; }
  .email-detail-pane { display: none; }
  .email-detail-pane.mobile-show {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg-primary);
  }
  .email-detail-pane.mobile-show .btn-back { display: flex; }
  .email-panes { flex-direction: column; }
}
@media (max-width: 600px) {
  .search-box { max-width: 100%; }
  .email-detail-scroll { padding: 20px 16px; }
  .detail-subject { font-size: 18px; }
}
