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

:root {
  --bg-main: #f4f7fb;
  --bg-soft: #eef2f7;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #0284c7;
  --brand-hover: #0369a1;
  --brand-light: #e0f2fe;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --success-hover: #059669;
  --info: #3b82f6;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-active: #38bdf8;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--text);
  background: var(--bg-main);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* Base Layout */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.bg-grid {
  background: var(--bg-main);
}

.centered-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at center, var(--bg-soft), var(--bg-main));
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0,0,0,0.06);
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  background: linear-gradient(135deg, var(--brand), #0ea5e9);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.brand-logo h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: white;
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: white;
  transform: translateX(4px);
}

.nav-link.active {
  background: rgba(56, 189, 248, 0.1);
  color: var(--sidebar-active);
  position: relative;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 24px;
  background: var(--sidebar-active);
  border-radius: 0 4px 4px 0;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
  margin: 20px 0 8px 14px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.version-info {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
}

/* Main Content Area */
.main-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar Modern */
.topbar-modern {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px 16px;
  background: rgba(244, 247, 251, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle-modern {
  margin: 4px 0 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-dropdown-trigger {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  user-select: none;
}

.user-dropdown-trigger::-webkit-details-marker {
  display: none;
}

.user-dropdown-trigger:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--brand), #0ea5e9);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.user-dropdown-text {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-dropdown-caret {
  color: var(--muted);
  font-size: 0.8rem;
  transition: var(--transition);
}

.user-dropdown[open] .user-dropdown-caret {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  padding: 8px;
  z-index: 100;
  animation: dropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top right;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.user-dropdown-header {
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.user-dropdown-header strong {
  font-size: 0.95rem;
}

.user-dropdown-header span {
  font-size: 0.8rem;
  color: var(--muted);
}

.dropdown-divider {
  border: none;
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.user-dropdown-link,
.user-dropdown-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
}

.user-dropdown-link:hover {
  background: var(--bg-soft);
  color: var(--brand);
}

.user-dropdown-logout {
  color: var(--danger);
}

.user-dropdown-logout:hover {
  background: #fef2f2;
}

.user-dropdown-form {
  margin: 0;
}

/* Content Area */
.content-wrap {
  padding: 16px 32px 40px;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* Cards & Panels */
.auth-card,
.form-panel,
.table-section,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 36px;
  box-shadow: var(--shadow-lg);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.metric-card {
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.metric-card::after {
  content: '';
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.1), rgba(14, 165, 233, 0.05));
  border-radius: 50%;
}

.metric-card p {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 8px 0;
}

.metric-card h2 {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
}

/* Forms & Inputs */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 4px;
  display: block;
}

input,
textarea,
select {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  color: var(--text);
  transition: var(--transition);
  width: 100%;
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}

textarea {
  resize: vertical;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}

.btn-primary:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(2, 132, 199, 0.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-soft);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: var(--danger-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3);
}

/* Tables */
.table-section {
  padding: 20px;
  margin-bottom: 24px;
}

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

.table-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.table-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.table-controls input,
.table-controls select {
  width: auto;
  min-width: 200px;
}

.table-container {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

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

th, td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: var(--surface-2);
}

/* Pagination */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.table-pagination span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

/* Alerts */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 0.95rem;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

/* Specific Page Styles */
.users-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

.user-create-panel {
  padding: 24px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-pill.is-active { background: #d1fae5; color: #065f46; }
.status-pill.is-inactive { background: #fee2e2; color: #991b1b; }
.status-pill.is-admin { background: #e0e7ff; color: #3730a3; }
.status-pill.is-user { background: #e2e8f0; color: #475569; }

.report-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.report-status-queued { background: #e0e7ff; color: #3730a3; }
.report-status-running { background: #dbeafe; color: #1e40af; }
.report-status-completed { background: #d1fae5; color: #065f46; }
.report-status-failed { background: #fee2e2; color: #991b1b; }

.report-progress-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface-2);
}

.report-progress-track {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.report-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #0ea5e9);
  transition: width 0.3s ease;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-secondary { background: var(--bg-soft); color: var(--muted); }
.badge-warning { background: #fffbeb; color: #92400e; border: 1px solid #fef3c7; }
.badge-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.badge-info { background: var(--brand-light); color: var(--brand); border: 1px solid var(--brand); }

.btn-info {
  background: var(--info);
  color: white;
  border: none;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-info:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
}

/* Table Status Rows */
tr.status-informed { background-color: rgba(16, 185, 129, 0.04); }
tr.status-informed:hover { background-color: rgba(16, 185, 129, 0.08) !important; }

tr.status-blocked { background-color: rgba(245, 158, 11, 0.04); }
tr.status-blocked:hover { background-color: rgba(245, 158, 11, 0.08) !important; }

tr.status-registered { background-color: transparent; }

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  position: relative;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Flash Banner */
.flash-banner {
  margin-bottom: 20px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  animation: dropdownIn 0.3s ease-out;
}

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.is-hidden { display: none; }

.autofill-trap {
  position: absolute;
  opacity: 0;
  height: 0;
  width: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

/* Responsive */
@media (max-width: 1024px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: var(--transition);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .users-layout {
    grid-template-columns: 1fr;
  }
}
