/* ==========================================================================
   ATMOPEL - Panel de Administración Master (CSS)
   ========================================================================== */

:root {
  --admin-bg: #f8fafc;
  --admin-sidebar: #0d0f12;
  --admin-card: #ffffff;
  --admin-green: #00e600;
  --admin-green-dark: #00b300;
  --admin-border: #e2e8f0;
  --admin-text: #1e293b;
  --admin-text-muted: #64748b;
  --font-main: 'Inter', -apple-system, sans-serif;
  --font-heading: 'Barlow Condensed', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--admin-bg);
  color: var(--admin-text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: var(--admin-sidebar);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand h2 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #ffffff;
}

.sidebar-menu {
  list-style: none;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: rgba(0, 230, 0, 0.12);
  color: var(--admin-green);
}

.sidebar-link.active {
  font-weight: 700;
  border-left: 3px solid var(--admin-green);
}

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

/* Main Area */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.admin-topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--admin-border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #0f172a;
}

.admin-content {
  padding: 28px;
  flex: 1;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(0, 230, 0, 0.12);
  color: var(--admin-green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.stat-lbl {
  font-size: 0.82rem;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Card Containers & Tables */
.admin-card {
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
  margin-bottom: 24px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  background: #f8fafc;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  color: #475569;
  border-bottom: 2px solid var(--admin-border);
}

.admin-table td {
  padding: 14px;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:hover {
  background: #fbfcfe;
}

/* Buttons & Inputs */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--admin-green);
  color: #000000;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-admin:hover {
  background: #00ff2b;
  transform: translateY(-1px);
}

.btn-admin-dark {
  background: var(--admin-sidebar);
  color: #ffffff;
}

.btn-admin-dark:hover {
  background: #242933;
}

.btn-admin-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-admin-danger:hover {
  background: #fca5a5;
}

/* Form Styles */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 0.92rem;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--admin-green-dark);
  box-shadow: 0 0 0 3px rgba(0, 230, 0, 0.2);
}

.img-preview-box {
  width: 120px;
  height: 120px;
  border: 2px dashed var(--admin-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #f8fafc;
  margin-top: 8px;
}

.img-preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Chat Console (Admin) */
.chat-console-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - 180px);
  min-height: 540px;
}

.chat-sessions-list {
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  overflow-y: auto;
}

.chat-session-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--admin-border);
  cursor: pointer;
  transition: background 0.15s;
}

.chat-session-card:hover,
.chat-session-card.active {
  background: #f1f5f9;
}

.chat-session-card.active {
  border-left: 4px solid var(--admin-green-dark);
}

.chat-active-panel {
  background: #ffffff;
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-active-header {
  padding: 14px 20px;
  background: #0f172a;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-active-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.chat-active-footer {
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid var(--admin-border);
  display: flex;
  gap: 12px;
}

/* Badges */
.badge-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-status.pendiente {
  background: #fef3c7;
  color: #b45309;
}

.badge-status.completado {
  background: #dcfce7;
  color: #15803d;
}

.badge-status.abierto {
  background: #dcfce7;
  color: #15803d;
}

.badge-status.resuelto {
  background: #f1f5f9;
  color: #475569;
}

/* Responsive */
@media (max-width: 900px) {
  body {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
  }

  .chat-console-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}