/* ==========================================================================
   Mk WhatsApp API - Admin Dashboard Styles
   ========================================================================== */

:root {
  --bg-main: #0B0F19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1F2937;
  --bg-glass: rgba(17, 24, 39, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(37, 211, 102, 0.3);
  
  --brand-wa: #25D366;
  --brand-wa-dark: #128C7E;
  --brand-wa-gradient: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  --accent-cyan: #38BDF8;
  --accent-indigo: #818CF8;
  --accent-purple: #A855F7;
  --accent-amber: #F59E0B;
  --accent-rose: #EF4444;

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-glow: 0 0 30px -10px rgba(37, 211, 102, 0.25);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(37, 211, 102, 0.06) 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(56, 189, 248, 0.05) 0%, transparent 45%);
}

h1, h2, h3, h4, .brand-font {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

/* --- Layout --- */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  padding: 24px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
}

.sidebar-brand img {
  width: 36px;
  height: 36px;
}

.sidebar-brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #FFF;
}

.sidebar-brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(37, 211, 102, 0.15);
  color: var(--brand-wa);
  border: 1px solid rgba(37, 211, 102, 0.3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 4px;
}

.sidebar-menu {
  list-style: none;
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(37, 211, 102, 0.1);
  color: var(--brand-wa);
  border-color: rgba(37, 211, 102, 0.25);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.sidebar-footer {
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--brand-wa-gradient);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #000;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main Content Area */
.main-layout {
  flex: 1;
  margin-left: 270px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  height: 72px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.page-title-wrap h1 {
  font-size: 1.35rem;
  font-weight: 700;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.content-body {
  padding: 32px;
  flex: 1;
}

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

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-wa { background: rgba(37, 211, 102, 0.15); color: var(--brand-wa); }
.icon-cyan { background: rgba(56, 189, 248, 0.15); color: var(--accent-cyan); }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.icon-rose { background: rgba(239, 68, 68, 0.15); color: var(--accent-rose); }
.icon-purple { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); }

.stat-info .stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-info .stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  margin-top: 2px;
}

/* Sections */
.panel-section {
  display: none;
}

.panel-section.active {
  display: block;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 24px;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.card-body {
  padding: 24px;
}

/* --- Tables --- */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  padding: 12px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

td {
  padding: 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: rgba(37, 211, 102, 0.15);
  color: var(--brand-wa);
  border: 1px solid rgba(37, 211, 102, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-expired {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-suspended {
  background: rgba(100, 116, 139, 0.2);
  color: #CBD5E1;
  border: 1px solid rgba(100, 116, 139, 0.4);
}

.badge-plan {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-plan-developer {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-plan-business {
  background: rgba(37, 211, 102, 0.15);
  color: var(--brand-wa);
  border: 1px solid rgba(37, 211, 102, 0.3);
}

.badge-plan-enterprise {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  filter: none;
}

.btn-primary {
  background: var(--brand-wa-gradient);
  color: #0B0F19;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(37, 211, 102, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFF;
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--brand-wa);
  color: var(--brand-wa);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: #EF4444;
  color: #FFF;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --- Forms & Inputs --- */
.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: rgba(11, 15, 25, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-wa);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.input-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Key Display Pill */
.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #A7F3D0;
}

/* --- Modals (Regla: Nunca usar alerts o confirms nativos) --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-backdrop.show {
  display: flex;
  opacity: 1;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  width: 100%;
  max-width: 540px;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.show .modal-dialog {
  transform: translateY(0);
}

.modal-dialog.modal-lg {
  max-width: 780px;
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Modal de Confirmación Destructiva */
.confirm-box {
  text-align: center;
  padding: 12px 8px;
}

.confirm-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-rose);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
}

.confirm-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.confirm-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Notificaciones STICKY (Regla obligatoria) --- */
.sticky-notification-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  width: 100%;
  pointer-events: none;
}

.sticky-toast {
  pointer-events: auto;
  background: var(--bg-surface-elevated);
  border-left: 4px solid var(--brand-wa);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
}

.sticky-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.sticky-toast.toast-error {
  border-left-color: var(--accent-rose);
}

.sticky-toast.toast-warning {
  border-left-color: var(--accent-amber);
}

.toast-icon {
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* --- Pantalla de Login Admin --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-card);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--brand-wa-gradient);
}

.login-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px auto;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 28px;
}

/* Keys list items */
.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.key-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.key-item-app {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.key-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Modern Pagination Component --- */
.pagination-container {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pagination-pagesize {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pagination-pagesize select {
  width: auto;
  min-width: 96px;
  padding: 5px 8px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  background-color: rgba(11, 15, 25, 0.95);
  cursor: pointer;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.pagination-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 10px;
  min-width: 32px;
  height: 32px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  font-family: inherit;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--brand-wa);
  color: var(--brand-wa);
  background: rgba(37, 211, 102, 0.08);
}

.pagination-btn.active {
  background: var(--brand-wa);
  color: #0B0F19;
  border-color: var(--brand-wa);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.pagination-btn:disabled,
.pagination-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 32px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Responsiveness */
@media (max-width: 900px) {
  .sidebar {
    width: 72px;
    padding: 16px 8px;
  }
  .sidebar-brand-title, .sidebar-brand-badge, .nav-item span, .user-info {
    display: none;
  }
  .sidebar-brand img {
    margin: 0 auto;
  }
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  .main-layout {
    margin-left: 72px;
  }
}
