:root {
    --bg: #08090b;
    --bg-soft: #101217;
    --panel: rgba(16, 18, 23, 0.94);
    --panel-soft: rgba(20, 23, 32, 0.88);
    --line: rgba(212, 175, 55, 0.24);
    --line-strong: rgba(212, 175, 55, 0.48);
    --primary-color: #d4af37;
    --secondary-color: #f5df9e;
    --bg-color: #08090b;
    --text-color: #f6f3eb;
    --text-muted: rgba(184, 179, 168, 0.76);
    --border-color: rgba(212, 175, 55, 0.22);
    --white: #ffffff;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow-sm: 0 14px 35px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 25px rgba(212, 175, 55, 0.12);
    --radius-sm: 14px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-pill: 999px;
}

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

body {
    min-height: 100vh;
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    background:
        radial-gradient(circle at 12% 8%, rgba(212, 175, 55, 0.14), transparent 28%),
        radial-gradient(circle at 88% 16%, rgba(245, 223, 158, 0.09), transparent 24%),
        linear-gradient(180deg, #060709 0%, #0c0e13 100%);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.95), transparent 94%);
    opacity: 0.4;
}

a {
    color: inherit;
    text-decoration: none;
}

.admin-body,
.login-body {
    position: relative;
}

.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 460px;
}

.glass-panel {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    background: linear-gradient(180deg, rgba(10, 18, 34, 0.96), rgba(7, 12, 22, 0.92));
    box-shadow: var(--shadow-md);
    /* Reducido de blur(18px) a blur(8px) para mejorar rendimiento en hosting compartido */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.glass-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(130deg, rgba(255, 255, 255, 0.22), rgba(47, 107, 255, 0.26), rgba(255, 255, 255, 0.06));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.login-box {
    overflow: hidden;
}

.login-eyebrow,
.page-intro,
.admin-brand small {
    color: var(--text-muted);
}

.login-eyebrow {
    display: inline-flex;
    align-items: center;
    margin-bottom: 16px;
    padding: 8px 14px;
    border: 1px solid rgba(139, 196, 255, 0.2);
    border-radius: var(--radius-pill);
    background: rgba(47, 107, 255, 0.12);
    color: var(--secondary-color);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.logo {
    font-family: 'Poppins', sans-serif;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    color: var(--white);
}

.login-box .logo {
    margin-bottom: 1rem;
    text-align: center;
}

.logo span {
    color: var(--secondary-color);
}

.login-copy {
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.65;
}

.login-back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 1.25rem;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 700;
    transition: color 0.2s ease, transform 0.2s ease;
}

.login-back-link:hover {
    color: var(--secondary-color);
    transform: translateY(-1px);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.55rem;
    color: var(--white);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.form-control {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

.form-control:focus {
    outline: none;
    border-color: var(--line-strong);
    box-shadow: 0 0 0 3px rgba(120, 180, 255, 0.14);
}

.form-control option {
    color: #04101e;
}

.size-options-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.size-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 54px;
    margin-bottom: 0;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.size-option:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.08);
}

.size-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary-color);
}

.size-option span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
}

.image-hint,
.image-editor-note,
.manual-editor__help,
#selected-images-info {
    margin-top: 0.55rem;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.image-analysis,
.manual-editor {
    margin-top: 0.8rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
}

.image-analysis--good {
    border-color: rgba(127, 224, 255, 0.32);
    background: rgba(127, 224, 255, 0.08);
    color: #d8f8ff;
}

.image-analysis--review {
    border-color: rgba(198, 220, 255, 0.28);
    background: rgba(198, 220, 255, 0.08);
    color: #f3f8ff;
}

.image-analysis--bad {
    border-color: rgba(255, 107, 143, 0.28);
    background: rgba(255, 107, 143, 0.08);
    color: #ffe7ee;
}

.image-analysis__title {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.image-analysis__summary,
.image-analysis__section {
    font-size: 0.84rem;
    line-height: 1.55;
}

.image-analysis__metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.75rem 0;
}

.image-analysis__metrics span {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
}

.image-analysis__section + .image-analysis__section {
    margin-top: 0.55rem;
}

.image-analysis__section ul {
    margin: 0.4rem 0 0 1rem;
}

.image-analysis__section li + li {
    margin-top: 0.22rem;
}

.image-editor-actions,
.manual-editor__toolbar,
.manual-editor__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

.image-editor-actions,
.manual-editor__actions {
    margin-top: 0.8rem;
}

.manual-editor__toolbar {
    margin-bottom: 0.8rem;
}

.manual-editor__label,
.manual-editor__value {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.manual-editor__value {
    min-width: 54px;
}

.manual-editor__toolbar input[type="range"] {
    width: 120px;
}

.manual-editor__canvas-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 420px;
    padding: 0.6rem;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background-color: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.manual-editor__canvas-wrap canvas {
    width: 100%;
    max-width: 420px;
    height: auto;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.manual-mode-btn {
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-color);
}

.manual-mode-btn.active {
    background: linear-gradient(135deg, var(--white), var(--secondary-color));
    border-color: transparent;
    color: #04101e;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0.75rem 1.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    text-decoration: none;
    letter-spacing: 0.04em;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 38px;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
}

.btn-lg {
    min-height: 54px;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--white), var(--secondary-color));
    color: #04101e;
    box-shadow: 0 16px 34px rgba(120, 180, 255, 0.16);
}

.btn-danger {
    background: rgba(255, 107, 143, 0.14);
    border-color: rgba(255, 107, 143, 0.2);
    color: #ffe8ef;
}

.btn-outline {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--white);
}

.btn-outline:hover {
    background: rgba(47, 107, 255, 0.12);
    border-color: var(--line-strong);
}

.btn-outline-dark {
    border-color: var(--border-color);
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.04);
}

.alert {
    padding: 1rem;
    border-radius: 18px;
    margin-bottom: 1rem;
    font-size: 0.92rem;
    border: 1px solid transparent;
}

.alert-danger {
    background: rgba(255, 107, 143, 0.08);
    color: #ffe7ee;
    border-color: rgba(255, 107, 143, 0.22);
}

.alert-success {
    background: rgba(127, 224, 255, 0.08);
    color: #d9f8ff;
    border-color: rgba(127, 224, 255, 0.22);
}

.alert-info {
    background: rgba(198, 220, 255, 0.08);
    color: #eff6ff;
    border-color: rgba(198, 220, 255, 0.24);
}

.admin-flash {
    margin-bottom: 1.25rem;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
}

.admin-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 18px 28px;
    border-bottom: 1px solid rgba(106, 154, 255, 0.12);
    background: rgba(4, 10, 22, 0.92);
    /* Reducido de blur(18px) a blur(6px): sticky + backdrop-filter es costoso en Hostinger */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    /* will-change evita repaint en el scroll del sticky header */
    will-change: transform;
}

.admin-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-header .logo {
    margin: 0;
}

.admin-brand small {
    font-size: 0.85rem;
    letter-spacing: 0.03em;
}

.admin-nav {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.admin-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    font-weight: 700;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.admin-nav a.active,
.admin-nav a:hover {
    color: var(--white);
    background: rgba(47, 107, 255, 0.16);
}

.admin-nav .btn-outline {
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.admin-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

.header-action {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.header-action h1,
.panel-heading h2,
.glass-panel h3 {
    font-family: 'Poppins', sans-serif;
    color: var(--white);
}

.header-action h1 {
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    margin-bottom: 0.3rem;
}

.page-intro {
    max-width: 760px;
    font-size: 1rem;
    line-height: 1.65;
}

.admin-overview-grid,
.dashboard-grid {
    display: grid;
    gap: 1.2rem;
}

.admin-overview-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 1.4rem;
}

.overview-card {
    position: relative;
    overflow: hidden;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(10, 18, 34, 0.92), rgba(7, 12, 22, 0.8));
    box-shadow: var(--shadow-sm);
}

.overview-card span,
.overview-card small {
    display: block;
}

.overview-card span {
    color: var(--text-muted);
    font-size: 0.86rem;
    letter-spacing: 0.02em;
}

.overview-card strong {
    display: block;
    margin: 0.5rem 0 0.25rem;
    font-family: 'Poppins', sans-serif;
    font-size: 2rem;
    color: var(--white);
}

.overview-card small {
    color: var(--text-muted);
}

.overview-card::after {
    content: '';
    position: absolute;
    right: -24px;
    top: -24px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 196, 255, 0.16), transparent 65%);
}

.dashboard-grid {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr 2fr;
    }
}

.admin-table-panel {
    padding: 1rem;
}

.panel-heading {
    padding: 0.6rem 0.6rem 0.2rem;
}

.panel-heading h2 {
    font-size: 1.25rem;
    margin-bottom: 0.35rem;
}

.panel-heading p {
    color: var(--text-muted);
    line-height: 1.55;
}

.form-panel {
    max-width: 980px;
    margin: 0 auto;
}

.table-responsive {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.admin-table th,
.admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(106, 154, 255, 0.12);
    vertical-align: top;
}

.admin-table th {
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.admin-table tbody tr {
    transition: background 0.2s ease;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge-info,
.badge-success,
.badge-warning {
    background: rgba(47, 107, 255, 0.12);
    color: var(--white);
    border-color: rgba(120, 180, 255, 0.18);
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

.slider {
    position: absolute;
    inset: 0;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.18);
    transition: .35s;
    border-radius: 24px;
}

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

input:checked + .slider {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

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

.thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
}

.order-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-btn {
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 0.8;
    color: var(--text-muted);
}

.order-btn:hover {
    color: var(--secondary-color);
}

.order-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.form-submit-row {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(106, 154, 255, 0.14);
}

@media (max-width: 820px) {
    .admin-header {
        padding: 16px 18px;
        flex-wrap: wrap;
    }

    .admin-nav {
        width: 100%;
    }

    .size-options-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@keyframes adminGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(120, 180, 255, 0.04);
        border-color: rgba(120, 180, 255, 0.16);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(120, 180, 255, 0.03);
        border-color: rgba(120, 180, 255, 0.3);
    }
}

/* adminGlow: solo en dispositivos con movimiento habilitado y en pantallas no reducidas.
   En Hostinger/shared hosting esta animación continua consume GPU innecesariamente. */
@media (prefers-reduced-motion: no-preference) and (min-width: 821px) {
    body.admin-body .admin-header,
    body.login-body .glass-panel,
    .overview-card,
    .glass-panel {
        animation: adminGlow 14s ease-in-out infinite;
    }
}

.admin-header {
    transition: background 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.admin-header::after {
    content: '';
    position: absolute;
    left: 28px;
    right: 28px;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139, 196, 255, 0.66), transparent);
    opacity: 0.8;
}

.admin-nav a {
    position: relative;
    overflow: hidden;
}

.admin-nav a::before,
.btn::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 -42%;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-18deg);
    opacity: 0;
}

.admin-nav a:hover::before,
.admin-nav a.active::before,
.btn:hover::before {
    animation: sheenSweepAdmin 0.75s ease;
}

@keyframes sheenSweepAdmin {
    0% {
        transform: translateX(-150%) skewX(-18deg);
        opacity: 0;
    }
    45% {
        opacity: 0.5;
    }
    100% {
        transform: translateX(200%) skewX(-18deg);
        opacity: 0;
    }
}

.glass-panel {
    overflow: hidden;
}

.glass-panel::after,
.overview-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(139, 196, 255, 0.12), transparent 28%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 42%);
    pointer-events: none;
}

.overview-card {
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    /* GPU layer solo en hover para evitar capas persistentes */
    will-change: auto;
}

.overview-card:hover {
    transform: translateY(-4px);
    border-color: rgba(120, 180, 255, 0.3);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
    will-change: transform;
}

.overview-card strong {
    text-shadow: 0 0 22px rgba(139, 196, 255, 0.1);
}

.panel-heading h2::after,
.header-action h1::after,
.glass-panel h3::after {
    content: '';
    display: block;
    width: 82px;
    height: 3px;
    margin-top: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--secondary-color), rgba(255, 255, 255, 0.18));
}

.admin-table tbody tr {
    position: relative;
}

.admin-table tbody tr::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(120, 180, 255, 0.18), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.admin-table tbody tr:hover::after {
    opacity: 1;
}

.admin-table .form-control,
.admin-table select.form-control {
    min-height: 40px;
    background: rgba(255, 255, 255, 0.04);
}

.btn-primary,
.btn-outline,
.btn-danger {
    position: relative;
    overflow: hidden;
}

.btn-primary {
    box-shadow: 0 18px 36px rgba(120, 180, 255, 0.14);
}

.btn-danger:hover {
    box-shadow: 0 16px 30px rgba(255, 107, 143, 0.12);
}

.login-box {
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
}

.login-box .logo {
    text-shadow: 0 0 26px rgba(139, 196, 255, 0.14);
}

.form-panel,
.admin-table-panel {
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

.badge-info,
.badge-success,
.badge-warning {
    box-shadow: inset 0 0 0 1px rgba(139, 196, 255, 0.08);
}

.order-btn:hover,
.switch:hover .slider {
    filter: brightness(1.15);
}

@media (prefers-reduced-motion: reduce) {
    body.admin-body .admin-header,
    body.login-body .glass-panel,
    .overview-card,
    .glass-panel {
        animation: none !important;
    }

    /* En dispositivos con movimiento reducido, también desactivar el sheen sweep */
    .admin-nav a::before,
    .btn::before {
        display: none !important;
    }
}
