/* ===== Variables ===== */
:root {
  --udi-blue: #253A7B;
  --udi-blue-dark: #1a2d5e;
  --udi-blue-light: #3451a0;
  --udi-yellow: #FFCC29;
  --udi-yellow-dark: #e6b800;
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 120px;
  --bg-light: #f0f2f5;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --card-radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-light);
  color: #1a1a2e;
  overflow-x: hidden;
}

/* ===== Topbar ===== */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  z-index: 100;
  transition: var(--transition);
}

.topbar-banner {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  position: relative;
}

.topbar-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(37,58,123,0.92), rgba(26,45,94,0.85));
}

.topbar-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 2rem;
  gap: 1.2rem;
}

.topbar-logo {
  width: 70px;
  height: 70px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.topbar-info h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.topbar-info p {
  font-size: 0.9rem;
  color: var(--udi-yellow);
  margin: 0;
  font-weight: 500;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--udi-blue-dark) 0%, var(--udi-blue) 50%, #2c4494 100%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar-header {
  padding: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.sidebar-nav {
  list-style: none;
  padding: 0.8rem 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-item {
  margin: 2px 0.6rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.sidebar-link.active {
  color: var(--udi-blue-dark);
  background: var(--udi-yellow);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(255,204,41,0.3);
}

.sidebar-link.active i {
  color: var(--udi-blue-dark);
}

.sidebar-link i {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 0.8rem 1rem;
}

.sidebar-section {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0.2rem 1.6rem;
  list-style: none;
}

.wa-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  margin-left: auto;
  flex-shrink: 0;
}

.wa-status-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 0.8rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
}

.user-avatar {
  font-size: 1.8rem;
  color: var(--udi-yellow);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-actions {
  display: flex;
  gap: 0.3rem;
}

.user-actions a {
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  padding: 0.3rem;
  border-radius: 6px;
  transition: var(--transition);
}

.user-actions a:hover {
  color: var(--udi-yellow);
  background: rgba(255,255,255,0.1);
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 1.5rem 2rem;
  min-height: calc(100vh - var(--topbar-height));
  transition: var(--transition);
}

/* ===== Mobile Toggle ===== */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 300;
  background: var(--udi-blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--card-shadow);
}

/* ===== Cards ===== */
.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  transition: var(--transition);
  background: #fff;
}

.card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem 1.25rem;
  font-weight: 600;
}

/* ===== Stat Cards ===== */
.stat-card {
  padding: 1.5rem;
  border-radius: var(--card-radius);
  background: #fff;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(37,58,123,0.1); color: var(--udi-blue); }
.stat-icon.yellow { background: rgba(255,204,41,0.15); color: var(--udi-yellow-dark); }
.stat-icon.green { background: rgba(34,197,94,0.1); color: #16a34a; }
.stat-icon.red { background: rgba(239,68,68,0.1); color: #dc2626; }
.stat-icon.purple { background: rgba(147,51,234,0.1); color: #9333ea; }
.stat-icon.cyan { background: rgba(6,182,212,0.1); color: #0891b2; }

.stat-info h3 {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0;
  line-height: 1;
}

.stat-info p {
  font-size: 0.82rem;
  color: #6b7280;
  margin: 0.2rem 0 0;
  font-weight: 500;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--udi-blue-dark);
  margin: 0;
}

.page-header h2 i {
  margin-right: 0.5rem;
  color: var(--udi-yellow-dark);
}

/* ===== Buttons ===== */
.btn-udi {
  background: var(--udi-blue);
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-udi:hover {
  background: var(--udi-blue-light);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,58,123,0.3);
}

.btn-yellow {
  background: var(--udi-yellow);
  color: var(--udi-blue-dark);
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-yellow:hover {
  background: var(--udi-yellow-dark);
  color: var(--udi-blue-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255,204,41,0.3);
}

/* ===== Tables ===== */
.table-container {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.table-container .table {
  margin: 0;
}

.table thead th {
  background: var(--udi-blue);
  color: #fff;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0.8rem 1rem;
  border: none;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.7rem 1rem;
  vertical-align: middle;
  font-size: 0.88rem;
  border-color: #f0f0f0;
}

.table tbody tr:hover {
  background: rgba(37,58,123,0.03);
}

/* ===== Filters Bar ===== */
.filters-bar {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.filters-bar .form-control,
.filters-bar .form-select {
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
}

.filters-bar .form-control:focus,
.filters-bar .form-select:focus {
  border-color: var(--udi-blue);
  box-shadow: 0 0 0 3px rgba(37,58,123,0.1);
}

/* ===== Badges ===== */
.badge-status {
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ratificado { background: rgba(34,197,94,0.1); color: #16a34a; }
.badge-nuevo { background: rgba(59,130,246,0.1); color: #2563eb; }
.badge-renuncia { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-clave { background: rgba(147,51,234,0.1); color: #9333ea; }

/* ===== Search Input ===== */
.search-box {
  position: relative;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

.search-box input {
  padding-left: 38px !important;
}

/* ===== Forms ===== */
.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #374151;
  margin-bottom: 0.3rem;
}

/* ===== Pagination ===== */
.pagination .page-link {
  border: none;
  color: var(--udi-blue);
  font-weight: 500;
  border-radius: 8px;
  margin: 0 2px;
}

.pagination .page-item.active .page-link {
  background: var(--udi-blue);
  color: #fff;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--udi-blue-dark), var(--udi-blue), #3451a0);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: var(--udi-yellow);
  border-radius: 50%;
  opacity: 0.05;
  top: -200px;
  right: -200px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: var(--udi-yellow);
  border-radius: 50%;
  opacity: 0.03;
  bottom: -100px;
  left: -100px;
}

.login-card {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}

.login-card .logo-container {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-card .logo-container img {
  width: 90px;
  margin-bottom: 1rem;
}

.login-card .logo-container h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--udi-blue-dark);
}

.login-card .logo-container p {
  color: #6b7280;
  font-size: 0.9rem;
}

.login-card .form-control {
  border-radius: 10px;
  padding: 0.7rem 1rem;
  border: 2px solid #e5e7eb;
  font-size: 0.9rem;
  transition: var(--transition);
}

.login-card .form-control:focus {
  border-color: var(--udi-blue);
  box-shadow: 0 0 0 4px rgba(37,58,123,0.1);
}

.login-card .btn-login {
  width: 100%;
  padding: 0.75rem;
  border-radius: 10px;
  background: var(--udi-blue);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  transition: var(--transition);
}

.login-card .btn-login:hover {
  background: var(--udi-blue-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37,58,123,0.3);
}

/* ===== Quick Links Grid ===== */
.quick-link {
  background: #fff;
  border-radius: var(--card-radius);
  padding: 1.5rem;
  text-align: center;
  text-decoration: none;
  color: #1a1a2e;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
  display: block;
}

.quick-link:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  color: var(--udi-blue);
}

.quick-link i {
  font-size: 2rem;
  color: var(--udi-blue);
  margin-bottom: 0.8rem;
  display: block;
}

.quick-link span {
  font-weight: 600;
  font-size: 0.9rem;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .sidebar {
    left: calc(var(--sidebar-width) * -1);
  }
  .sidebar.show {
    left: 0;
  }
  .topbar {
    left: 0;
  }
  .main-content {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .topbar-content {
    padding: 0 1rem;
  }
  .topbar-info h1 {
    font-size: 1.1rem;
  }
  .topbar-logo {
    width: 50px;
    height: 50px;
  }
  .main-content {
    padding: 1rem;
  }
  .stat-card {
    padding: 1rem;
  }
  .stat-info h3 {
    font-size: 1.4rem;
  }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeInUp 0.4s ease-out;
}

/* ===== Scrollbar ===== */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}

/* ===== Profile card ===== */
.profile-card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.profile-card .profile-header {
  background: linear-gradient(135deg, var(--udi-blue), var(--udi-blue-light));
  padding: 2rem;
  text-align: center;
  color: #fff;
}

.profile-card .profile-header .avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--udi-yellow);
  color: var(--udi-blue-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 auto 1rem;
  border: 3px solid rgba(255,255,255,0.3);
}

.profile-card .profile-body {
  padding: 1.5rem;
}

.profile-card .info-row {
  display: flex;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.profile-card .info-row:last-child {
  border-bottom: none;
}

.profile-card .info-label {
  font-weight: 600;
  color: #6b7280;
  width: 140px;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.profile-card .info-value {
  color: #1a1a2e;
  font-size: 0.9rem;
}

/* ===== Modal ===== */
.modal-content {
  border-radius: 16px;
  border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
  background: var(--udi-blue);
  color: #fff;
  border-radius: 16px 16px 0 0;
  padding: 1rem 1.5rem;
}

.modal-header .btn-close {
  filter: invert(1);
}

/* ===== Toast ===== */
.toast-custom {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  animation: slideInRight 0.3s ease-out;
  min-width: 300px;
}

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

/* ===== Compose Page ===== */
.compose-container {
  max-width: 900px;
}

.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(37,58,123,0.08);
  color: var(--udi-blue);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  margin: 0.2rem;
}

.recipient-chip .remove {
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.6;
}

.recipient-chip .remove:hover {
  opacity: 1;
}

/* ===== Chart placeholder ===== */
.chart-container {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
}
