/* ============== VARIABLES ============== */
:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --success: #16a34a;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius: 10px;
}

/* ============== RESET ============== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ============== LOGIN ============== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 20px;
}

.login-card h1 {
  text-align: center;
  font-size: 22px;
  margin-bottom: 4px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-card .form-group { margin-bottom: 16px; }
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.login-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fff;
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 15px;
}

.login-card .alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* ============== TOPBAR ============== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo.small {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-info {
  font-size: 14px;
  color: var(--text-muted);
}

.user-info strong {
  color: var(--text);
  font-weight: 600;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--primary-light);
  color: var(--primary-dark);
  margin-left: 6px;
}

/* ============== DASHBOARD LAYOUT ============== */
.dashboard {
  display: grid;
  grid-template-columns: 240px 1fr;
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: fixed;
  top: 60px;
  bottom: 0;
  width: 240px;
  overflow-y: auto;
}

.sidebar nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar nav li {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.sidebar nav li:hover:not(.disabled) {
  background: #f1f5f9;
}

.sidebar nav li.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.sidebar nav li.disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

.sidebar nav li.disabled::before {
  content: "🔒";
  font-size: 11px;
  margin-right: 2px;
}

.content {
  grid-column: 2;
  padding: 28px 32px;
  max-width: 1400px;
}

.view { animation: fadeIn 0.18s ease-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============== PAGE HEADER ============== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 24px;
  margin-bottom: 4px;
  font-weight: 700;
}

.page-header .muted {
  color: var(--text-muted);
  font-size: 14px;
}

.muted { color: var(--text-muted); }
.center { text-align: center; }

/* ============== EMPTY STATE ============== */
.empty-state {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  margin: 0 auto 16px;
}

.empty-state h2 {
  font-size: 18px;
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.empty-modules {
  list-style: none;
  display: inline-block;
  text-align: left;
}

.empty-modules li {
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 14px;
  position: relative;
  padding-left: 22px;
}

.empty-modules li::before {
  content: "○";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

/* ============== BUTTONS ============== */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: #f1f5f9; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover { background: #b91c1c; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  margin-right: 4px;
  transition: all 0.12s;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--text);
}

.btn-icon.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

/* ============== TABLE ============== */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  background: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: #fafbfc; }

.data-table .muted { color: var(--text-muted); font-style: italic; }

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-badge.activo { background: #dcfce7; color: #166534; }
.status-badge.inactivo { background: #f1f5f9; color: var(--text-muted); }

/* ============== HEADER ACTIONS ============== */
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.header-actions input[type="search"] {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  width: 280px;
  max-width: 100%;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.header-actions input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ============== MODAL ============== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  z-index: 1000;
  overflow-y: auto;
  animation: backdropIn 0.15s ease-out;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  animation: modalIn 0.18s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}

.modal-close:hover { background: #f1f5f9; }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  border-radius: 0 0 14px 14px;
}

/* ============== FORMS ============== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 18px;
}

.form-grid .full { grid-column: 1 / -1; }

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: var(--text);
}

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

.form-group textarea {
  min-height: 70px;
  resize: vertical;
  font-family: inherit;
}

.form-group .error-msg {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
  border-color: var(--danger);
}

.form-group.has-error .error-msg { display: block; }

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

/* ============== TOAST ============== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  min-width: 260px;
  max-width: 360px;
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }

/* ============== RESPONSIVE ============== */
@media (max-width: 768px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .content { grid-column: 1; padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .header-actions input[type="search"] { width: 100%; }
}
