/* =========================================
   1. VARIABLES DE SISTEMA (PALETA PREMIUM)
   ========================================= */
:root {
    /* Colores Base */
    --bg-main: #0f1015;
    --bg-card: #1e1f29;
    --bg-input: #2a2b36;
    
    /* Acentos IA */
    --accent-primary: #6366f1; /* Indigo Vibrante */
    --accent-secondary: #a855f7; /* Violeta Magia */
    --accent-gradient: linear-gradient(135deg, #6366f1, #ec4899);
    
    /* Textos */
    --text-high: #ffffff;
    --text-mid: #94a3b8;
    --text-low: #64748b;
    
    /* Estados */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #facc15;
    
    /* Efectos */
    --glass: rgba(30, 31, 41, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
}

/* =========================================
   2. RESET Y BASES FUNCIONALES
   ========================================= */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent; 
}

body {
    background-color: var(--bg-main);
    color: var(--text-high);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 90px; /* Espacio para nav flotante */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Clases de utilidad principales */
.hidden { display: none !important; }
.app-viewport { width: 100%; min-height: 100vh; }

/* Scrollbar oculta pero funcional */
::-webkit-scrollbar { width: 0px; background: transparent; }

h1, h2, h3 { font-family: 'Outfit', sans-serif; }
button { font-family: 'Inter', sans-serif; }

/* =========================================
   3. PANTALLA DE LOGIN (Full Screen)
   ========================================= */
.auth-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: radial-gradient(circle at top right, #2d1b4e, var(--bg-main));
    display: flex; justify-content: center; align-items: center;
    padding: 20px;
}

.auth-card {
    width: 100%; max-width: 380px;
    text-align: center;
    animation: fadeIn 0.8s ease-out;
}

.auth-logo {
    font-size: 3rem; margin-bottom: 10px;
    animation: float 3s ease-in-out infinite;
}

.auth-title {
    font-size: 2.5rem; letter-spacing: -1px; margin-bottom: 5px;
}
.auth-title span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-tagline { color: var(--text-mid); margin-bottom: 40px; font-size: 0.95rem; }

.btn-google {
    background: white; color: #1e293b;
    width: 100%; padding: 14px;
    border: none; border-radius: var(--radius-md);
    font-weight: 600; font-size: 1rem;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    cursor: pointer; transition: transform 0.2s;
}
.btn-google:active { transform: scale(0.98); }
.btn-google img { width: 24px; height: 24px; }

/* =========================================
   4. HEADER Y PERFIL
   ========================================= */
.main-header {
    padding: 20px 20px 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.header-content {
    width: 100%; max-width: 600px; margin: 0 auto;
    display: flex; justify-content: space-between; align-items: center;
}

.profile-area { display: flex; align-items: center; gap: 12px; }
.profile-avatar {
    width: 45px; height: 45px;
    background: var(--bg-card);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--glass-border);
    overflow: hidden;
}
.profile-text { display: flex; flex-direction: column; }
.profile-welcome { font-size: 0.75rem; color: var(--text-mid); }
.profile-name { font-weight: 700; font-size: 1rem; }

.global-actions { display: flex; gap: 10px; }

.btn-icon-round {
    width: 40px; height: 40px;
    border-radius: 50%; border: 1px solid var(--glass-border);
    background: var(--bg-card); color: var(--text-high);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    transition: transform 0.2s;
}
.btn-icon-round:active { transform: scale(0.95); }

body.dark-mode .icon-moon { display: none; }
body.dark-mode .icon-sun { display: inline-block; }
body.light-mode .icon-moon { display: inline-block; }
body.light-mode .icon-sun { display: none; }

/* =========================================
   5. CONTENEDOR DE VISTAS Y GRID
   ========================================= */
.view-container {
    width: 100%; max-width: 600px; margin: 0 auto;
    padding: 20px;
}

.view-header { margin-bottom: 25px; }
.header-titles { display: flex; flex-direction: column; }
.view-title { font-size: 1.8rem; margin-bottom: 5px; }
.view-subtitle { color: var(--text-mid); font-size: 0.9rem; }
.view-stats { margin-top: 15px; display: flex; gap: 10px; }
.stat-badge {
    background: var(--bg-card); border: 1px solid var(--glass-border);
    padding: 6px 12px; border-radius: 20px; font-size: 0.8rem;
    display: flex; gap: 6px;
}
.stat-value { font-weight: 700; color: var(--accent-primary); }

.search-filter-bar { margin-bottom: 20px; }
.search-box {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px 15px;
    border: 1px solid var(--glass-border);
    display: flex; align-items: center; gap: 10px;
}
.search-box input {
    background: transparent; border: none; color: inherit;
    width: 100%; outline: none; font-size: 0.95rem;
}

.garment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.garment-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    transition: transform 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Modificado para soportar imagen */
.card-visual {
    height: 130px; /* Un poco más alto para lucir la foto */
    width: 100%;
    position: relative;
    background-color: var(--bg-input); /* Fallback */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.garment-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.garment-card:hover .garment-img {
    transform: scale(1.05); /* Ligero zoom al pasar el ratón */
}

.btn-fav {
    position: absolute; top: 8px; right: 8px;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    border: none;
    color: white; width: 28px; height: 28px; border-radius: 50%;
    cursor: pointer; opacity: 0.8; z-index: 10;
    transition: all 0.2s;
}
.btn-fav.active { color: #fbbf24; opacity: 1; transform: scale(1.1); }

.card-content { padding: 12px; flex: 1; }
.card-content h3 { font-size: 0.95rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 0.75rem; color: var(--text-mid); margin-bottom: 8px; }

.card-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.card-tags span, .rain-tag {
    background: rgba(255,255,255,0.05); padding: 2px 6px;
    border-radius: 4px; font-size: 0.65rem; color: var(--text-mid);
}
.rain-tag { font-size: 0.75rem; background: transparent; padding: 0;}

.card-footer {
    padding: 10px 12px; border-top: 1px solid var(--glass-border);
    display: flex; gap: 8px;
}
.btn-action-sm {
    flex: 1; padding: 6px; border-radius: 6px; border: none;
    font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.btn-state { background: rgba(255,255,255,0.1); color: inherit; }
.btn-del { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.is-dirty { opacity: 0.6; filter: grayscale(0.8); border: 1px solid var(--danger); }

/* =========================================
   6. FORMULARIOS Y UPLOAD (Vista Añadir)
   ========================================= */
.glass-form {
    background: var(--bg-card);
    padding: 20px; border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
}
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

label { display: block; font-size: 0.85rem; color: var(--text-mid); margin-bottom: 8px; }

input[type="text"], input[type="number"], select, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    padding: 12px; border-radius: var(--radius-sm);
    color: inherit; outline: none;
    font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-primary); }

/* --- NUEVO: ESTILOS PARA SUBIR FOTO --- */
.image-upload-wrapper {
    position: relative;
    width: 100%;
    height: 160px;
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}
.image-upload-wrapper:hover { border-color: var(--accent-primary); background: rgba(99, 102, 241, 0.05); }
.image-upload-wrapper input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 10;
}
.upload-placeholder {
    text-align: center; color: var(--text-mid); pointer-events: none; padding: 10px;
}
.upload-icon { font-size: 2rem; margin-bottom: 8px; display: block; }
.upload-text { font-size: 0.85rem; font-weight: 500; color: var(--text-high); }
.upload-hint { font-size: 0.7rem; margin-top: 5px; }

.image-preview {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover; z-index: 5;
    display: none; /* Oculto por defecto */
}
/* -------------------------------------- */

.color-flex { display: flex; gap: 10px; align-items: center;}
#color-picker { height: 42px; width: 42px; padding: 2px; background: var(--bg-input); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); cursor: pointer; }

input[type=range] { -webkit-appearance: none; width: 100%; background: transparent; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background: var(--accent-primary); cursor: pointer; margin-top: -6px; }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; background: var(--bg-input); border-radius: 2px; }
.range-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-low); margin-bottom: 5px; }
.input-hint { font-size: 0.7rem; color: var(--text-low); margin-top: 5px; text-align: center; }

.shelf-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.shelf-chip input { display: none; }
.chip-content {
    background: var(--bg-input); padding: 8px 12px;
    border-radius: 20px; font-size: 0.8rem; cursor: pointer;
    border: 1px solid transparent; transition: 0.2s; user-select: none;
}
.shelf-chip input:checked + .chip-content { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }

.btn-main-action {
    width: 100%; padding: 16px; background: var(--accent-gradient);
    border: none; border-radius: var(--radius-md); color: white;
    font-weight: 700; font-size: 1rem; cursor: pointer; margin-top: 10px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); transition: opacity 0.2s;
}
.btn-main-action:active { opacity: 0.8; }
.btn-main-action:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================================
   7. IA STYLIST (Vista Mágica)
   ========================================= */
.ia-engine-box { text-align: center; }
.ia-header { margin-bottom: 30px; }

.ia-controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 25px; }
.control-item { background: var(--bg-card); padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--glass-border); text-align: left; }
.full-width-mobile { grid-column: span 2; }

.toggle-container { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: var(--bg-input); transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent-secondary); }
input:checked + .slider:before { transform: translateX(20px); }

.btn-ai-magic {
    width: 100%; padding: 18px; background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    background-size: 200% 200%; animation: gradientShift 5s ease infinite;
    border: none; border-radius: var(--radius-md); color: white; font-weight: 800; font-size: 1.1rem;
    cursor: pointer; position: relative; overflow: hidden;
}

.outfit-result-card { margin-top: 30px; background: var(--bg-card); border: 1px solid var(--accent-primary); border-radius: var(--radius-lg); padding: 20px; box-shadow: 0 0 30px rgba(99, 102, 241, 0.15); }
.ai-loader { padding: 20px; font-weight: 600; color: var(--accent-secondary); animation: float 1.5s infinite; }
.error-msg { color: var(--danger); font-weight: 500; padding: 10px; }
.outfit-card { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.outfit-part { background: rgba(255,255,255,0.03); padding: 12px; border-radius: var(--radius-sm); border-left: 3px solid var(--accent-primary); }

.ia-feedback { margin-top: 20px; }
.feedback-title { font-weight: 600; margin-bottom: 10px; }
.feedback-actions { display: flex; gap: 10px; justify-content: center; }
.btn-feedback { padding: 10px 20px; border-radius: 20px; border: none; cursor: pointer; font-weight: 600; transition: transform 0.2s; }
.btn-feedback:active { transform: scale(0.95); }
.positive { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.negative { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* =========================================
   8. BOTTOM NAV (Flotante)
   ========================================= */
.bottom-nav {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); width: 90%; max-width: 400px;
    background: rgba(30, 31, 41, 0.85); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border); height: 70px; border-radius: 35px;
    display: flex; justify-content: space-around; align-items: center; z-index: 1000; box-shadow: var(--shadow-card);
}
.nav-btn { background: none; border: none; color: var(--text-low); display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: color 0.3s; padding: 5px; }
.nav-btn.active { color: var(--text-high); }
.nav-icon { font-size: 1.4rem; margin-bottom: 2px; }
.nav-label { font-size: 0.7rem; font-weight: 600; }
.plus-circle { width: 55px; height: 55px; background: var(--accent-gradient); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: white; box-shadow: 0 5px 15px rgba(236, 72, 153, 0.4); transform: translateY(-20px); }

/* =========================================
   9. SECCIÓN COMUNIDAD (REVIEWS)
   ========================================= */
.review-overlay { position: absolute; bottom: 10px; left: 10px; padding: 4px 8px; border-radius: 20px; background: rgba(15, 16, 21, 0.65); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; gap: 8px; border: 1px solid rgba(255,255,255,0.1); }
.review-comment { font-size: 0.85rem; color: var(--text-mid); line-height: 1.4; font-style: italic; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--glass-border); }
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

/* =========================================
   10. ANIMACIONES
   ========================================= */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* =========================================
   11. LIGHT MODE OVERRIDES
   ========================================= */
body.light-mode { --bg-main: #f1f5f9; --bg-card: #ffffff; --bg-input: #f8fafc; --text-high: #1e293b; --text-mid: #64748b; --text-low: #94a3b8; --glass-border: rgba(0,0,0,0.08); }
body.light-mode .bottom-nav { background: rgba(255, 255, 255, 0.85); }