/**
 * Gestemas Admin Premium Styles
 * Estilos avanzados para el área de administración de WordPress
 * @package Gestemas
 * @version 1.0.0
 */

/* ═══════════════════════════════════════════════════════════
   ADMIN WRAPPER
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: var(--block-padding-internal, 20px);
    padding-left: 0;
}

.gestemas-admin h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1E3A5F;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN CARDS
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-card {
    background: #ffffff;
    border: 1px solid #E9EDF2;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.06);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.gestemas-admin .gestemas-card:hover {
    box-shadow: 0 8px 24px rgba(30, 58, 95, 0.1);
    transform: translateY(-2px);
}

.gestemas-admin .gestemas-card__header {
    padding: 16px 20px;
    border-bottom: 1px solid #E9EDF2;
    background: linear-gradient(145deg, #FAFBFC 0%, #F4F6F8 100%);
}

.gestemas-admin .gestemas-card__title {
    font-size: 16px;
    font-weight: 600;
    color: #1E3A5F;
    margin: 0;
}

.gestemas-admin .gestemas-card__body {
    padding: var(--block-padding-internal, 20px);
}

/* ═══════════════════════════════════════════════════════════
   ADMIN FORMS
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-form-group {
    margin-bottom: 20px;
}

.gestemas-admin .gestemas-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.gestemas-admin .gestemas-input,
.gestemas-admin .gestemas-select,
.gestemas-admin .gestemas-textarea {
    width: 100%;
    max-width: 500px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: #1F2937;
    background: #ffffff;
    border: 1px solid #D1D9E0;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.gestemas-admin .gestemas-input:focus,
.gestemas-admin .gestemas-select:focus,
.gestemas-admin .gestemas-textarea:focus {
    outline: none;
    border-color: #2FA4A9;
    box-shadow: 0 0 0 3px rgba(47, 164, 169, 0.15);
}

.gestemas-admin .gestemas-input::placeholder {
    color: #A8B5C4;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN BUTTONS
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.gestemas-admin .gestemas-btn--primary {
    background: linear-gradient(135deg, #1E3A5F 0%, #2A4F7F 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.25);
}

.gestemas-admin .gestemas-btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 58, 95, 0.3);
    filter: brightness(1.1);
}

.gestemas-admin .gestemas-btn--secondary {
    background: linear-gradient(135deg, #2FA4A9 0%, #3DBDC3 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(47, 164, 169, 0.25);
}

.gestemas-admin .gestemas-btn--secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(47, 164, 169, 0.3);
}

.gestemas-admin .gestemas-btn--ghost {
    background: transparent;
    color: #6B7280;
    padding: 8px 16px;
}

.gestemas-admin .gestemas-btn--ghost:hover {
    background: #F4F6F8;
    color: #1E3A5F;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN TABLES
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.gestemas-admin .gestemas-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #1E3A5F;
    background: #FAFBFC;
    border-bottom: 2px solid #E9EDF2;
}

.gestemas-admin .gestemas-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #E9EDF2;
    color: #374151;
}

.gestemas-admin .gestemas-table tbody tr:hover {
    background: #F8FAFC;
}

.gestemas-admin .gestemas-table tbody tr:last-child td {
    border-bottom: none;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN BADGES
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.gestemas-admin .gestemas-badge--success {
    background: rgba(39, 174, 96, 0.1);
    color: #27AE60;
}

.gestemas-admin .gestemas-badge--warning {
    background: rgba(243, 156, 18, 0.1);
    color: #F39C12;
}

.gestemas-admin .gestemas-badge--error {
    background: rgba(231, 76, 60, 0.1);
    color: #E74C3C;
}

.gestemas-admin .gestemas-badge--info {
    background: rgba(47, 164, 169, 0.1);
    color: #2FA4A9;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN STATS GRID
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.gestemas-admin .gestemas-stat-card {
    padding: 20px;
    background: #ffffff;
    border: 1px solid #E9EDF2;
    border-radius: 12px;
    transition: all 0.2s;
}

.gestemas-admin .gestemas-stat-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.gestemas-admin .gestemas-stat-card__icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.gestemas-admin .gestemas-stat-card__value {
    font-size: 28px;
    font-weight: 700;
    color: #1E3A5F;
    line-height: 1.2;
}

.gestemas-admin .gestemas-stat-card__label {
    font-size: 13px;
    color: #6B7280;
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN TABS
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #F4F6F8;
    border-radius: 12px;
    margin-bottom: 24px;
}

.gestemas-admin .gestemas-tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #6B7280;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.gestemas-admin .gestemas-tab:hover {
    color: #1E3A5F;
    background: rgba(255, 255, 255, 0.5);
}

.gestemas-admin .gestemas-tab--active {
    color: #1E3A5F;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ═══════════════════════════════════════════════════════════
   ADMIN EMPTY STATES
   ═══════════════════════════════════════════════════════════ */

.gestemas-admin .gestemas-empty-state {
    text-align: center;
    padding: 48px 24px;
}

.gestemas-admin .gestemas-empty-state__icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.gestemas-admin .gestemas-empty-state__title {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 8px;
}

.gestemas-admin .gestemas-empty-state__text {
    font-size: 14px;
    color: #6B7280;
    margin: 0 0 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE ADMIN
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 782px) {
    .gestemas-admin {
        padding: 15px 10px;
    }

    .gestemas-admin h1 {
        font-size: 22px;
    }

    .gestemas-admin .gestemas-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ═══════════════════════════════════════════════════════════
   INTELLIGENCE OVERHAUL: SIDE DRAWER & LISTS
   ═══════════════════════════════════════════════════════════ */

/* -- Side Drawer (Viewer) -- */
.gestemas-viewer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    justify-content: flex-end;
}

.gestemas-viewer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.gestemas-viewer-drawer {
    width: 600px;
    max-width: 100vw;
    /* Allow full width on mobile */
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.gestemas-viewer-backdrop.active .gestemas-viewer-drawer {
    transform: translateX(0);
}

.viewer-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    color: #64748b;
}

.viewer-close-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    transform: rotate(90deg);
}

.viewer-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    position: relative;
}

.viewer-actions {
    padding: 20px 40px;
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Compact Buttons for Viewer Actions */
.viewer-actions .gestemas-btn {
    padding: 8px 16px;
    font-size: 13px;
    min-height: 36px;
}


/* -- Nexus List Blocks (Silicon Valley Lists) -- */
.premium-data-wrapper {
    position: relative;
    min-height: 200px;
}

.nexus-list-block {
    display: flex;
    align-items: center;
    gap: 24px;
    background: white;
    border: 1px solid #e2e8f0;
    padding: 16px 24px;
    border-radius: 16px;
    margin-bottom: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.nexus-list-block:hover {
    transform: translateY(-2px) scale(1.005);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    border-color: var(--gestemas-primary, #6366f1);
    z-index: 1;
}

.nexus-list-block.is-completed {
    opacity: 0.6;
    background: #f8fafc;
}

.nexus-block-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 80px;
}

.nexus-date-box {
    text-align: center;
    color: #64748b;
    font-weight: 700;
    line-height: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.d-day {
    font-size: 18px;
    color: #0f172a;
}

.d-month {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nexus-block-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.main-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nexus-title {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nexus-title.line-through {
    text-decoration: line-through;
    color: #94a3b8;
}

.dimension-badge,
.nexus-badge-soft {
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.nexus-excerpt {
    font-size: 13px;
    color: #64748b;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nexus-block-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: 0.2s;
}

.nexus-list-block:hover .nexus-block-actions {
    opacity: 1;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #f1f5f9;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.action-btn:hover {
    background: var(--gestemas-primary, #6366f1);
    color: white;
}

.action-btn.edit:hover {
    background: #0ea5e9;
}

/* Responsive Nexus */
@media (max-width: 768px) {
    .nexus-list-block {
        padding: 16px;
        gap: 16px;
        flex-wrap: wrap;
    }

    .nexus-block-actions {
        opacity: 1;
        margin-left: auto;
    }

    .nexus-excerpt {
        display: none;
    }

    .gestemas-viewer-drawer {
        width: 100%;

        .gestemas-viewer-drawer {
            width: 100%;
            max-width: 100%;
            border-left: none;
        }

        .viewer-content {
            padding: 10px;
            /* Reduced padding for mobile */
        }

        .viewer-header {
            padding: 16px 10px;
        }

        .viewer-meta-grid {
            grid-template-columns: 1fr;
            /* Stack meta items on mobile */
            padding: 16px 20px;
        }
    }

    /* -- Premium Layout Standard -- */
    .gestemas-page-premium {
        padding: 0 var(--padding-side-mobile, 16px);
        max-width: var(--gestemas-max-width);
        margin: 0 auto;
    }

    .gestemas-premium-header {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 24px 0 20px;
        gap: 16px;
    }

    .gestemas-page-header__right {
        width: 100%;
    }

    .gestemas-actions-group {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 12px;
    }

    .gestemas-actions-group .gestemas-btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    .gestemas-consumption-indicator {
        align-items: flex-start !important;
        margin-right: 0 !important;
        margin-bottom: 8px;
    }

    .gestemas-control-bar {
        display: flex;
        align-items: center;
        gap: 16px;
        background: rgba(255, 255, 255, 0.7);
        backdrop-filter: blur(12px);
        border: 1px solid rgba(0, 0, 0, 0.05);
        padding: 12px 10px;
        border-radius: 20px;
        margin-bottom: 24px;
        flex-wrap: wrap;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    }

    .control-search {
        position: relative;
        flex: 1;
        min-width: 250px;
    }

    .control-search i {
        position: absolute;
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: #94a3b8;
        width: 18px;
        height: 18px;
    }

    .control-search-input {
        width: 100%;
        padding: 12px 12px 12px 42px;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        background: white;
        font-size: 14px;
        transition: all 0.2s;
    }

    .control-search-input:focus {
        outline: none;
        border-color: var(--gestemas-primary);
        box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
    }

    .control-filters {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .premium-select {
        padding: 10px 16px;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
        background: white;
        font-size: 13px;
        color: #475569;
        cursor: pointer;
        transition: 0.2s;
    }

    .premium-select:hover {
        border-color: #cbd5e1;
    }

    .view-toggle {
        display: flex;
        background: #f1f5f9;
        padding: 4px;
        border-radius: 12px;
        gap: 2px;
    }

    .toggle-btn {
        padding: 8px;
        border: none;
        background: transparent;
        border-radius: 8px;
        color: #64748b;
        cursor: pointer;
        transition: 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .toggle-btn.active {
        background: white;
        color: var(--gestemas-primary);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    }

    /* -- Premium Cards -- */
    .premium-card {
        background: white;
        border-radius: 24px;
        border: 1px solid #e2e8f0;
        padding: 24px;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex;
        flex-direction: column;
        gap: 16px;
        position: relative;
        overflow: hidden;
    }

    .premium-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.08);
        border-color: var(--gestemas-primary);
    }

    .view-mode-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 24px;
        margin-bottom: 40px;
    }

    /* -- Analytics Extras -- */
    .analytics-kpi-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
        margin-bottom: 32px;
    }

    .glass-v3 {
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    }

    .g-fade-up {
        animation: gFadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    @keyframes gFadeUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @media (max-width: 1024px) {
        .analytics-kpi-grid {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    @media (max-width: 640px) {
        .gestemas-premium-header {
            flex-direction: column;
            align-items: flex-start;
        }

        .gestemas-control-bar {
            padding: 12px;
        }
    }

    /* -- Nexus Extras -- */
    .nexus-title-sm {
        font-size: 14px;
        font-weight: 700;
        color: #1e293b;
    }

    .nexus-badge-soft {
        background: #f1f5f9;
        color: #475569;
        font-size: 11px;
        font-weight: 700;
        padding: 2px 8px;
        border-radius: 6px;
        text-transform: uppercase;
    }

    .nexus-status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #cbd5e1;
    }

    .nexus-status-dot.critical {
        background: #ef4444;
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
    }

    .nexus-status-dot.normal {
        background: #10b981;
    }

    .date-stacked {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 40px;
    }

    .date-stacked .d-day {
        font-size: 18px;
        font-weight: 800;
        color: #0f172a;
        line-height: 1;
    }

    .date-stacked .d-mon {
        font-size: 10px;
        color: #64748b;
        font-weight: 700;
        text-transform: uppercase;
    }

    .avatar-mini {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        background: #e2e8f0;
        color: #475569;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
        font-weight: 700;
        flex-shrink: 0;
    }

    .nexus-badge-pill {
        background: #f1f5f9;
        color: #475569;
        font-size: 11px;
        font-weight: 600;
        padding: 4px 12px;
        border-radius: 99px;
        border: 1px solid #e2e8f0;
    }

    .premium-list-container {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* Animations */
    @keyframes gFadeUp {
        from {
            opacity: 0;
            transform: translateY(10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .g-fade-up {
        animation: gFadeUp 0.4s ease-out forwards;
    }
}

/* === Responsive Drawer & Viewer === */
@media (max-width: 768px) {
    .gestemas-viewer-drawer {
        width: 100%;
        max-width: 100%;
        border-left: none;
    }

    .viewer-content {
        padding: 20px;
    }

    .viewer-header {
        padding: 20px 20px 16px;
    }

    .viewer-meta-grid {
        grid-template-columns: 1fr;
        padding: 16px 20px;
    }
}