/* ============================================================
   PANEL ADMIN — ESTILOS
   ============================================================ */

:root {
    --admin-primary:  #6366f1;
    --admin-dark:     #4f46e5;
    --admin-bg:       #f1f5f9;
    --admin-sidebar:  #1e293b;
    --admin-sidebar-hover: #334155;
    --admin-sidebar-active: #6366f1;
    --admin-text:     #1e293b;
    --admin-muted:    #64748b;
    --admin-border:   #e2e8f0;
    --admin-card-bg:  #fff;
    --admin-radius:   12px;
    --admin-shadow:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
    --sidebar-width:  240px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    font-size: 14px;
    margin: 0;
}

/* ============================================================
   LAYOUT ADMIN
   ============================================================ */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--admin-sidebar);
    min-height: 100vh;
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .3s;
}

.admin-sidebar .sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
}

.admin-sidebar .sidebar-brand span {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.3px;
}

.admin-sidebar .sidebar-brand small {
    display: block;
    color: rgba(255,255,255,.4);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .8px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav .nav-section {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,.3);
    padding: .75rem 1.5rem .25rem;
    margin-top: .5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.5rem;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    border-radius: 0;
}

.sidebar-nav a:hover {
    background: var(--admin-sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--admin-sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav a i { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: rgba(255,255,255,.5);
    font-size: .8rem;
    text-decoration: none;
    transition: color .2s;
}

.sidebar-footer a:hover { color: #fff; }

/* MAIN CONTENT */
.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOP BAR */
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--admin-border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.admin-topbar .page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--admin-text);
    margin: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: var(--admin-muted);
}

.topbar-user .avatar {
    width: 32px; height: 32px;
    background: var(--admin-primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: .8rem;
}

/* Toggle sidebar para móvil */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--admin-text);
    cursor: pointer;
    padding: .2rem;
}

/* CONTENT AREA */
.admin-content {
    padding: 1.5rem;
    flex: 1;
}

/* ============================================================
   TARJETAS ESTADÍSTICAS (DASHBOARD)
   ============================================================ */
.stat-card {
    background: var(--admin-card-bg);
    border-radius: var(--admin-radius);
    padding: 1.25rem;
    box-shadow: var(--admin-shadow);
    border: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-info .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--admin-text);
}

.stat-card .stat-info .stat-label {
    font-size: .78rem;
    color: var(--admin-muted);
    margin-top: .2rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
}

.stat-card .stat-info .stat-sub {
    font-size: .72rem;
    color: var(--admin-muted);
    margin-top: .15rem;
    font-weight: 500;
}

/* ============================================================
   TABLAS
   ============================================================ */
.admin-table {
    background: var(--admin-card-bg);
    border-radius: var(--admin-radius);
    overflow: hidden;
    box-shadow: var(--admin-shadow);
    border: 1px solid var(--admin-border);
}

.admin-table .table {
    margin: 0;
    font-size: .875rem;
}

.admin-table .table thead th {
    background: var(--admin-bg);
    font-weight: 700;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .6px;
    color: var(--admin-muted);
    border-bottom: 1px solid var(--admin-border);
    padding: .875rem 1rem;
}

.admin-table .table tbody td {
    padding: .75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--admin-border);
    color: var(--admin-text);
}

.admin-table .table tbody tr:last-child td {
    border-bottom: none;
}

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

/* ============================================================
   FORMULARIOS ADMIN
   ============================================================ */
.admin-card {
    background: var(--admin-card-bg);
    border-radius: var(--admin-radius);
    padding: 1.5rem;
    box-shadow: var(--admin-shadow);
    border: 1px solid var(--admin-border);
    margin-bottom: 1.5rem;
}

.admin-card h5 {
    font-weight: 700;
    color: var(--admin-text);
    margin-bottom: 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--admin-bg);
}

.form-label {
    font-weight: 600;
    font-size: .82rem;
    color: var(--admin-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: .35rem;
}

.form-control, .form-select, .form-check-input {
    border-color: var(--admin-border);
    border-radius: 8px;
    font-size: .875rem;
    transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

/* ============================================================
   BOTONES ADMIN
   ============================================================ */
.btn { border-radius: 8px; font-weight: 600; font-size: .85rem; }

.btn-primary {
    background: var(--admin-primary);
    border-color: var(--admin-primary);
}

.btn-primary:hover {
    background: var(--admin-dark);
    border-color: var(--admin-dark);
}

.btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: .9rem;
}

/* ============================================================
   PÁGINA DE LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 50px rgba(0,0,0,.25);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .login-logo h4 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--admin-primary);
    margin-bottom: .25rem;
}

.login-card .login-logo p {
    color: var(--admin-muted);
    font-size: .85rem;
}

/* ============================================================
   IMAGEN PREVIEW
   ============================================================ */
.img-preview-wrap {
    position: relative;
    display: inline-block;
}

.img-preview {
    width: 80px; height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--admin-border);
}

.img-preview-wrap .btn-remove {
    position: absolute;
    top: -6px; right: -6px;
    width: 20px; height: 20px;
    background: var(--admin-primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* ============================================================
   BADGE STATUS
   ============================================================ */
.status-badge {
    padding: .2rem .7rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.status-badge.active   { background: #dcfce7; color: #16a34a; }
.status-badge.inactive { background: #fee2e2; color: #dc2626; }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
.form-switch .form-check-input {
    width: 2.5em;
    height: 1.25em;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--admin-primary);
    border-color: var(--admin-primary);
}

/* ============================================================
   RESPONSIVE ADMIN
   ============================================================ */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.open {
        transform: translateX(0);
    }
    .admin-main {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .admin-content {
        padding: 1rem;
    }
    /* Overlay cuando sidebar abierto */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 1039;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.gap-1 { gap: .25rem !important; }
.gap-2 { gap: .5rem !important; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.text-muted { color: var(--admin-muted) !important; }

/* ============================================================
   FORMULARIO DE PRODUCTO — SECCIONES
   ============================================================ */
.form-section-header {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1.25rem;
    padding-bottom: .875rem;
    border-bottom: 2px solid var(--admin-bg);
}

.form-section-header > i {
    font-size: 1.3rem;
    color: var(--admin-primary);
    margin-top: .05rem;
    flex-shrink: 0;
}

.form-section-header h5 {
    font-weight: 700;
    color: var(--admin-text);
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    font-size: .95rem;
}

.form-section-header p {
    margin: 0;
    line-height: 1.4;
}

/* Flag cards (Destacado / Más vendido) */
.product-flag-card {
    background: var(--admin-bg);
    border: 1.5px solid var(--admin-border);
    border-radius: 10px;
    padding: .75rem 1rem;
    transition: border-color .2s, background .2s;
    cursor: pointer;
}

.product-flag-card:has(.form-check-input:checked) {
    border-color: var(--admin-primary);
    background: rgba(99,102,241,.05);
}

.product-flag-card .form-check {
    padding: 0;
    margin: 0;
}

.product-flag-card .form-check-input {
    float: right;
    margin: 0;
}

.product-flag-card .flag-label {
    display: flex;
    align-items: center;
    gap: .6rem;
    cursor: pointer;
    width: 100%;
}

.product-flag-card .flag-icon {
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.product-flag-card .flag-text strong {
    display: block;
    font-size: .84rem;
    font-weight: 600;
    color: var(--admin-text);
    line-height: 1.2;
}

.product-flag-card .flag-text small {
    display: block;
    font-size: .72rem;
    color: var(--admin-muted);
    line-height: 1.3;
}

/* ── Image slots grid ─────────────────────────────────────── */
.img-slots-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .85rem;
}

.img-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

/* Slot principal ocupa 2 columnas */
.img-slot-main {
    grid-column: span 2;
}

.img-slot-label {
    display: block;
    cursor: pointer;
    width: 100%;
}

.img-slot-input {
    display: none;
}

.img-slot-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    border: 2px dashed var(--admin-border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--admin-bg);
    transition: border-color .2s, background .2s;
}

.img-slot-main .img-slot-preview {
    aspect-ratio: 4 / 3;
}

.img-slot-label:hover .img-slot-preview,
.img-slot-preview.has-image:hover {
    border-color: var(--admin-primary);
    background: #f5f3ff;
}

.img-slot-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 10px;
}

.img-slot-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    color: #94a3b8;
    text-align: center;
    padding: .5rem;
    pointer-events: none;
}
.img-slot-placeholder i    { font-size: 1.6rem; }
.img-slot-placeholder span { font-size: .75rem; font-weight: 600; }
.img-slot-placeholder small{ font-size: .65rem; opacity: .75; }

/* Overlay "Cambiar" al hover sobre imagen cargada */
.img-slot-overlay {
    position: absolute;
    inset: 0;
    background: rgba(99,102,241,.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-size: .8rem;
    font-weight: 700;
    border-radius: 10px;
    opacity: 0;
    transition: opacity .2s;
}
.img-slot-label:hover .img-slot-overlay { opacity: 1; }

/* Badge de nombre de slot */
.img-slot-badge {
    font-size: .68rem;
    font-weight: 600;
    color: #94a3b8;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* Botón eliminar imagen existente */
.img-slot-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    background: rgba(239,68,68,.9);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    text-decoration: none;
    z-index: 2;
    transition: background .2s;
    backdrop-filter: blur(4px);
}
.img-slot-delete:hover { background: #dc2626; color: #fff; }

@media (max-width: 575px) {
    .img-slots-grid { grid-template-columns: repeat(2, 1fr); }
    .img-slot-main  { grid-column: span 2; }
}

/* Publication sidebar card */
.publish-card {
    position: sticky;
    top: 76px;
}

/* Variant rows */
.variant-admin-row {
    background: var(--admin-bg);
    border-radius: 8px;
    padding: .5rem .75rem;
}

/* Sidebar logo */
.sidebar-logo-img {
    max-height: 56px;
    max-width: 160px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin-bottom: .5rem;
    filter: brightness(0) invert(1);
    opacity: .9;
}
