:root {
    --primary: #0057A8;
    --primary-hover: #0868C8;
    --primary-light: #e0f2fe;
    --dark-bg: #07131F;
    --dark-sidebar: #0B1928;
    --dark-surface: #102438;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --white: #ffffff;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #0284c7;
    --info-light: #e0f2fe;
    
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--slate-100);
    color: var(--slate-800);
    line-height: 1.5;
    font-size: 14px;
    display: flex;
    min-height: 100vh;
}

/* App Wrapper */
.admin-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--dark-sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    transition: transform 0.3s ease;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo {
    padding: 20px 18px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid var(--primary);
    min-height: 80px;
}

.sidebar-logo img {
    max-height: 55px;
    max-width: 100%;
    object-fit: contain;
}

.sidebar-menu {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--slate-400);
    padding: 10px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13.5px;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--dark-surface);
    color: #ffffff;
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 87, 168, 0.4);
}

.nav-item .icon {
    font-size: 17px;
    width: 22px;
    display: inline-flex;
    justify-content: center;
}

.nav-item .pill-badge {
    margin-left: auto;
    background: var(--danger);
    color: #ffffff;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: var(--dark-bg);
}

.sidebar-footer .back-to-store {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: var(--radius);
    transition: color 0.2s;
}

.sidebar-footer .back-to-store:hover {
    color: #ffffff;
    background: var(--dark-surface);
}

/* Main Content Area */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--slate-100);
}

/* Top Header */
.admin-header {
    background: var(--white);
    border-bottom: 1px solid var(--slate-200);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: var(--shadow-sm);
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--slate-700);
    cursor: pointer;
}

.header-title h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--slate-900);
}

.header-title p {
    font-size: 12px;
    color: var(--slate-500);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 20px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    background: var(--primary);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--slate-800);
}

.btn-logout {
    background: var(--danger-light);
    color: var(--danger);
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    color: #ffffff;
}

/* Page Container */
.admin-container {
    padding: 28px;
    flex: 1;
}

/* Section Switching - Instantáneo sin desvanecimiento ni retrasos */
.tab-section {
    display: none !important;
}

.tab-section.active {
    display: block !important;
    animation: none !important;
    transition: none !important;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--white);
    padding: 22px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--slate-200);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
}

.kpi-card.warning::before { background: var(--warning); }
.kpi-card.success::before { background: var(--success); }
.kpi-card.danger::before { background: var(--danger); }

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.kpi-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--slate-500);
}

.kpi-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--slate-100);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.kpi-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--slate-900);
    margin-bottom: 4px;
}

.kpi-subtitle {
    font-size: 12px;
    color: var(--slate-500);
}

/* Dashboard Two Columns */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* Cards & Panels */
.card-panel {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--slate-200);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 800;
    color: var(--slate-900);
}

.card-header p {
    font-size: 12px;
    color: var(--slate-500);
}

.card-body {
    padding: 22px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.admin-table th {
    background: var(--slate-50);
    color: var(--slate-600);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11.5px;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    border-bottom: 2px solid var(--slate-200);
    text-align: left;
}

.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--slate-200);
    vertical-align: middle;
}

.admin-table tr:hover {
    background: #f8fafc;
}

/* Product Thumbnail */
.prod-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.prod-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    flex-shrink: 0;
}

/* Status Badges */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-nueva { background: var(--info-light); color: var(--info); }
.status-en-revision { background: var(--warning-light); color: #b45309; }
.status-aprobada { background: var(--success-light); color: var(--success); }
.status-rechazada { background: var(--danger-light); color: var(--danger); }
.status-enviada { background: #f3e8ff; color: #7e22ce; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13.5px;
    font-weight: 700;
    border-radius: var(--radius);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--slate-200); color: var(--slate-700); }
.btn-secondary:hover { background: var(--slate-300); }

.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 5px;
}

.btn-icon {
    padding: 6px 9px;
    font-size: 14px;
}

/* Toolbar & Filters */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius);
    padding: 6px 12px;
    min-width: 280px;
    gap: 8px;
}

.search-box input {
    border: none;
    outline: none;
    font-size: 13.5px;
    width: 100%;
    background: transparent;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.select-filter {
    padding: 8px 12px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius);
    font-size: 13.5px;
    background: var(--white);
    outline: none;
}

/* Modals - Apertura y cierre inmediato sin desvanecimiento ni retrasos */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    opacity: 1;
    pointer-events: auto;
    transition: none !important;
    animation: none !important;
}

.modal-backdrop.open {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transition: none !important;
    animation: none !important;
}

.modal-dialog {
    background: var(--white);
    border-radius: 10px;
    width: 94vw;
    max-width: 960px;
    max-height: 92vh;
    overflow: hidden;
    resize: both;
    box-shadow: var(--shadow-lg);
    display: flex !important;
    flex-direction: column !important;
    transition: none !important;
    animation: none !important;
}

.modal-dialog form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
}

.modal-dialog .modal-header {
    flex-shrink: 0 !important;
}

.modal-dialog .modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}

.modal-dialog .modal-footer {
    flex-shrink: 0 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-end !important;
    align-items: center !important;
    background: var(--slate-50) !important;
    border-top: 1px solid var(--slate-200) !important;
    padding: 14px 24px !important;
    margin: 0 !important;
    position: static !important;
    box-shadow: none !important;
    border-bottom-left-radius: 10px !important;
    border-bottom-right-radius: 10px !important;
}

.modal-dialog.modal-expanded {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 95vh !important;
    max-height: 95vh !important;
    border-radius: 8px !important;
}

.modal-dialog.modal-expanded .modal-body {
    flex: 1 1 auto !important;
    max-height: calc(95vh - 125px) !important;
    overflow-y: auto !important;
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 800;
    color: var(--slate-900);
    flex: 1;
}

.modal-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modal-expand-btn {
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: inherit;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.modal-expand-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: #3b82f6;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--slate-400);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--slate-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--slate-50);
}

/* Modo Pestaña Expandida (Ocultar barra lateral para usar 100% del ancho) */
body.sidebar-collapsed .admin-sidebar {
    transform: translateX(-100%) !important;
}

body.sidebar-collapsed .admin-main {
    margin-left: 0 !important;
    width: 100% !important;
}

.menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    cursor: pointer;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group.full {
    grid-column: span 2;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--slate-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--slate-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 87, 168, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* Image Dropzone / Preview */
.image-upload-box {
    border: 2px dashed var(--slate-300);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    background: var(--slate-50);
    cursor: pointer;
    transition: all 0.2s;
}

.image-upload-box:hover {
    border-color: var(--primary);
    background: #f0f9ff;
}

.image-preview-large {
    max-height: 120px;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 4px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--slate-900);
    color: #ffffff;
    padding: 14px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 600;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.open {
        transform: translateX(0);
    }
    .admin-main {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-group.full {
        grid-column: span 1;
    }
    .admin-container {
        padding: 16px;
    }
}
