/* Panel de administración — Taiko Email */
/* Estilo limpio y funcional, sin dependencias externas */

: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;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

.hidden { display: none !important; }

/* --- Login --- */
.login-box {
  max-width: 360px;
  margin: 15vh auto;
  padding: 2rem;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-box h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.login-box .subtitle {
  color: var(--gray-500);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-box input {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.login-box button {
  padding: 0.65rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 500;
}

.login-box button:hover { background: var(--primary-dark); }

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* --- Header --- */
header {
  background: white;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

header h1 {
  font-size: 1.1rem;
  white-space: nowrap;
}

header nav {
  display: flex;
  gap: 0.25rem;
}

header nav a {
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  color: var(--gray-500);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
}

header nav a:hover { background: var(--gray-100); color: var(--gray-700); }
header nav a.active { background: var(--primary); color: white; }

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--gray-500);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-link:hover { text-decoration: underline; }

/* --- Main --- */
main {
  max-width: 1200px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card.clickable { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.stat-card.clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

.stat-card.highlight { border-left: 3px solid var(--primary); }
.stat-card.success .value { color: var(--success); }
.stat-card.danger .value { color: var(--danger); }
.stat-card.warning .value { color: var(--warning); }

/* --- Cards --- */
.card {
  background: white;
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--gray-700);
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-500);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}

tbody tr:hover { background: var(--gray-50); }

.clickable { cursor: pointer; }
.clickable:hover { background: var(--gray-100) !important; }

/* --- Status Badges --- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-queued { background: #dbeafe; color: #1d4ed8; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-sent { background: #d1fae5; color: #065f46; }
.badge-delivered { background: #065f46; color: white; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-bounced { background: #fecaca; color: #7f1d1d; }
.badge-spam { background: #fde68a; color: #78350f; }

/* --- Filters --- */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filters select,
.filters input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.filters input[type="text"] { flex: 1; min-width: 200px; }
.filters input[type="date"] { flex: none; min-width: auto; }

.btn-primary {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
}

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

.btn-secondary {
  padding: 0.5rem 1rem;
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
}

.btn-secondary:hover { background: var(--gray-100); }

.btn-danger {
  padding: 0.4rem 0.75rem;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-danger:hover { opacity: 0.9; }

.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--gray-300);
  background: white;
}

.btn-small:hover { background: var(--gray-100); }

/* --- Pagination --- */
.pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.pagination button {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--gray-300);
  background: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

.pagination button:hover { background: var(--gray-100); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Detail View --- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.detail-grid .card { margin-bottom: 0; }

.detail-row {
  display: flex;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.88rem;
}

.detail-row .label {
  width: 140px;
  flex-shrink: 0;
  color: var(--gray-500);
  font-weight: 500;
}

.detail-row .value {
  flex: 1;
  word-break: break-all;
}

.timeline {
  list-style: none;
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline li {
  position: relative;
  padding: 0.5rem 0;
  font-size: 0.85rem;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -1.5rem;
  top: 0.85rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
}

.timeline .event-type { font-weight: 600; }
.timeline .event-time { color: var(--gray-500); font-size: 0.8rem; }
.timeline .event-detail { color: var(--gray-500); font-size: 0.8rem; }

/* --- System View --- */
.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

#back-to-messages {
  color: var(--primary);
  text-decoration: none;
  font-weight: normal;
  font-size: 1rem;
}

#back-to-messages:hover { text-decoration: underline; }

/* --- Expandable text --- */
.expandable-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.expandable-text.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.expand-toggle {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0;
  margin-top: 0.2rem;
}

.expand-toggle:hover { text-decoration: underline; }

/* --- Active filters indicator --- */
.filters-active-label {
  align-self: center;
  font-size: 0.8rem;
  color: var(--gray-500);
  font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .header-left { gap: 1rem; }
  header nav { display: none; }
}
