/* --- VARIABLES & RESET --- */
:root {
    --bg-deep: #050505;
    --bg-panel: #0f0f0f;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.3);
    
    --accent: #ffffff;
    --primary: #ededed;
    --secondary: #333333;
    
    --text-main: #e5e5e5;
    --text-muted: #a3a3a3;
    
    --success: #34d399;
    --warning: #fbbf24;
    --processing: #60a5fa;
    --error: #f87171;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-display: 'Playfair Display', serif;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: var(--font-ui);
    margin: 0;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }

/* --- UTILIDADES (Mini Framework) --- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.opacity-50 { opacity: 0.5; }
.absolute { position: absolute; }
.relative { position: relative; }
.top-0 { top: 0; } .bottom-0 { bottom: 0; } .left-0 { left: 0; } .right-0 { right: 0; } .inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.z-10 { z-index: 10; } .z-20 { z-index: 20; } .z-30 { z-index: 30; }
.overflow-hidden { overflow: hidden; }
.object-contain { object-fit: contain; }
.w-1 { width: 4px; } .w-8 { width: 2rem; } .h-8 { height: 2rem; }
.bg-white { background: white; }
.text-black { color: black; }
.text-white { color: white; }
.rounded-full { border-radius: 9999px; }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); }
.cursor-ew-resize { cursor: ew-resize; }
.select-none { user-select: none; }
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }
.backdrop-blur { backdrop-filter: blur(8px); }
.backdrop-blur-md { backdrop-filter: blur(12px); }

/* Soporte para clases tipo Tailwind usadas en el HTML */
.bg-black\/50 { background-color: rgba(0, 0, 0, 0.5); }
.bg-black\/90 { background-color: rgba(0, 0, 0, 0.9); }
.border-white\/10 { border-color: rgba(255, 255, 255, 0.1); }
.border-white\/20 { border-color: rgba(255, 255, 255, 0.2); }
.border-white\/50 { border-color: rgba(255, 255, 255, 0.5); }

/* --- COMPATIBILIDAD SLIDER (Critico para Comparación) --- */
.left-1\/2 { left: 50%; }
.w-10 { width: 2.5rem; }
.-ml-5 { margin-left: -1.25rem; }
.bg-white\/50 { background-color: rgba(255, 255, 255, 0.5); }
.bg-white\/90 { background-color: rgba(255, 255, 255, 0.9); }
/* Escapamos los corchetes para soportar la clase generada por JS */
.shadow-\[0_0_5px_black\] { box-shadow: 0 0 5px #000; } 
.group:hover .group-hover\:scale-110 { transform: scale(1.1); }

/* --- COMPONENTES UI --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    gap: 8px;
    user-select: none;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover:not(:disabled) {
    background: #e0e0e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255,255,255,0.15);
}
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-secondary {
    background: var(--glass);
    color: var(--text-main);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover {
    color: var(--accent);
    background: rgba(255,255,255,0.02);
}

.input {
    width: 100%;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border);
    padding: 14px;
    color: #fff;
    border-radius: 8px;
    transition: 0.3s;
    font-family: var(--font-ui);
    font-size: 0.95rem;
}
.input:focus {
    border-color: var(--accent);
    background: rgba(255,255,255,0.08);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1);
}
textarea.input { resize: vertical; min-height: 80px; }

/* --- LOGIN --- */
.auth-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #111 0%, #000 100%);
    padding: 20px;
}
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 3rem;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.8);
}

/* --- LAYOUT --- */
.app-layout { max-width: 1400px; margin: 0 auto; padding: 20px 40px; }
header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 0; margin-bottom: 40px; border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--font-display); font-weight: 600; font-size: 1.5rem; letter-spacing: -0.03em; }

/* --- UPLOAD --- */
.upload-box {
    border: 2px dashed var(--border);
    padding: 5rem 2rem;
    text-align: center;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.01);
}
.upload-box:hover { border-color: var(--accent); background: rgba(255,255,255,0.03); transform: translateY(-2px); }

/* --- PREP --- */
.prep-item {
    display: flex; gap: 20px; background: var(--bg-panel); padding: 20px;
    border-radius: 12px; border: 1px solid var(--border); margin-bottom: 15px; align-items: flex-start;
}
.prep-thumb { width: 100px; height: 100px; border-radius: 8px; object-fit: cover; background: #000; }
.prep-content { flex: 1; }

/* --- GALLERY --- */
.gallery-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; margin-top: 30px;
}
.card {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px;
    overflow: hidden; position: relative; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.card:hover { border-color: var(--accent); transform: translateY(-6px); box-shadow: 0 12px 24px rgba(0,0,0,0.4); }
.card-img { width: 100%; height: 320px; object-fit: cover; background: #111; transition: opacity 0.3s ease; }
.status-badge {
    position: absolute; top: 12px; right: 12px; padding: 6px 10px; border-radius: 6px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(8px); border: 1px solid var(--border);
    letter-spacing: 0.5px; z-index: 10;
}
.st-analyzing { color: var(--processing); border-color: var(--processing); }
.st-restoring { color: var(--warning); border-color: var(--warning); }
.st-completed { color: var(--success); border-color: var(--success); }

/* --- TOAST --- */
#toast {
    position: fixed; top: 24px; right: 24px; z-index: 9999;
    background: #ffffff; color: #000; padding: 16px 24px; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); display: flex; align-items: center; gap: 12px;
    font-weight: 600; font-size: 0.9rem; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(0) scale(1); opacity: 1;
}
#toast.translate-y-\[-20px\] { transform: translateY(-20px) scale(0.95); }
#toast.opacity-0 { opacity: 0; pointer-events: none; }

/* --- MODAL --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px);
    z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
    animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background: #080808; border: 1px solid var(--border); width: 100%; max-width: 1400px;
    height: 90vh; border-radius: 20px; display: flex; overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}
.modal-visual {
    flex: 2; background: radial-gradient(circle at center, #111 0%, #000 100%);
    display: flex; align-items: center; justify-content: center; position: relative;
    border-right: 1px solid var(--border);
}
.modal-visual img { max-width: 100%; max-height: 100%; object-fit: contain; }

.modal-data {
    flex: 1; min-width: 380px; background: var(--bg-panel); padding: 2.5rem;
    display: flex; flex-direction: column; overflow-y: auto;
}
.data-block { margin-bottom: 2.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1.5rem; }
.data-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 0.75rem; font-weight: 600; }
.history-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.history-thumb {
    width: 64px; height: 64px; border-radius: 8px; border: 2px solid transparent;
    cursor: pointer; opacity: 0.5; transition: 0.2s; object-fit: cover;
}
.history-thumb:hover, .history-thumb.active { opacity: 1; border-color: var(--accent); transform: scale(1.05); }
.regen-hint-box {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    padding: 1.5rem; border-radius: 12px; margin-top: auto;
}

@media (max-width: 1024px) {
    .app-layout { padding: 15px; }
    .modal-content { flex-direction: column; height: 100%; border-radius: 0; border: none; }
    .modal-visual { height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
    .modal-data { height: 55vh; width: 100%; padding: 1.5rem; }
    .gallery-grid { grid-template-columns: 1fr; }
    #toast { top: auto; bottom: 20px; right: 20px; left: 20px; justify-content: center; }
    #toast.translate-y-\[-20px\] { transform: translateY(20px); }
}