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

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.5;
}

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

/* ─── Login Page ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-light) 100%);
}

.login-card {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo img { height: 56px; object-fit: contain; }
.login-logo .app-name {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--brand-primary);
  display: block;
  margin-top: 0.5rem;
}

/* ─── Forms ─── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 0.375rem;
}
.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: var(--font-size-base);
  font-family: inherit;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}
.form-control.error { border-color: var(--color-danger); }
.form-error {
  font-size: var(--font-size-xs);
  color: var(--color-danger);
  margin-top: 0.25rem;
}

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

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-secondary);
  color: white;
}
.btn-primary:hover:not(:disabled) { filter: brightness(0.9); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }

.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-danger:hover:not(:disabled) { filter: brightness(0.9); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--font-size-xs); }
.btn-lg { padding: 0.875rem 1.75rem; font-size: var(--font-size-base); }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 0.5rem; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ─── Cards ─── */
.card {
  background: white;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: var(--font-size-lg); font-weight: 600; color: var(--gray-900); }
.card-body { padding: 1.5rem; }

/* ─── Tables ─── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 500;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--gray-200);
}
tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: var(--font-size-lg); font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  padding: 0.25rem;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Modal como bottom sheet no mobile */
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    max-width: 100%;
    max-height: 88vh;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  }
  .modal-footer { justify-content: stretch; }
  .modal-footer .btn { flex: 1; justify-content: center; }
}

/* ─── Alerts / Toasts ─── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.875rem 1.25rem;
  border-radius: var(--border-radius);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease;
  max-width: 360px;
}
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-info { background: var(--color-info); }

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

/* ─── Loading ─── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand-secondary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; align-items: center; padding: 3rem; }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state-text { font-size: var(--font-size-sm); }

/* ─── Stats cards ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.stat-card {
  background: white;
  border-radius: var(--border-radius-lg);
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--gray-200);
}
.stat-label { font-size: var(--font-size-xs); color: var(--gray-500); font-weight: 500; text-transform: uppercase; }
.stat-value { font-size: var(--font-size-3xl); font-weight: 700; color: var(--gray-900); margin-top: 0.25rem; }
.stat-meta { font-size: var(--font-size-xs); color: var(--gray-400); margin-top: 0.25rem; }

/* ─── Progress bar ─── */
.progress {
  height: 8px;
  background: var(--gray-200);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--brand-secondary);
  border-radius: 9999px;
  transition: width 0.3s;
}
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.success { background: var(--color-success); }

/* ─── Utility ─── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-muted { color: var(--gray-400); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.p-4 { padding: 1rem; }
.rounded { border-radius: var(--border-radius); }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-100);
}
.settings-row:last-child { border-bottom: none; }
