/**
 * NICC Admin Menu - Modern Styles
 * Glassmorphism design with role-based permissions
 */

/* ============================================================
   VARIABLES
   ============================================================ */

.nicc-admin-container {
    /* Colores Base - Modo Claro */
    --bg-gradient-start: #f0f4f8;
    --bg-gradient-end: #e2e8f0;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-hover: rgba(255, 255, 255, 0.95);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: rgba(148, 163, 184, 0.2);
    --border-color-hover: rgba(148, 163, 184, 0.4);

    /* Acentos */
    --accent-system: #3b82f6;
    --accent-users: #8b5cf6;
    --accent-content: #10b981;
    --accent-tools: #f59e0b;
    --accent-modules: #ec4899;
    --accent-danger: #ef4444;

    /* Sombras */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-card-hover: 0 10px 20px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Tipografia */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 350ms ease;

    /* Espaciado */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;

    /* Bordes */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
}

/* Modo Oscuro */
.nicc-admin-container[data-theme="dark"] {
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.8);
    --bg-card-hover: rgba(30, 41, 59, 0.95);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --border-color: rgba(100, 116, 139, 0.2);
    --border-color-hover: rgba(100, 116, 139, 0.4);

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 10px 20px -5px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */

.nicc-admin-container {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HEADER
   ============================================================ */

.nicc-admin-header {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--text-primary);
}

.logo svg {
    width: 32px;
    height: 32px;
    color: var(--accent-modules);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-admin {
    color: var(--accent-modules);
    font-weight: 500;
}

/* Search Box */
.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 var(--space-xl);
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: var(--space-md);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    padding-left: 2.5rem;
    padding-right: 4rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-modules);
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-shortcut {
    position: absolute;
    right: var(--space-sm);
    padding: 2px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: var(--space-sm);
}

.user-role {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--accent-modules);
    color: white;
}

.user-role[data-role="admin"] {
    background: var(--accent-users);
}

.user-role[data-role="manager"] {
    background: var(--accent-tools);
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    transform: translateY(-1px);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

/* Theme toggle icons */
.nicc-admin-container[data-theme="light"] .icon-moon { display: none; }
.nicc-admin-container[data-theme="dark"] .icon-sun { display: none; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.nicc-admin-main {
    flex: 1;
    padding: var(--space-xl);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: all var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    border-radius: var(--radius-md);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================================
   MENU CATEGORIES
   ============================================================ */

.menu-categories {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.category {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all var(--transition-base);
}

.category:hover {
    border-color: var(--border-color-hover);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

.category-header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.nicc-admin-container[data-theme="dark"] .category-header:hover {
    background: rgba(255, 255, 255, 0.02);
}

.category-title {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.category-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--category-color) 15%, transparent);
}

.category-icon svg {
    width: 20px;
    height: 20px;
    color: var(--category-color);
}

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

.category-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: var(--space-sm);
}

.category-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.category-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    transition: transform var(--transition-base);
}

.category.collapsed .category-toggle svg {
    transform: rotate(-90deg);
}

.category-content {
    padding: 0 var(--space-lg) var(--space-lg);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-md);
    max-height: 2000px;
    overflow: hidden;
    transition: all var(--transition-base);
}

.category.collapsed .category-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* ============================================================
   MENU ITEMS (CARDS)
   ============================================================ */

.menu-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    position: relative;
    transition: all var(--transition-base);
    overflow: hidden;
}

.menu-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--item-color);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.menu-item:hover {
    border-color: var(--item-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
    text-decoration: none;
    color: var(--text-primary);
}

.menu-item:hover::before {
    opacity: 1;
}

.menu-item.is-dangerous {
    border-color: rgba(239, 68, 68, 0.3);
}

.menu-item.is-dangerous:hover {
    border-color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.05);
}

.menu-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.menu-item-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--item-color) 12%, transparent);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.menu-item:hover .menu-item-icon {
    background: color-mix(in srgb, var(--item-color) 20%, transparent);
    transform: scale(1.05);
}

.menu-item-icon svg {
    width: 22px;
    height: 22px;
    color: var(--item-color);
}

.menu-item-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--badge-color, var(--accent-modules));
    color: white;
}

.menu-item-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: var(--space-sm);
}

.menu-item-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.menu-item-arrow {
    position: absolute;
    bottom: var(--space-md);
    right: var(--space-md);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateX(-8px);
    transition: all var(--transition-fast);
}

.menu-item-arrow svg {
    width: 16px;
    height: 16px;
    color: var(--item-color);
}

.menu-item:hover .menu-item-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================================
   FOOTER
   ============================================================ */

.nicc-admin-footer {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.separator {
    opacity: 0.5;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.footer-link svg {
    width: 16px;
    height: 16px;
}

.footer-link:hover {
    background: var(--bg-secondary);
    color: var(--accent-modules);
    text-decoration: none;
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

/* ============================================================
   OCULTAR ELEMENTOS DE DOKUWIKI
   ============================================================ */

/* Ocultar informacion de version de DokuWiki */
.nicc-admin-container ~ .docInfo,
.nicc-admin-container ~ * .docInfo,
body.do_admin .docInfo {
    display: none !important;
}

/* Ocultar el footer de DokuWiki cuando esta el menu NICC */
body.do_admin #dokuwiki__footer .doc,
body.do_admin .dokuwiki .docInfo {
    display: none !important;
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.btn-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.btn-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.modal-body a {
    color: var(--accent-modules);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .nicc-admin-header {
        padding: var(--space-md);
        flex-wrap: wrap;
        gap: var(--space-md);
    }

    .header-center {
        order: 3;
        flex-basis: 100%;
        margin: 0;
        max-width: none;
    }

    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .category-content {
        grid-template-columns: 1fr;
    }

    .nicc-admin-footer {
        flex-direction: column;
        gap: var(--space-sm);
        text-align: center;
    }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

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

.menu-item {
    animation: fadeInUp 0.4s ease backwards;
}

.category:nth-child(1) .menu-item { animation-delay: 0.05s; }
.category:nth-child(2) .menu-item { animation-delay: 0.1s; }
.category:nth-child(3) .menu-item { animation-delay: 0.15s; }
.category:nth-child(4) .menu-item { animation-delay: 0.2s; }
.category:nth-child(5) .menu-item { animation-delay: 0.25s; }
.category:nth-child(6) .menu-item { animation-delay: 0.3s; }

/* Stagger items within category */
.menu-item:nth-child(1) { animation-delay: 0.02s; }
.menu-item:nth-child(2) { animation-delay: 0.04s; }
.menu-item:nth-child(3) { animation-delay: 0.06s; }
.menu-item:nth-child(4) { animation-delay: 0.08s; }
.menu-item:nth-child(5) { animation-delay: 0.10s; }
.menu-item:nth-child(6) { animation-delay: 0.12s; }
