/* LtrGen Custom Styles - Supplements Tailwind */

/* ============ CSS Variables / Theme ============ */
:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --accent: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1e40af;
  --glow: rgba(59, 130, 246, 0.5);
}

.dark {
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --primary-dark: #2563eb;
  --surface: #1e293b;
  --surface-alt: #0f172a;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --sidebar-bg: #020617;
}

/* ============ Global ============ */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--surface-alt);
  color: var(--text);
  min-height: 100vh;
}

/* ============ Scrollbar ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ============ Sidebar ============ */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: #f1f5f9;
}

.sidebar-nav a.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-left-color: #3b82f6;
}

.sidebar-section {
  padding: 16px 24px 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
  font-weight: 600;
}

/* ============ Main Content ============ */
.main-content {
  margin-left: 260px;
  min-height: 100vh;
}

.top-bar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.page-content { padding: 32px; }

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }

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

.card-body { padding: 24px; }

/* ============ Stat Cards ============ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(to right, var(--primary), var(--accent));
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px var(--glow); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-warning { background: var(--warning); color: white; }

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

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

/* ============ Forms ============ */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

textarea.form-input { min-height: 120px; resize: vertical; }

select.form-input { cursor: pointer; }

/* ============ Tables ============ */
.table-container { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tbody tr:hover { background: var(--surface-alt); }

/* ============ Badges ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-active { background: #d1fae5; color: #065f46; }
.badge-suspended { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-draft { background: #e0e7ff; color: #3730a3; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-generating { background: #dbeafe; color: #1e40af; }
.badge-watermarked { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-invoiced { background: #dbeafe; color: #1e40af; }

.dark .badge-active { background: #064e3b; color: #6ee7b7; }
.dark .badge-suspended { background: #7f1d1d; color: #fca5a5; }

/* ============ Stepper (Wizard) ============ */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  position: relative;
}

.stepper-step.active { color: var(--primary); font-weight: 600; }
.stepper-step.completed { color: var(--success); }

.stepper-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.stepper-step.active .stepper-number {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.stepper-step.completed .stepper-number {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.stepper-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 40px;
}

.stepper-line.completed { background: var(--success); }

/* ============ Progress Bar ============ */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ============ Modal ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-overlay.show { opacity: 1; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.modal-overlay.show .modal { transform: translateY(0); }

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

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ============ Toast Notifications ============ */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  transform: translateX(120%);
  transition: transform 0.3s ease;
  min-width: 300px;
  max-width: 450px;
}

.toast.show { transform: translateX(0); }

.toast-success { background: #065f46; color: #d1fae5; }
.toast-error { background: #991b1b; color: #fee2e2; }
.toast-info { background: #1e3a8a; color: #dbeafe; }
.toast-warning { background: #92400e; color: #fef3c7; }

/* ============ Letter Preview ============ */
.letter-preview-frame {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  overflow: hidden;
}

.letter-preview-frame iframe {
  width: 100%;
  border: none;
  min-height: 600px;
}

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  opacity: 0.4;
}

.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }

/* ============ Loading ============ */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-alt) 50%, var(--border) 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; } }

/* ============ Restricted Banner ============ */
.restricted-banner {
  background: linear-gradient(135deg, #991b1b, #7f1d1d);
  color: white;
  padding: 60px 20px;
  text-align: center;
  border-radius: 16px;
  margin: 40px;
}

.restricted-banner h2 { font-size: 2rem; margin-bottom: 12px; }

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ============ Animations ============ */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.slide-in { animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
