<!-- components/AdminAcademia/layout/AdminLayout.vue -->
<template>
  <a-layout style="min-height: 100vh;" class="admin-layout">
    <!-- Header estilo ChatGPT -->
    <a-layout-header class="header">
      <div class="header-container">
        <div class="header-left">
          <div class="brand-section">
            <a-button
              v-if="isMobile"
              type="text"
              class="menu-toggle"
              @click="toggleDrawer"
            >
              <MenuOutlined />
            </a-button>
            
            <div class="logo-wrapper">
              <div class="logo-icon">
                <BankOutlined />
              </div>
              <div class="logo-content">
                <h1 class="admin-name">Dirección de Admisión</h1>
                <div class="admin-role">Panel Administrativo</div>
              </div>
            </div>
          </div>
        </div>
        
        <!-- Desktop Actions -->
        <div class="header-right" v-if="!isMobile">
          <div class="header-actions">
            
            <!-- Notificaciones -->
            <a-dropdown :trigger="['click']" placement="bottomRight">
              <a-badge :count="notificacionesCount" dot>
                <div class="action-btn">
                  <BellOutlined />
                </div>
              </a-badge>
              <template #overlay>
                <div class="notification-dropdown">
                  <div class="notification-header">
                    <h3>Notificaciones</h3>
                    <a-button type="link" size="small" @click="verNotificaciones">
                      Ver todas
                    </a-button>
                  </div>
                  <div class="notification-list">
                    <div v-for="notif in notificaciones" :key="notif.id" 
                         class="notification-item" @click="handleNotification(notif)">
                      <div class="notification-icon" :style="{ color: notif.color }">
                        <component :is="notif.icon" />
                      </div>
                      <div class="notification-content">
                        <div class="notification-title">{{ notif.titulo }}</div>
                        <div class="notification-time">{{ formatTimeAgo(notif.fecha) }}</div>
                      </div>
                    </div>
                  </div>
                </div>
              </template>
            </a-dropdown>
            
            <!-- Profile -->
            <a-dropdown :trigger="['click']" placement="bottomRight">
              <div class="profile-btn">
                <a-avatar :size="36" class="profile-avatar">
                  {{ userStore.user?.name?.charAt(0)?.toUpperCase() || 'A' }}
                </a-avatar>
                <span class="profile-name">{{ userStore.user?.name }}</span>
                <DownOutlined class="dropdown-arrow" />
              </div>
              <template #overlay>
                <a-menu class="profile-menu">
                  <a-menu-item @click="irPerfil">
                    <UserOutlined />
                    <span>Mi Perfil</span>
                  </a-menu-item>
                  <a-menu-divider />
                  <a-menu-item class="logout-item" @click="logout">
                    <LogoutOutlined />
                    <span>Cerrar Sesión</span>
                  </a-menu-item>
                </a-menu>
              </template>
            </a-dropdown>
          </div>
        </div>
        
        <!-- Mobile Actions -->
        <div class="mobile-actions" v-else>
          <a-dropdown :trigger="['click']" placement="bottomRight">
            <div class="mobile-notification">
              <a-badge :count="notificacionesCount" dot>
                <BellOutlined />
              </a-badge>
            </div>
            <template #overlay>
              <div class="mobile-notification-dropdown">
                <div class="notification-header">
                  <h3>Notificaciones</h3>
                </div>
                <div class="notification-list">
                  <div v-for="notif in notificaciones" :key="notif.id" 
                       class="notification-item">
                    <div class="notification-icon" :style="{ color: notif.color }">
                      <component :is="notif.icon" />
                    </div>
                    <div class="notification-content">
                      <div class="notification-title">{{ notif.titulo }}</div>
                      <div class="notification-time">{{ formatTimeAgo(notif.fecha) }}</div>
                    </div>
                  </div>
                </div>
              </div>
            </template>
          </a-dropdown>
          
          <a-dropdown :trigger="['click']" placement="bottomRight">
            <a-avatar :size="32" class="mobile-avatar">
              {{ userStore.user?.name?.charAt(0)?.toUpperCase() || 'A' }}
            </a-avatar>
            <template #overlay>
              <a-menu class="mobile-profile-menu">
                <a-menu-item @click="irPerfil">
                  <UserOutlined />
                  <span>Mi Perfil</span>
                </a-menu-item>
                <a-menu-divider />
                <a-menu-item class="logout-item" @click="logout">
                  <LogoutOutlined />
                  <span>Cerrar Sesión</span>
                </a-menu-item>
              </a-menu>
            </template>
          </a-dropdown>
        </div>
      </div>
    </a-layout-header>

    <!-- Layout Principal -->
    <a-layout class="main-layout">
      <!-- Sidebar Desktop - Estilo ChatGPT Oscuro -->
      <a-layout-sider
        v-if="!isMobile"
        :width="280"
        theme="dark"
        collapsible
        v-model:collapsed="sidebarCollapsed"
        :trigger="null"
        class="sidebar"
        :class="{ 'sidebar-collapsed': sidebarCollapsed }"
      >
        <div class="sidebar-header">
          <div class="sidebar-brand" v-if="!sidebarCollapsed">
            <div class="brand-icon">
              <BankOutlined />
            </div>
            <div class="brand-text">
              <h3>Admisión</h3>
              <p>Sistema Académico</p>
            </div>
          </div>
          <div class="sidebar-collapse-btn" v-else>
            <BankOutlined />
          </div>
        </div>
        
        <div class="sidebar-menu-container">
          <a-menu
            v-model:selectedKeys="selectedKeys"
            mode="inline"
            theme="dark"
            class="sidebar-menu"
            @select="handleMenuSelect"
          >
            <!-- Dashboard -->
            <a-menu-item key="dashboard" class="menu-item">
              <template #icon>
                <DashboardOutlined />
              </template>
              <span>Dashboard</span>
            </a-menu-item>
            
            <!-- Gestión -->
            <div class="menu-divider" v-if="!sidebarCollapsed">
              <span>Gestión</span>
            </div>
            
            <a-sub-menu key="estudiantes" class="sub-menu">
              <template #icon>
                <TeamOutlined />
              </template>
              <template #title>Estudiantes</template>
              <a-menu-item key="estudiantes-lista">Lista de Estudiantes</a-menu-item>
            </a-sub-menu>
            
            <a-sub-menu key="examenes" class="sub-menu">
              <template #icon>
                <FileTextOutlined />
              </template>
              <template #title>Exámenes</template>
              <a-menu-item key="examenes-lista">Todos los Exámenes</a-menu-item>
              <a-menu-item key="examenes-nuevo">Crear Examen</a-menu-item>
            </a-sub-menu>
            
            <a-sub-menu key="preguntas" class="sub-menu">
              <template #icon>
                <QuestionCircleOutlined />
              </template>
              <template #title>Gestión Preguntas</template>
              <a-menu-item key="lista-areas">Áreas</a-menu-item>
              <a-menu-item key="lista-cursos">Cursos</a-menu-item>
            </a-sub-menu>
            
            <!-- Análisis -->
            <div class="menu-divider" v-if="!sidebarCollapsed">
              <span>Análisis</span>
            </div>
            
            <a-menu-item key="resultados" class="menu-item">
              <template #icon>
                <RiseOutlined />
              </template>
              <span>Resultados</span>
            </a-menu-item>
            
            <a-menu-item key="reportes" class="menu-item">
              <template #icon>
                <BarChartOutlined />
              </template>
              <span>Reportes</span>
            </a-menu-item>
            
            <!-- Configuración -->
            <div class="menu-divider" v-if="!sidebarCollapsed">
              <span>Configuración</span>
            </div>
            
            <a-menu-item key="config-academia" class="menu-item">
              <template #icon>
                <SettingOutlined />
              </template>
              <span>Academia</span>
            </a-menu-item>
          </a-menu>
        </div>
        
        <!-- Collapse Button -->
        <div class="sidebar-footer">
          <a-button 
            type="text" 
            class="collapse-btn"
            @click="sidebarCollapsed = !sidebarCollapsed"
          >
            <template #icon>
              <MenuUnfoldOutlined v-if="sidebarCollapsed" />
              <MenuFoldOutlined v-else />
            </template>
            <span v-if="!sidebarCollapsed">Colapsar Menú</span>
          </a-button>
        </div>
      </a-layout-sider>

      <!-- Drawer Mobile -->
      <a-drawer
        v-model:open="drawerVisible"
        title=""
        placement="left"
        width="280"
        :body-style="{ padding: 0, backgroundColor: '#202123' }"
        class="mobile-drawer"
        :headerStyle="{ display: 'none' }"
      >
        <div class="mobile-sidebar">
          <div class="mobile-sidebar-header">
            <div class="mobile-brand">
              <BankOutlined />
              <h3>Admisión</h3>
            </div>
          </div>
          
          <a-menu
            v-model:selectedKeys="selectedKeys"
            mode="inline"
            theme="dark"
            class="mobile-sidebar-menu"
            @select="handleMobileMenuSelect"
          >
            <a-menu-item key="dashboard">
              <DashboardOutlined />
              <span>Dashboard</span>
            </a-menu-item>
            
            <a-sub-menu key="estudiantes">
              <template #icon>
                <TeamOutlined />
              </template>
              <template #title>Estudiantes</template>
              <a-menu-item key="estudiantes-lista">Lista</a-menu-item>
            </a-sub-menu>
            
            <a-sub-menu key="examenes">
              <template #icon>
                <FileTextOutlined />
              </template>
              <template #title>Exámenes</template>
              <a-menu-item key="examenes-lista">Todos</a-menu-item>
              <a-menu-item key="examenes-nuevo">Crear</a-menu-item>
            </a-sub-menu>
            
            <a-sub-menu key="preguntas">
              <template #icon>
                <QuestionCircleOutlined />
              </template>
              <template #title>Preguntas</template>
              <a-menu-item key="lista-areas">Áreas</a-menu-item>
              <a-menu-item key="lista-cursos">Cursos</a-menu-item>
            </a-sub-menu>
            
            <a-menu-item key="resultados">
              <RiseOutlined />
              <span>Resultados</span>
            </a-menu-item>
            
            <a-menu-item key="reportes">
              <BarChartOutlined />
              <span>Reportes</span>
            </a-menu-item>
            
            <a-menu-item key="config-academia">
              <SettingOutlined />
              <span>Academia</span>
            </a-menu-item>
          </a-menu>
        </div>
      </a-drawer>

      <!-- Content Area -->
      <a-layout-content class="content">
        <div class="content-container">
          <router-view />
        </div>
      </a-layout-content>
    </a-layout>
  </a-layout>
</template>

<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '../../store/user'
import {
  BankOutlined,
  BellOutlined,
  DownOutlined,
  UserOutlined,
  SettingOutlined,
  LogoutOutlined,
  DashboardOutlined,
  TeamOutlined,
  FileTextOutlined,
  RiseOutlined,
  BarChartOutlined,
  MenuOutlined,
  MenuFoldOutlined,
  MenuUnfoldOutlined,
  QuestionCircleOutlined,
  PlusOutlined,
  UnorderedListOutlined,
} from '@ant-design/icons-vue'

const router = useRouter()
const userStore = useUserStore()

// Estado interno
const selectedKeys = ref(['/administrador/dashboard'])
const drawerVisible = ref(false)
const sidebarCollapsed = ref(false)
const isMobile = ref(false)

// Notificaciones
const notificacionesCount = ref(3)
const notificaciones = ref([
  { id: 1, titulo: 'Nuevo estudiante registrado', fecha: new Date(Date.now() - 5 * 60000), icon: 'TeamOutlined', color: '#10b981' },
  { id: 2, titulo: 'Examen próximo a vencer', fecha: new Date(Date.now() - 30 * 60000), icon: 'FileTextOutlined', color: '#f59e0b' },
  { id: 3, titulo: 'Capacidad al 80%', fecha: new Date(Date.now() - 2 * 3600000), icon: 'BarChartOutlined', color: '#6366f1' }
])

const toggleDrawer = () => {
  drawerVisible.value = !drawerVisible.value
}

const checkMobile = () => {
  isMobile.value = window.innerWidth < 992
  if (!isMobile.value) {
    drawerVisible.value = false
  }
}

const handleMenuSelect = ({ key }) => {
  selectedKeys.value = [key]

  switch (key) {
    case 'dashboard':
      router.push({ name: 'AcademiaDashboard' })
      break
    case 'estudiantes-lista':
      router.push({ name: 'AcademiaEstudiantes' })
      break
    case 'examenes-lista':
      router.push({ name: 'AcademiaExamenes' })
      break
    case 'examenes-nuevo':
      router.push({ name: 'AcademiaExamenNuevo' })
      break
    case 'reportes':
      router.push({ name: 'AcademiaReportes' })
      break
    case 'config-academia':
      router.push({ name: 'AcademiaConfig' })
      break
    case 'lista-areas':
      router.push({ name: 'AcademiAreaLista' })
      break
    case 'lista-cursos':
      router.push({ name: 'AcademiaCursosLista' })
      break
  }
}

const handleMobileMenuSelect = ({ key }) => {
  handleMenuSelect({ key })
  drawerVisible.value = false
}

const irPerfil = () => {
  router.push({ name: 'Perfil' })
}

const logout = () => {
  userStore.logout()
  router.push('/login')
}

const formatTimeAgo = (date) => {
  const now = new Date()
  const diffMs = now - new Date(date)
  const diffMins = Math.floor(diffMs / 60000)
  const diffHours = Math.floor(diffMs / 3600000)
  const diffDays = Math.floor(diffMs / 86400000)
  
  if (diffMins < 60) return `Hace ${diffMins} min`
  if (diffHours < 24) return `Hace ${diffHours} h`
  return `Hace ${diffDays} d`
}

// Lifecycle hooks
onMounted(() => {
  checkMobile()
  window.addEventListener('resize', checkMobile)
})

onUnmounted(() => {
  window.removeEventListener('resize', checkMobile)
})
</script>

<style scoped>
/* Variables de colores estilo ChatGPT */
:root {
  --sidebar-bg: #202123;
  --sidebar-hover: #343541;
  --sidebar-active: #40414f;
  --sidebar-text: #ececf1;
  --sidebar-text-secondary: #8e8ea0;
  --header-bg: #ffffff;
  --content-bg: #ffffff;
  --border-color: #e5e5e5;
  --primary-color: #10a37f;
  --notification-badge: #ef4444;
}

/* Layout General */
.admin-layout {
  background: var(--content-bg);
}

/* Header estilo ChatGPT */
.header {
  background: var(--header-bg);
  height: 64px;
  padding: 0;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.header-container {
  height: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: #374151;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.menu-toggle:hover {
  background: #f3f4f6;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #0d8a6d 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.logo-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.admin-role {
  font-size: 12px;
  color: #6b7280;
}

/* Header Actions */
.header-right {
  display: flex;
  align-items: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid #e5e7eb;
  color: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

:deep(.ant-badge-dot) {
  box-shadow: 0 0 0 2px var(--header-bg);
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.profile-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-weight: 600;
  color: white;
}

.profile-name {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

.dropdown-arrow {
  font-size: 12px;
  color: #9ca3af;
}

/* Mobile Actions */
.mobile-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-notification {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  cursor: pointer;
  transition: background 0.2s;
}

.mobile-notification:hover {
  background: #f3f4f6;
}

.mobile-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-weight: 600;
  color: white;
  cursor: pointer;
}

/* Sidebar estilo ChatGPT Oscuro */
.sidebar {
  background: var(--sidebar-bg) !important;
  box-shadow: 1px 0 2px rgba(0, 0, 0, 0.1);
  height: calc(100vh - 64px);
  position: fixed;
  left: 0;
  top: 64px;
  z-index: 99;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.sidebar-collapsed {
  width: 80px !important;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #0d8a6d 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.brand-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--sidebar-text);
  line-height: 1.2;
}

.brand-text p {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: var(--sidebar-text-secondary);
}

.sidebar-collapse-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #0d8a6d 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin: 0 auto;
}

.sidebar-menu-container {
  padding: 16px 0;
  overflow-y: auto;
  height: calc(100% - 180px);
}

.sidebar-menu-container::-webkit-scrollbar {
  width: 6px;
}

.sidebar-menu-container::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.sidebar-menu {
  background: transparent !important;
  border-right: none !important;
}

.sidebar-menu :deep(.ant-menu-item),
.sidebar-menu :deep(.ant-menu-submenu-title) {
  height: 44px;
  line-height: 44px;
  margin: 4px 12px !important;
  padding: 0 12px !important;
  border-radius: 6px;
  color: var(--sidebar-text);
  transition: all 0.2s;
}

.sidebar-menu :deep(.ant-menu-item:hover),
.sidebar-menu :deep(.ant-menu-submenu-title:hover) {
  background: var(--sidebar-hover) !important;
  color: var(--sidebar-text) !important;
}

.sidebar-menu :deep(.ant-menu-item-selected) {
  background: var(--sidebar-active) !important;
  color: var(--sidebar-text) !important;
}

.sidebar-menu :deep(.ant-menu-item .ant-menu-item-icon),
.sidebar-menu :deep(.ant-menu-submenu-title .ant-menu-item-icon) {
  font-size: 16px;
  color: var(--sidebar-text-secondary);
}

.sidebar-menu :deep(.ant-menu-item-selected .ant-menu-item-icon) {
  color: var(--sidebar-text) !important;
}

.menu-divider {
  padding: 8px 20px 4px;
  font-size: 11px;
  color: var(--sidebar-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  opacity: 0.7;
}

/* Submenu styles */
.sidebar-menu :deep(.ant-menu-submenu-arrow) {
  color: var(--sidebar-text-secondary) !important;
}

.sidebar-menu :deep(.ant-menu-submenu-open .ant-menu-submenu-title) {
  background: var(--sidebar-hover) !important;
}

.sidebar-menu :deep(.ant-menu-sub .ant-menu-item) {
  padding-left: 48px !important;
  margin: 2px 12px !important;
}

/* Sidebar Footer */
.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.collapse-btn {
  width: 100%;
  height: 40px;
  color: var(--sidebar-text-secondary) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  background: rgba(255, 255, 255, 0.05) !important;
}

.collapse-btn:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: var(--sidebar-text) !important;
}

.collapse-btn :deep(.ant-btn-icon) {
  font-size: 14px;
}

/* Main Layout */
.main-layout {
  margin-left: 280px;
  transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapsed + .main-layout {
  margin-left: 80px;
}

/* Content */
.content {
  background: var(--content-bg);
  min-height: calc(100vh - 64px);
  padding: 24px;
}

.content-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  min-height: calc(100vh - 112px);
  padding: 24px;
}

/* Mobile Drawer */
.mobile-drawer :deep(.ant-drawer-content) {
  background: var(--sidebar-bg);
}

.mobile-sidebar {
  height: 100%;
}

.mobile-sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--sidebar-text);
}

.mobile-brand h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.mobile-brand svg {
  font-size: 24px;
  color: var(--primary-color);
}

.mobile-sidebar-menu {
  background: transparent !important;
  border-right: none !important;
  padding: 16px 0;
}

.mobile-sidebar-menu :deep(.ant-menu-item),
.mobile-sidebar-menu :deep(.ant-menu-submenu-title) {
  color: var(--sidebar-text) !important;
  height: 48px;
  line-height: 48px;
  margin: 2px 12px !important;
  padding-left: 20px !important;
}

.mobile-sidebar-menu :deep(.ant-menu-item:hover),
.mobile-sidebar-menu :deep(.ant-menu-submenu-title:hover) {
  background: var(--sidebar-hover) !important;
}

.mobile-sidebar-menu :deep(.ant-menu-item-selected) {
  background: var(--sidebar-active) !important;
}

/* Dropdowns */
.notification-dropdown,
.mobile-notification-dropdown {
  width: 320px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.notification-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f9fafb;
}

.notification-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.notification-list {
  max-height: 400px;
  overflow-y: auto;
}

.notification-item {
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
}

.notification-item:hover {
  background: #f9fafb;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.05);
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-size: 14px;
  font-weight: 500;
  color: #111827;
  margin-bottom: 4px;
  line-height: 1.4;
}

.notification-time {
  font-size: 12px;
  color: #6b7280;
}

.profile-menu,
.mobile-profile-menu {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
}

.profile-menu :deep(.ant-menu-item),
.mobile-profile-menu :deep(.ant-menu-item) {
  height: 40px;
  line-height: 40px;
  margin: 0 !important;
  padding: 0 16px !important;
}

.profile-menu :deep(.ant-menu-item:hover),
.mobile-profile-menu :deep(.ant-menu-item:hover) {
  background: #f3f4f6 !important;
}

.logout-item {
  color: #ef4444 !important;
}

.logout-item:hover {
  background: #fef2f2 !important;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .sidebar {
    width: 240px !important;
  }
  
  .main-layout {
    margin-left: 240px;
  }
  
  .sidebar.sidebar-collapsed {
    width: 80px !important;
  }
  
  .sidebar-collapsed + .main-layout {
    margin-left: 80px;
  }
}

@media (max-width: 992px) {
  .sidebar {
    display: none !important;
  }
  
  .main-layout {
    margin-left: 0 !important;
  }
  
  .content {
    padding: 20px;
  }
  
  .header-container {
    padding: 0 20px;
  }
}

@media (max-width: 768px) {
  .header {
    height: 60px;
  }
  
  .header-container {
    padding: 0 16px;
  }
  
  .content {
    padding: 16px;
  }
  
  .content-container {
    padding: 20px;
  }
  
  .logo-content {
    display: none;
  }
  
  .admin-name {
    font-size: 14px;
  }
  
  .mobile-actions {
    gap: 12px;
  }
}

@media (max-width: 576px) {
  .header-container {
    padding: 0 12px;
  }
  
  .content {
    padding: 12px;
  }
  
  .content-container {
    padding: 16px;
    border-radius: 8px;
  }
  
  .notification-dropdown,
  .mobile-notification-dropdown {
    width: 280px;
  }
}

@media (max-width: 480px) {
  .brand-section {
    gap: 8px;
  }
  
  .menu-toggle {
    width: 36px;
    height: 36px;
  }
  
  .logo-icon {
    width: 36px;
    height: 36px;
  }
  
  .mobile-actions {
    gap: 8px;
  }
}

/* Animaciones */
.sidebar-menu :deep(.ant-menu-item),
.sidebar-menu :deep(.ant-menu-submenu-title) {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Mejoras de accesibilidad */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .main-layout,
  .sidebar-menu :deep(.ant-menu-item),
  .sidebar-menu :deep(.ant-menu-submenu-title) {
    transition: none !important;
    animation: none !important;
  }
}

/* Modo oscuro del sistema */
@media (prefers-color-scheme: dark) {
  :root {
    --header-bg: #1f2937;
    --content-bg: #111827;
    --border-color: #374151;
  }
  
  .header {
    background: var(--header-bg);
    border-bottom-color: var(--border-color);
  }
  
  .admin-name {
    color: #f9fafb;
  }
  
  .admin-role {
    color: #9ca3af;
  }
  
  .action-btn {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
  }
  
  .action-btn:hover {
    background: #4b5563;
    border-color: #6b7280;
  }
  
  .profile-btn {
    background: #374151;
    border-color: #4b5563;
  }
  
  .profile-btn:hover {
    background: #4b5563;
    border-color: #6b7280;
  }
  
  .profile-name {
    color: #d1d5db;
  }
  
  .content-container {
    background: #1f2937;
    color: #f9fafb;
  }
  
  .notification-dropdown,
  .mobile-notification-dropdown {
    background: #1f2937;
    border-color: #374151;
  }
  
  .notification-header {
    background: #111827;
    border-bottom-color: #374151;
  }
  
  .notification-header h3 {
    color: #f9fafb;
  }
  
  .notification-item:hover {
    background: #374151;
  }
  
  .notification-title {
    color: #f9fafb;
  }
  
  .notification-time {
    color: #9ca3af;
  }
  
  .profile-menu,
  .mobile-profile-menu {
    background: #1f2937;
    border-color: #374151;
  }
  
  .profile-menu :deep(.ant-menu-item:hover),
  .mobile-profile-menu :deep(.ant-menu-item:hover) {
    background: #374151 !important;
  }
}
</style>