/* ============================================================
   Rack Up Pro — Shared Stylesheet
   ============================================================ */

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

/* ---------- CSS Variables ---------- */
:root {
  --bg-color: #0f172a;
  --surface-color: rgba(30, 41, 59, 0.7);
  --surface-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #f59e0b;
  --accent-gradient: linear-gradient(135deg, #f59e0b, #d97706);
  --error-color: #ef4444;
  --success-color: #22c55e;
  --radius: 12px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

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

a { color: var(--accent-color); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button { cursor: pointer; font-family: inherit; }

/* ---------- Glass Card ---------- */
.glass-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2rem;
}

/* ---------- Form Elements ---------- */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 0.625rem 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.form-control::placeholder { color: var(--text-secondary); opacity: 0.7; }

select.form-control { appearance: none; }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  transition: opacity 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-gradient);
  color: #0f172a;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
}

.btn-outline:hover { border-color: var(--accent-color); color: var(--accent-color); }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--error-color);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-sm { font-size: 0.8125rem; padding: 0.375rem 0.75rem; }

.btn-full { width: 100%; }

/* ---------- Center Wrapper (auth pages) ---------- */
.center-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.center-wrapper .glass-card {
  width: 100%;
  max-width: 420px;
}

/* ---------- Dashboard Layout ---------- */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.95);
  border-right: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 1rem;
}

.sidebar-brand span {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-color);
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  margin-left: auto;
  padding: 0.25rem;
  line-height: 1;
}

.sidebar nav { flex: 1; padding: 0 0.75rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 0.25rem;
}

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

.nav-item.active {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-color);
}

.nav-item.logout { color: var(--error-color); margin-top: auto; }
.nav-item.logout:hover { background: rgba(239,68,68,0.1); }

.sidebar-footer { padding: 0 0.75rem; margin-top: 0.5rem; }

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--surface-border);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 1rem;
}

.topbar h1 {
  font-size: 1.25rem;
  font-weight: 600;
  flex: 1;
}

/* ---------- User Profile (topbar) ---------- */
.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f172a;
  flex-shrink: 0;
}

.user-profile-info { display: flex; flex-direction: column; }
.user-profile-name { font-size: 0.875rem; font-weight: 600; }
.user-profile-email { font-size: 0.75rem; color: var(--text-secondary); }

/* ---------- Page Content Padding ---------- */
.page-content {
  padding: 2rem;
  flex: 1;
}

/* ---------- Tab Content ---------- */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---------- Stats Grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-color);
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
}

thead tr {
  border-bottom: 1px solid var(--surface-border);
}

thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 0.875rem 1rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: rgba(34,197,94,0.15); color: var(--success-color); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--accent-color); }
.badge-error { background: rgba(239,68,68,0.15); color: var(--error-color); }

/* ---------- Services Grid ---------- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.service-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.service-card h3 { font-size: 1rem; font-weight: 600; }
.service-card p { font-size: 0.875rem; color: var(--text-secondary); }

/* ---------- Section Header ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-header h2 { font-size: 1.125rem; font-weight: 600; }

/* ---------- Search Input ---------- */
.search-input {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.875rem;
  transition: border-color 0.2s;
  min-width: 200px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.search-input::placeholder { color: var(--text-secondary); opacity: 0.7; }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: none;
}

.alert.show { display: block; }
.alert-error { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: var(--error-color); }
.alert-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.3); color: var(--success-color); }

/* ---------- Mobile Menu Toggle ---------- */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 0.5rem;
  flex-shrink: 0;
}

/* ---------- Sidebar Overlay ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 45;
}

.sidebar-overlay.active { display: block; }

/* ---------- Modal Backdrop ---------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal-card {
  background: #1e293b;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-header h2 { font-size: 1.125rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.125rem;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text-primary); }

/* ---------- Profile Info Cards ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.info-card .info-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.info-card .info-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---------- Utility Classes ---------- */
.hidden { display: none !important; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-4 { gap: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-accent { color: var(--accent-color); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-error { color: var(--error-color); }
.text-success { color: var(--success-color); }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }

/* ---------- Divider ---------- */
.divider {
  border: none;
  border-top: 1px solid var(--surface-border);
  margin: 1.5rem 0;
}

/* ============================================================
   Responsive — Tablet (≤ 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   Responsive — Mobile (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  /* Sidebar becomes off-canvas */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 50;
    width: 280px;
  }

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

  .sidebar-close { display: flex; }

  /* Show hamburger */
  .menu-toggle { display: flex; }

  /* Topbar adjustments */
  .topbar { padding: 0.875rem 1rem; }

  /* Main content */
  .page-content { padding: 1.25rem 1rem; }

  /* Stats grid 2 columns */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.875rem; }

  /* User profile text hidden on small screens */
  .user-profile-info { display: none; }
}

/* ============================================================
   Responsive — Small Mobile (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  /* Stats grid 1 column */
  .stats-grid { grid-template-columns: 1fr; }

  /* Form rows stack */
  .form-row { flex-direction: column; }

  /* Glass card padding reduction */
  .glass-card { padding: 1.5rem 1.25rem; }

  /* Modal becomes bottom sheet */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 92vh;
  }

  /* Section header stacks */
  .section-header { flex-direction: column; align-items: flex-start; }

  .search-input { width: 100%; min-width: unset; }
}
