/* 
 * KPCJ Design - Enterprise Admin Command Center (Phase 11)
 * Visual Language: B2B SaaS, Glassmorphism, Strict Hierarchy
 */

:root {
    --admin-bg: #030712;
    --admin-sidebar: #0b1121;
    --admin-accent: #3b82f6;
    --admin-card: rgba(17, 24, 39, 0.7);
    --admin-border: rgba(255, 255, 255, 0.08);
    --admin-text: #f1f5f9;
    --admin-muted: #94a3b8;
    --admin-glass: rgba(3, 7, 18, 0.85);
    --admin-glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

body.admin-mode {
    overflow: hidden !important;
    background: var(--admin-bg) !important;
    height: 100vh !important;
    width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.admin-mode #navbar, 
body.admin-mode #site-footer,
body.admin-mode .site-footer,
body.admin-mode #floating-tools,
body.admin-mode #draft-recovery-widget,
body.admin-mode #audio-pill,
body.admin-mode #low-power-indicator,
body.admin-mode .hero,
body.admin-mode .page:not(#admin-vault) {
    display: none !important;
}

html.admin-mode, body.admin-mode {
    overflow: hidden !important;
    height: 100vh !important;
    width: 100vw !important;
    position: fixed !important;
    font-family: 'Outfit', 'Inter', sans-serif !important;
}

/* --- PHASE 12: ENTERPRISE ANALYTICS --- */
.metric-card-premium {
    padding: 30px;
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(255,255,255,0.03), transparent);
    border: 1px solid var(--admin-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.metric-card-premium:hover {
    transform: translateY(-5px);
    border-color: var(--admin-accent);
    background: linear-gradient(145deg, rgba(59, 130, 246, 0.08), transparent);
}

.metric-label {
    font-size: 0.7rem;
    color: var(--admin-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
}

.metric-value {
    font-size: 2.4rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--admin-muted);
}

.section-title-premium {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 30px;
    color: var(--admin-muted);
    font-weight: 700;
}

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

.admin-vault-content {
    animation: adminFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
}

/* Kanban Enhancements */
.kanban-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 20px;
}

.filter-bar {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--admin-border);
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--admin-muted);
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.filter-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.filter-btn.active {
    background: var(--admin-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.admin-search-bar {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    padding: 8px 15px;
    color: #fff;
    font-size: 0.8rem;
    width: 250px;
    outline: none;
    transition: border-color 0.3s;
}

.admin-search-bar:focus {
    border-color: var(--admin-accent);
    background: rgba(255, 255, 255, 0.05);
}

.empty-state-card {
    padding: 30px 20px;
    text-align: center;
    color: var(--admin-muted);
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--admin-border);
    border-radius: 12px;
    font-size: 0.75rem;
    margin: 10px 0;
}

.badge-alert {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid #ef4444;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 800;
}


#admin-vault {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 100vw;
    background: var(--admin-bg);
    color: var(--admin-text);
    font-family: 'Inter', sans-serif;
    display: grid;
    grid-template-columns: 260px 1fr;
    z-index: 10000;
}

/* Sidebar Styling */
.admin-sidebar {
    width: 260px !important;
    max-width: 260px !important;
    background: var(--admin-sidebar) !important;
    border-right: 1px solid var(--admin-border) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 20px 0 !important;
    flex-shrink: 0 !important;
    z-index: 100 !important;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.4) !important;
    overflow: hidden !important;
}

.sidebar-logo {
    padding: 0 25px;
    margin-bottom: 40px;
}

.sidebar-logo-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--admin-accent);
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
}

.sidebar-nav {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    text-align: left !important;
    width: 100% !important;
    overflow-y: auto !important;
    /* Reset global nav fixed position */
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    padding: 0 !important;
    background: transparent !important;
    height: auto !important;
    z-index: 10 !important;
}

.sidebar-nav button {
    background: transparent !important;
    border: none !important;
    color: var(--admin-muted) !important;
    padding: 14px 20px !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    width: calc(100% - 10px) !important;
    margin: 4px 5px !important;
    border-radius: 8px !important;
    text-align: left !important;
}

.sidebar-nav button:hover {
    background: rgba(255, 255, 255, 0.03) !important;
    color: #fff !important;
}

.sidebar-nav button.active {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--admin-accent) !important;
    border-right: 3px solid var(--admin-accent) !important;
}

.sidebar-nav button span {
    font-size: 1.1rem;
    opacity: 0.7;
}

.btn-exit {
    width: 100% !important;
    padding: 12px !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    margin-top: 20px !important;
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
}

.btn-exit:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    transform: translateY(-2px) !important;
}

/* Main Content Area */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--admin-bg);
    overflow: hidden;
}

.admin-header {
    height: 70px;
    background: var(--admin-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 100;
    position: sticky;
    top: 0;
}

.admin-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.admin-view {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.03), transparent 40%);
}

.search-bar {
    margin-bottom: 25px;
    max-width: 400px;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--admin-border);
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    border-color: var(--admin-accent);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 20px;
    height: 100%;
    min-height: calc(100vh - 150px);
    overflow-x: auto;
    padding-bottom: 20px;
}

.kanban-col {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 12px;
    border: 1px solid var(--admin-border);
}

.kanban-col h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--admin-muted);
    padding: 15px 20px;
    margin: 0;
    letter-spacing: 1px;
    font-weight: 800;
    border-bottom: 1px solid var(--admin-border);
    background: rgba(255, 255, 255, 0.02);
}

.kanban-list {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100px;
}

/* Order Card */
.kanban-card {
    background: var(--admin-card);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid var(--admin-border);
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(5px);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card:hover {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(30, 41, 59, 0.9);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--admin-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.card-client {
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 4px;
}

.card-type {
    font-size: 0.75rem;
    color: var(--admin-muted);
}

.card-footer {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid var(--admin-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-quote {
    font-weight: 800;
    font-size: 0.85rem;
    color: #10b981;
}

.card-deadline {
    font-size: 0.7rem;
    color: var(--admin-muted);
}

.badge-alert {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    font-size: 0.6rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Side Modal (Order Hub) */
.side-modal {
    position: fixed;
    top: 0;
    right: -600px;
    width: 600px;
    height: 100vh;
    background: var(--admin-sidebar);
    border-left: 1px solid var(--admin-border);
    z-index: 30005;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
}

.side-modal.active {
    right: 0;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 30000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: block;
    opacity: 1;
}

/* CRM & Inventory Tables */
.admin-table-container {
    background: var(--admin-card);
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    padding: 15px 20px;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--admin-muted);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
    padding: 15px 20px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--admin-border);
}

.admin-table tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

/* Material Engine Toggles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--admin-accent);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Sortable Shadow */
.sortable-ghost {
    opacity: 0.4;
    background: var(--admin-accent) !important;
}

.sortable-drag {
    cursor: grabbing !important;
}

/* --- Phase 12: Order Type Control & Filters --- */
.kanban-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 0 5px;
}

.filter-bar {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--admin-border);
    gap: 4px;
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--admin-muted);
    padding: 6px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-btn:hover {
    color: var(--admin-text);
    background: rgba(255, 255, 255, 0.05);
}

.filter-btn.active {
    background: var(--admin-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Request Type Badges */
.badge-type {
    font-size: 0.6rem !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
}

.badge-ready { background: rgba(34, 197, 94, 0.15) !important; color: #4ade80 !important; border: 1px solid rgba(34, 197, 94, 0.3) !important; }
.badge-repair { background: rgba(234, 179, 8, 0.15) !important; color: #fde047 !important; border: 1px solid rgba(234, 179, 8, 0.3) !important; }
.badge-canvas { background: rgba(239, 68, 68, 0.15) !important; color: #f87171 !important; border: 1px solid rgba(239, 68, 68, 0.3) !important; }
.badge-blue { background: rgba(59, 130, 246, 0.15) !important; color: #60a5fa !important; border: 1px solid rgba(59, 130, 246, 0.3) !important; }
.badge-purple { background: rgba(139, 92, 246, 0.15) !important; color: #a78bfa !important; border: 1px solid rgba(139, 92, 246, 0.3) !important; }

.kanban-card {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease !important;
}

.kanban-card:hover {
    transform: translateY(-4px) scale(1.02) !important;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4) !important;
    border-color: var(--admin-accent) !important;
}

/* --- ORDER BLUEPRINT OVERVIEW (V21) --- */
#admin-order-hub {
    position: fixed;
    top: 0;
    right: -100%;
    width: 800px;
    height: 100%;
    background: var(--admin-card);
    z-index: 30005;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 50px rgba(0,0,0,0.5);
    border-left: 1px solid var(--admin-border);
}

#admin-order-hub.active {
    right: 0;
}

.admin-table-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.admin-table-container:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

.loading-shimmer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--admin-accent, #0ea5e9);
    animation: shimmer-pulse 1.5s infinite;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.loading-shimmer::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid rgba(14, 165, 233, 0.1);
    border-top: 2px solid var(--accent-b2b, #0ea5e9);
    border-radius: 50%;
    animation: portal-spin 1s infinite linear;
    display: inline-block;
}

@keyframes shimmer-pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@keyframes portal-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Scrollbar for Hub */
#admin-order-hub ::-webkit-scrollbar {
    width: 6px;
}
#admin-order-hub ::-webkit-scrollbar-track {
    background: transparent;
}
#admin-order-hub ::-webkit-scrollbar-thumb {
    background: var(--admin-border);
    border-radius: 10px;
}

/* --- PHASE 12: MOBILE RESPONSIVENESS --- */
.admin-mobile-only {
    display: none !important;
}

@media (max-width: 1024px) {
    #admin-vault {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: fixed !important;
        left: -260px !important;
        top: 0;
        bottom: 0;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important, opacity 0.3s ease !important, visibility 0.3s !important;
        box-shadow: 30px 0 60px rgba(0, 0, 0, 0.8) !important;
        z-index: 1000 !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .admin-sidebar.mobile-active {
        left: 0 !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .admin-header {
        padding: 0 20px !important;
    }

    .admin-mobile-only {
        display: block !important;
    }

    .admin-desktop-only {
        display: none !important;
    }

    .admin-view {
        padding: 20px !important;
    }

    .kanban-board {
        padding-bottom: 50px;
    }

    .metric-card-premium {
        padding: 20px;
    }

    .metric-value {
        font-size: 1.8rem;
    }
}

/* Custom Scrollbar for Sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* --- V21 SECURITY AUDIT: RESPONSIVE SIDE MODALS --- */
@media (max-width: 800px) {
    .side-modal,
    #admin-order-hub {
        width: 100% !important;
        max-width: 100vw !important;
        right: -100% !important;
    }
    
    .side-modal.active,
    #admin-order-hub.active {
        right: 0 !important;
    }
}

@keyframes pulse-orange { 
    0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7); } 
    70% { box-shadow: 0 0 0 10px rgba(249, 115, 22, 0); } 
    100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); } 
}

/* --- V21 DESIGN UPGRADE: HIGH-CONTRAST ACTION BUTTONS --- */
#admin-vault .btn-action {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #f1f5f9 !important; /* Force highly legible white/light-grey text */
    border: 1px solid var(--admin-border, rgba(255, 255, 255, 0.08)) !important;
    border-radius: 8px !important;
    padding: 8px 16px !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    outline: none !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

#admin-vault .btn-action:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-1px) !important;
}

#admin-vault .btn-action.active {
    background: var(--admin-accent, #3b82f6) !important;
    color: #ffffff !important;
    border-color: var(--admin-accent, #3b82f6) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}
