/* =========================================
   Lufyne — Global Design System
   ========================================= */

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

/* ─── CSS Variables ─── */
:root {
  /* Brand Colors */
  --brand-primary: #FF6B2B;
  --brand-primary-dark: #E5551A;
  --brand-primary-light: #FF8F5E;
  --brand-secondary: #1A1A2E;
  --brand-accent: #FFB347;

  /* Neutrals */
  --bg-dark: #0D0D14;
  --bg-card: #16161F;
  --bg-card-hover: #1E1E2A;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 107, 43, 0.4);

  /* Text */
  --text-primary: #F0F0F8;
  --text-secondary: #8A8AA0;
  --text-muted: #55556A;

  /* Status */
  --status-empty: #2A2A3A;
  --status-empty-text: #6B6B80;
  --status-occupied: #1A3A2A;
  --status-occupied-accent: #2ECC71;
  --status-pending: #3A2A1A;
  --status-pending-accent: #FFB347;
  --status-paid: #1A2A3A;
  --status-paid-accent: #3498DB;

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #FF6B2B 0%, #FF8F5E 100%);
  --gradient-dark: linear-gradient(135deg, #16161F 0%, #1E1E2A 100%);
  --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(255, 107, 43, 0.15) 0%, transparent 60%);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-brand: 0 4px 24px rgba(255, 107, 43, 0.3);
  --shadow-brand-lg: 0 8px 48px rgba(255, 107, 43, 0.4);

  /* Layout */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ─── Typography ─── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  line-height: 1.25;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-primary); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.btn:hover::before { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { box-shadow: var(--shadow-brand-lg); transform: translateY(-1px); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-hover); }

.btn-danger {
  background: rgba(231, 76, 60, 0.15);
  color: #E74C3C;
  border: 1px solid rgba(231, 76, 60, 0.3);
}
.btn-danger:hover { background: rgba(231, 76, 60, 0.25); }

.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-lg { padding: 16px 32px; font-size: 16px; }
.btn-xl { padding: 18px 40px; font-size: 17px; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }

.btn:disabled, .btn.loading {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
}
.card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ─── Form Elements ─── */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.form-input, .form-select, .form-textarea {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-primary);
  background: rgba(255, 107, 43, 0.05);
  box-shadow: 0 0 0 3px rgba(255, 107, 43, 0.12);
}
.form-input::placeholder { color: var(--text-muted); }
.form-select { cursor: pointer; }
option { background: var(--bg-card); color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}
.badge-empty { background: rgba(107,107,128,0.15); color: var(--status-empty-text); }
.badge-occupied { background: rgba(46,204,113,0.15); color: var(--status-occupied-accent); }
.badge-pending { background: rgba(255,179,71,0.15); color: var(--status-pending-accent); }
.badge-paid { background: rgba(52,152,219,0.15); color: var(--status-paid-accent); }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
}
.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-title { font-size: 20px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-size: 16px;
}
.modal-close:hover { color: var(--text-primary); border-color: var(--border-hover); }

/* ─── Toast Notifications ─── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn 0.3s ease forwards;
  min-width: 280px;
  max-width: 400px;
}
.toast.success { border-left: 3px solid var(--status-occupied-accent); }
.toast.error { border-left: 3px solid #E74C3C; }
.toast.warning { border-left: 3px solid var(--status-pending-accent); }
.toast.info { border-left: 3px solid var(--status-paid-accent); }
.toast.hiding { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* ─── Loading Spinner ─── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Page Loader ─── */
#page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.4s ease;
}
#page-loader .logo-mark {
  width: 56px; height: 56px;
  background: var(--gradient-brand);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  animation: pulse 1.5s ease infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,107,43,0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(255,107,43,0); }
}

/* ─── Sidebar Layout ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 36px; height: 36px;
  background: var(--gradient-brand);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-brand-name { font-weight: 700; font-size: 18px; }
.sidebar-brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active {
  background: rgba(255, 107, 43, 0.12);
  color: var(--brand-primary);
  border: 1px solid rgba(255, 107, 43, 0.2);
}
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  overflow-x: hidden;
  min-height: 100vh;
}
.content-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.content-header h1 { font-size: 24px; }
.content-body { padding: 32px; }

/* ─── Grid ─── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ─── Tag / Pill ─── */
.tag {
  display: inline-flex; align-items: center;
  padding: 4px 12px;
  background: rgba(255,107,43,0.1);
  border: 1px solid rgba(255,107,43,0.2);
  border-radius: var(--radius-full);
  color: var(--brand-primary);
  font-size: 12px; font-weight: 600;
}

/* ─── Divider ─── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 14px; margin-top: 8px; }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .sidebar { width: 220px; min-width: 220px; }
  .content-body { padding: 24px; }
}
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .nav-item span:not(.icon) { display: none; }
  .nav-item { padding: 10px; border-radius: var(--radius-sm); }
  .content-header { padding: 20px; }
  .content-body { padding: 20px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
