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

/* Variables */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
}

/* Typography */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-700);
  background: var(--gray-50);
}

h1, h2, h3 { color: var(--gray-900); }
h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

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

code {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  background: var(--gray-100);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Navigation */
.nav {
  background: var(--gray-900);
  padding: 0.75rem 0;
  margin-bottom: 2rem;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav .logo {
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
}

.nav .logo:hover { text-decoration: none; }

.nav nav a {
  color: var(--gray-300);
  margin-left: 1.5rem;
}

.nav nav a:hover { color: white; }

/* Footer */
footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--gray-200);
  text-align: center;
  color: var(--gray-500);
  font-size: 0.85rem;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

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

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-300); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #15803d; }

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

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #b91c1c; }

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Forms */
.form { max-width: 500px; }

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--gray-700);
}

.form-group .required { color: var(--danger); }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="email"],
.form-group input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.875rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--gray-500);
  font-size: 0.75rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  max-width: none;
}

.inline-form input { flex: 1; }

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
}

.search-form input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  min-width: 200px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td { border-bottom: none; }
tr:hover { background: var(--gray-50); }

.url-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status badges */
.status {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-revoked {
  background: #fee2e2;
  color: #991b1b;
}

/* Event types */
.event-type {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
}

.event-create { background: #dbeafe; color: #1e40af; }
.event-update { background: #fef3c7; color: #92400e; }
.event-revoke { background: #fee2e2; color: #991b1b; }
.event-activate { background: #dcfce7; color: #166534; }
.event-delete { background: #fecaca; color: #7f1d1d; }
.event-redirect { background: var(--gray-100); color: var(--gray-700); }

/* Cards */
.card {
  background: white;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 1rem;
}

/* Detail page */
.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.detail-main dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem 1rem;
}

.detail-main dt {
  font-weight: 500;
  color: var(--gray-500);
}

.detail-main dd {
  color: var(--gray-900);
  word-break: break-all;
}

/* QR Preview */
.qr-preview {
  text-align: center;
}

.qr-image {
  max-width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.download-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline { display: inline; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--gray-500);
}

/* Events table */
.events-table th, .events-table td {
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
}

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}

.auth-card {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
}

.auth-card h1 {
  text-align: center;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.auth-subtitle {
  text-align: center;
  color: var(--gray-500);
  margin-bottom: 1.5rem;
}

.auth-form .form-group {
  margin-bottom: 1rem;
}

.btn-block {
  width: 100%;
  padding: 0.75rem 1rem;
}

.input-disabled {
  background: var(--gray-100);
  color: var(--gray-500);
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-200);
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* User info in nav */
.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user-name {
  color: var(--gray-300);
  font-size: 0.875rem;
}

.nav-user form {
  display: inline;
}

.nav-user .btn-logout {
  background: transparent;
  color: var(--gray-300);
  border: 1px solid var(--gray-500);
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

.nav-user .btn-logout:hover {
  background: var(--gray-700);
  color: white;
}
