/* ==========================================================================
   TKD PRO MANAGER - LAYOUT CON SIDEBAR VERTICAL CLARO / COLLAPSIBLE Y TOPBAR
   ========================================================================== */

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 64px;
  --sidebar-bg: #FFFFFF;
  --sidebar-border: #E2E8F0;
  --sidebar-text: #475569;
  --sidebar-active-bg: #EFF6FF;
  --sidebar-active-text: #1D4ED8;
}

body {
  margin: 0;
  padding: 0;
  background-color: #F8FAFC;
  font-family: 'Outfit', sans-serif;
  color: #0F172A;
  overflow-x: hidden;
}

/* Layout Wrapper General */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* --------------------------------------------------------------------------
   1. SIDEBAR LATERAL IZQUIERDO (TEMA CLARO / ITF)
   -------------------------------------------------------------------------- */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1200;
  box-shadow: 2px 0 12px rgba(15, 23, 42, 0.03);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
}

.sidebar-header {
  padding: 1rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 84px;
  box-sizing: border-box;
  gap: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-logo {
  width: 100%;
  max-width: 185px;
  height: auto;
  max-height: 64px;
  object-fit: contain;
  transition: all 0.2s ease;
}

.sidebar-collapse-btn {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  color: #475569;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background-color: #2563EB;
  color: #FFFFFF;
  border-color: #2563EB;
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: #64748B;
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}

/* Navegación del Sidebar */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Etiquetas de Categoría (ACADEMIA, ADMINISTRACIÓN) */
.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: #94A3B8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1rem 0.75rem 0.35rem 0.75rem;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

/* Enlaces del Sidebar */
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.45rem 0.85rem;
  color: #475569;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.sidebar-nav-link:hover:not(.disabled) {
  color: #1D4ED8;
  background-color: #F0F6FF;
}

.sidebar-nav-link.active {
  color: #1D4ED8;
  background-color: var(--sidebar-active-bg);
  font-weight: 700;
  border-left: 3.5px solid #1D4ED8;
}

.sidebar-nav-link.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-icon-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  flex-shrink: 0;
}

.nav-icon-emoji {
  font-size: 1.2rem;
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.nav-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  background-color: #E2E8F0;
  color: #64748B;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Pie del Sidebar */
.sidebar-footer {
  padding: 0.85rem 0.65rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FCA5A5;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sidebar-logout-btn:hover {
  background-color: #EF4444;
  color: #FFFFFF;
}

/* --------------------------------------------------------------------------
   ESTADO CONTRAÍDO (SIDEBAR COLLAPSED)
   -------------------------------------------------------------------------- */
.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .sidebar-logo {
  height: 32px;
  width: 32px;
  object-fit: cover;
  object-position: left;
}

.app-sidebar.collapsed .sidebar-nav-link {
  justify-content: center;
  padding: 0.75rem 0;
  gap: 0;
}

.app-sidebar.collapsed .nav-text,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .nav-badge {
  display: none !important;
}

.app-sidebar.collapsed .sidebar-logout-btn {
  justify-content: center;
  padding: 0.75rem 0;
}

.app-sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 1rem 0.5rem;
}

.app-sidebar.collapsed .sidebar-brand {
  display: none;
}

/* --------------------------------------------------------------------------
   2. MAIN WRAPPER Y TOPBAR HEADER
   -------------------------------------------------------------------------- */
.app-main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-main-wrapper.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
}

.app-container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem;
  box-sizing: border-box;
}

.app-topbar {
  height: var(--topbar-height);
  background-color: #FFFFFF;
  border-bottom: 1px solid #E2E8F0;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.topbar-toggle-btn {
  display: none;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  color: #0F172A;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.topbar-module-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-module-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.module-page-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0F172A;
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Indicador de Estado BD */
.db-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: #F0FDF4;
  border: 1px solid #BBF7D0;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #166534;
}

.db-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22C55E;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Badge de Usuario Logueado */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #F8FAFC;
  border: 1px solid #E2E8F0;
  padding: 0.3rem 0.75rem 0.3rem 0.5rem;
  border-radius: 20px;
}

.user-avatar-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #DBEAFE;
  color: #1D4ED8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.user-profile-info {
  display: flex;
  flex-direction: column;
}

.user-profile-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0F172A;
  line-height: 1.1;
}

.user-profile-role {
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748B;
}

/* Overlay Backdrop en Mobile */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   3. RESPONSIVE DESIGN (TABLET & MOBILE <= 992px)
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 250px !important;
  }

  .app-sidebar.active {
    transform: translateX(0);
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .sidebar-close-btn {
    display: block;
  }

  .app-main-wrapper {
    margin-left: 0 !important;
  }

  .topbar-toggle-btn {
    display: flex;
  }

  .app-topbar {
    padding: 0 1rem;
  }

  .module-page-title {
    font-size: 1.05rem;
  }

  .db-status-text {
    display: none;
  }

  .db-status-badge {
    padding: 0.4rem;
    border-radius: 50%;
  }

  .user-profile-role {
    display: none;
  }
}