/**
 * DASHBOARD PORTAL CORPORATIVO
 * Ruta: /wp-content/themes/clean/portal/dashboard/dashboard.css
 * Convención de clases: prefijo .pd-
 * Raíz del módulo: <div id="portal-dashboard" class="pd">
 */

/* =========================================================
   1. VARIABLES & BASE
   ========================================================= */

#portal-dashboard {
    /* Paleta corporativa */
    --pd-blue-dark: #003666;
    --pd-blue: #025993;
    --pd-blue-light: #0082cf;
    --pd-blue-soft: #e0f2fe;

    --pd-bg: #f5f7fb;
    --pd-card: #ffffff;

    --pd-gray-dark: #0f172a;
    --pd-gray: #6b7280;
    --pd-gray-light: #e5e7eb;

    --pd-accent: #40e9e5;
    --pd-danger: #fd5459;

    --pd-radius-lg: 18px;
    --pd-radius-pill: 999px;

    --pd-shadow-soft: 0 15px 30px rgba(15, 23, 42, 0.08);
    --pd-shadow-topbar: 0 1px 0 rgba(15, 23, 42, 0.06);

    font-family: "Raleway", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--pd-gray-dark);
}

/* Contenedor principal */
#portal-dashboard.pd {
    display: flex;
    min-height: 100vh;
    background: var(--pd-bg);
}

/* Helpers genéricos */
#portal-dashboard .pd-empty {
    padding: 18px;
    background: #fef3c7;
    border-radius: 14px;
    font-size: 0.85rem;
}

/* =========================================================
   2. SIDEBAR
   ========================================================= */

#portal-dashboard .pd-sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--pd-blue-dark), var(--pd-blue));
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
}

#portal-dashboard .pd-sidebar-header {
    margin-bottom: 24px;
}

#portal-dashboard .pd-brand {
    display: flex;
    align-items: center;
    justify-content: center;
}

#portal-dashboard .pd-brand-logo-img {
    max-width: 160px;
    height: auto;
    display: block;
}

#portal-dashboard .pd-brand-fallback {
    font-weight: 700;
    font-size: 1rem;
}

/* Menú lateral */
#portal-dashboard .pd-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: auto;
}

#portal-dashboard .pd-menu-item {
    border: none;
    background: transparent;
    color: #dbeafe;
    border-radius: var(--pd-radius-pill);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
}

#portal-dashboard .pd-menu-item i {
    width: 18px;
}

#portal-dashboard .pd-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

#portal-dashboard .pd-menu-item.is-active {
    background: #ffffff;
    color: var(--pd-blue-dark);
}

#portal-dashboard .pd-sidebar-footer {
    margin-top: 24px;
    font-size: 0.75rem;
    opacity: 0.8;
}

/* =========================================================
   3. MAIN & TOPBAR
   ========================================================= */

#portal-dashboard .pd-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Barra superior */
#portal-dashboard .pd-topbar {
    display: flex;
    align-items: center;
    padding: 18px 24px;
    background: #ffffff;
    box-shadow: var(--pd-shadow-topbar);
}

/* Lado izquierdo: organización */
#portal-dashboard .pd-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#portal-dashboard .pd-org {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#portal-dashboard .pd-org label {
    font-size: 0.7rem;
    color: var(--pd-gray);
}

#portal-dashboard .pd-org select {
    border-radius: var(--pd-radius-pill);
    border: 1px solid var(--pd-gray-light);
    padding: 6px 10px;
    font-size: 0.8rem;
    background: #ffffff;
}

/* Lado derecho: buscador + avatar */
#portal-dashboard .pd-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

/* =========================================================
   4. BUSCADOR
   ========================================================= */

/* Contenedor del buscador */
#portal-dashboard .pd-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f9fafb;
    border-radius: var(--pd-radius-pill);
    border: 1px solid var(--pd-gray-light);
    padding: 0 14px;
    height: 40px;
    margin: 0;
}

/* Variante estática (topbar) */
#portal-dashboard .pd-search-static {
    max-width: 360px;
    width: 320px;
}

/* Icono de lupa */
#portal-dashboard .pd-search-icon {
    color: var(--pd-gray);
    flex-shrink: 0;
}

/* Input de búsqueda */
#portal-dashboard .pd-search input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
}

/* =========================================================
   5. ICONOS SUPERIORES & NOTIFICACIONES
   ========================================================= */

#portal-dashboard .pd-top-icon {
    border: none;
    background: transparent;
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: var(--pd-radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#portal-dashboard .pd-top-icon i {
    color: var(--pd-gray-dark);
}

#portal-dashboard .pd-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    background: var(--pd-danger);
    color: #ffffff;
    border-radius: var(--pd-radius-pill);
    font-size: 0.65rem;
    padding: 2px 5px;
}

/* =========================================================
   6. PERFIL DE USUARIO (AVATAR + MENÚ)
   ========================================================= */

#portal-dashboard .pd-user {
    position: relative;
    display: flex;
    align-items: center;
}

#portal-dashboard .pd-user-trigger {
    border: none;
    background: #f9fafb;
    border-radius: var(--pd-radius-pill);
    padding: 3px 10px 3px 3px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    height: 40px;
}

#portal-dashboard .pd-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--pd-radius-pill);
    object-fit: cover;
}

#portal-dashboard .pd-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#portal-dashboard .pd-user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

#portal-dashboard .pd-user-role {
    font-size: 0.75rem;
    color: var(--pd-gray);
}

/* Menú del avatar alineado a la izquierda del botón */
#portal-dashboard .pd-user-menu {
    position: absolute;
    left: 0;
    top: 110%;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: var(--pd-shadow-soft);
    padding: 4px;
    min-width: 190px;
    display: none;
    flex-direction: column;
    z-index: 20;
}

#portal-dashboard .pd-user-menu.is-open {
    display: flex;
}

#portal-dashboard .pd-user-menu-item {
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    text-decoration: none;
    color: var(--pd-gray-dark);
    cursor: pointer;
}

#portal-dashboard .pd-user-menu-item:hover {
    background: #f3f4f6;
}

#portal-dashboard .pd-user-logout {
    color: var(--pd-danger);
}

/* =========================================================
   7. CONTENIDO PRINCIPAL
   ========================================================= */

#portal-dashboard .pd-content {
    flex: 1;
    padding: 18px 24px 24px;
    background: var(--pd-bg);
}

#portal-dashboard .pd-welcome h1 {
    margin: 0 0 4px;
    font-size: 1.6rem;
    color: var(--pd-blue-dark);
}

#portal-dashboard .pd-welcome p {
    margin: 0 0 14px;
    color: var(--pd-gray);
}

#portal-dashboard .pd-main-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* =========================================================
   8. TARJETAS DE ESTADÍSTICAS & WIDGETS
   ========================================================= */

#portal-dashboard .pd-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

#portal-dashboard .pd-stat-card {
    background: var(--pd-card);
    border-radius: var(--pd-radius-lg);
    padding: 16px;
    box-shadow: var(--pd-shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#portal-dashboard .pd-stat-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

#portal-dashboard .pd-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: var(--pd-blue-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pd-blue-dark);
}

#portal-dashboard .pd-stat-label {
    font-size: 0.85rem;
    color: var(--pd-gray);
}

#portal-dashboard .pd-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--pd-blue-dark);
}

#portal-dashboard .pd-stat-caption {
    font-size: 0.78rem;
    color: var(--pd-gray);
}

/* Grid de widgets */
#portal-dashboard .pd-widgets-grid {
    display: grid;
    grid-template-columns: 2fr 1.4fr;
    gap: 16px;
}

#portal-dashboard .pd-widget {
    background: var(--pd-card);
    border-radius: var(--pd-radius-lg);
    padding: 16px;
    box-shadow: var(--pd-shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#portal-dashboard .pd-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#portal-dashboard .pd-widget-header h2 {
    margin: 0;
    font-size: 0.95rem;
}

/* Actividad reciente */
#portal-dashboard .pd-activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#portal-dashboard .pd-activity-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
}

#portal-dashboard .pd-activity-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--pd-radius-pill);
    background: var(--pd-blue-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pd-blue-dark);
    flex-shrink: 0;
}

#portal-dashboard .pd-activity-body {
    flex: 1;
}

#portal-dashboard .pd-activity-text {
    margin: 0 0 2px;
    font-size: 0.86rem;
}

#portal-dashboard .pd-activity-meta {
    font-size: 0.75rem;
    color: var(--pd-gray);
}

/* Calendario de reuniones */
#portal-dashboard .pd-calendar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#portal-dashboard .pd-calendar-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
}

#portal-dashboard .pd-calendar-date {
    min-width: 64px;
    border-radius: 12px;
    background: #eff6ff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
}

#portal-dashboard .pd-calendar-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#portal-dashboard .pd-calendar-title {
    font-size: 0.86rem;
    font-weight: 600;
}

#portal-dashboard .pd-calendar-time {
    font-size: 0.78rem;
    color: var(--pd-gray);
}

/* =========================================================
   9. BOTONES, MODALES & TOAST
   ========================================================= */

#portal-dashboard .pd-btn-primary,
#portal-dashboard .pd-btn-secondary {
    border-radius: var(--pd-radius-pill);
    border: none;
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
}

#portal-dashboard .pd-btn-primary {
    background: linear-gradient(90deg, var(--pd-blue), var(--pd-blue-dark));
    color: #ffffff;
}

#portal-dashboard .pd-btn-secondary {
    background: #f3f4f6;
    color: var(--pd-gray-dark);
}

/* Modales */
#portal-dashboard .pd-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

#portal-dashboard .pd-modal.is-open {
    display: flex;
}

#portal-dashboard .pd-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
}

#portal-dashboard .pd-modal-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 20px;
    padding: 16px 18px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
    max-width: 420px;
    width: 100%;
    z-index: 51;
}

#portal-dashboard .pd-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#portal-dashboard .pd-modal-header h2 {
    margin: 0;
}

#portal-dashboard .pd-modal-body {
    margin-top: 10px;
    font-size: 0.9rem;
}

#portal-dashboard .pd-modal-footer {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#portal-dashboard .pd-modal-close {
    border: none;
    background: transparent;
    cursor: pointer;
}

/* Toast */
#portal-dashboard .pd-toast {
    position: fixed;
    bottom: 18px;
    right: 18px;
    background: #111827;
    color: #ffffff;
    border-radius: var(--pd-radius-pill);
    padding: 10px 16px;
    font-size: 0.82rem;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 60;
}

#portal-dashboard .pd-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================================
   10. RESPONSIVE
   ========================================================= */

@media (max-width: 1024px) {
    #portal-dashboard .pd-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #portal-dashboard .pd-widgets-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #portal-dashboard.pd {
        flex-direction: column;
    }

    #portal-dashboard .pd-sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    #portal-dashboard .pd-menu {
        flex-direction: row;
        overflow-x: auto;
    }

    #portal-dashboard .pd-topbar {
        flex-wrap: wrap;
    }

    #portal-dashboard .pd-user-info {
        display: none;
    }

    #portal-dashboard .pd-search-static {
        width: 100%;
        max-width: none;
    }
}
