/* ============================================
   MARCOS Y MARCOS - Cotizador de Marcos
   Design System: Dark Elegance + Glassmorphism
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;600;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-glass: rgba(255, 255, 255, 0.06);
    --bg-glass-hover: rgba(255, 255, 255, 0.1);
    --border-glass: rgba(255, 255, 255, 0.08);

    --text-primary: #f0ece2;
    --text-secondary: #a09c94;
    --text-muted: #6b6860;

    --accent-gold: #d4af37;
    --accent-gold-light: #e8cc6e;
    --accent-gold-dark: #a38829;
    --accent-green-wa: #25d366;
    --accent-green-wa-hover: #1eba56;

    --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(212, 175, 55, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(212, 175, 55, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* =====================
   ONBOARDING OVERLAY
   ===================== */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease;
}

.onboarding-overlay.hidden {
    display: none;
}

.onboarding-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
}

.onboarding-modal {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 28, 0.98));
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(212, 175, 55, 0.08);
}

.onboarding-steps-indicator {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-glass);
    transition: all 0.3s;
}

.step-dot.active {
    background: var(--accent-gold);
    width: 24px;
    border-radius: 4px;
}

.onboarding-slide {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    min-height: 180px;
    justify-content: center;
}

.onboarding-slide.active {
    display: flex;
    animation: slideIn 0.35s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: bounce 2s ease infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.onboarding-slide h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    background: linear-gradient(135deg, var(--accent-gold-light), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.onboarding-slide p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 320px;
    line-height: 1.5;
}

.onboarding-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
}

.onb-btn {
    padding: 0.6rem 1.5rem;
    border-radius: 50px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.onb-skip {
    background: transparent;
    color: var(--text-muted);
}

.onb-skip:hover {
    color: var(--text-secondary);
}

.onb-next {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
    color: #000;
}

.onb-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.3);
}

/* =====================
   HEADER
   ===================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    background: rgba(10, 10, 15, 0.8);
    border-bottom: 1px solid var(--border-glass);
    padding: 0.6rem 1.5rem;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-brand .logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.header-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-gold-light), var(--accent-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* =====================
   LAYOUT: Preview left, controls right
   ===================== */
.app-layout {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
    min-height: calc(100vh - 60px);
}

/* =====================
   SIDEBAR (Controls) - now on the RIGHT
   ===================== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-right: 0.25rem;
    order: 2;
}

.sidebar::-webkit-scrollbar {
    width: 3px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

/* =====================
   CARDS
   ===================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem;
    backdrop-filter: blur(10px);
    transition: var(--transition);
    animation: fadeIn 0.4s ease forwards;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-title .icon {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Card row for side-by-side cards */
.card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.card-half {
    padding: 0.85rem;
}

/* =====================
   UPLOAD ZONE
   ===================== */
.upload-zone {
    border: 2px dashed var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 1.25rem 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.upload-zone:hover {
    border-color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.05);
}

.upload-zone.has-image {
    padding: 0.5rem;
    border-style: solid;
    border-color: var(--accent-gold);
}

.upload-zone .upload-icon {
    font-size: 2rem;
    margin-bottom: 0.3rem;
    opacity: 0.6;
}

.upload-zone .upload-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.upload-zone .upload-text strong {
    color: var(--accent-gold);
}

.upload-zone input[type="file"] {
    display: none;
}

.upload-preview-thumb {
    width: 100%;
    max-height: 120px;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.btn-change-photo {
    display: inline-block;
    margin-top: 0.4rem;
    font-size: 0.65rem;
    color: var(--accent-gold);
    cursor: pointer;
    text-decoration: underline;
}

/* =====================
   SELECT & INPUTS
   ===================== */
.form-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.form-select {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a09c94' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    padding-right: 1.75rem;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* =====================
   RANGE SLIDER
   ===================== */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.slider-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 20px;
}

input[type="range"] {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-glass);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-gold-light), var(--accent-gold));
    cursor: grab;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
    transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-gold-light), var(--accent-gold));
    cursor: grab;
}

/* =====================
   IMAGE GRID SELECTOR
   ===================== */
.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 0.2rem;
}

#moldura-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    max-height: 240px;
}

.image-grid::-webkit-scrollbar {
    width: 3px;
}

.image-grid::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

.grid-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.grid-item:hover {
    border-color: rgba(212, 175, 55, 0.4);
    transform: scale(1.05);
}

.grid-item.active {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.grid-item.active::after {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: var(--accent-gold);
    color: #000;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-item .item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.15rem 0.25rem;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.5rem;
    text-align: center;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: var(--accent-gold);
    font-size: 0.6rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    z-index: 2;
}

/* =====================
   TOGGLE SWITCH
   ===================== */
.toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.toggle-label .toggle-hint {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--bg-glass);
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    transition: var(--transition);
    cursor: pointer;
}

.toggle-track::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked+.toggle-track {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--accent-gold);
}

.toggle input:checked+.toggle-track::before {
    transform: translateX(20px);
    background: var(--accent-gold);
}

/* =====================
   PREVIEW PANEL - now on the LEFT, sticky
   ===================== */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 1.5rem 2rem 2rem;
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    backdrop-filter: blur(10px);
    order: 1;
}

.preview-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.25rem;
}

.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* =====================
   FRAME PREVIEW - New architecture:
   border = moldura, padding + bg = marialuisa, content = photo
   ===================== */
.frame-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Moldura = border */
    border: 22px solid #333;
    /* Marialuisa = padding + background */
    padding: 15px;
    background-color: #eee;
    background-size: cover;
    background-position: center;
    /* Shadow for depth */
    box-shadow: var(--shadow-soft), 4px 4px 20px rgba(0, 0, 0, 0.5);
    transition: border-color 0.3s ease, padding 0.3s ease, background-color 0.3s ease;
    line-height: 0;
}

.preview-photo {
    display: block;
    object-fit: cover;
    background: #1a1a1a;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    color: var(--text-muted);
    gap: 0.5rem;
    line-height: 1.5;
}

.preview-placeholder .placeholder-icon {
    font-size: 2.5rem;
    opacity: 0.4;
}

.preview-placeholder .placeholder-text {
    font-size: 0.75rem;
    text-align: center;
    max-width: 150px;
}

/* Corner overlay: real moldura photo overlaid on the preview */
.preview-container {
    position: relative;
}

.corner-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 140px;
    height: auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.15);
    z-index: 10;
    background: #fff;
    transition: transform 0.3s ease;
}

.corner-overlay:hover {
    transform: scale(1.5);
    z-index: 20;
}

.corner-overlay-label {
    position: absolute;
    bottom: 10px;
    left: 158px;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    z-index: 10;
}

.corner-overlay-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Config summary */
.config-summary {
    margin-top: 1.25rem;
    width: 100%;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
}

.config-summary h3 {
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.6rem;
}

.config-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.config-list li {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.config-list li:last-child {
    border-bottom: none;
}

.config-list .config-label {
    color: var(--text-secondary);
}

.config-list .config-value {
    color: var(--text-primary);
    font-weight: 500;
}

/* =====================
   WHATSAPP BUTTON
   ===================== */
.wa-btn-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
}

.wa-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.5rem;
    background: var(--accent-green-wa);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.3);
}

.wa-btn:hover {
    background: var(--accent-green-wa-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(37, 211, 102, 0.4);
}

.wa-btn .wa-icon {
    font-size: 1.2rem;
}

.wa-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(37, 211, 102, 0.3);
    }

    50% {
        box-shadow: 0 4px 30px rgba(37, 211, 102, 0.5);
    }
}

.wa-btn.ready {
    animation: pulse 2s infinite;
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        padding: 0.75rem;
    }

    .preview-panel {
        position: static;
        order: -1;
        max-height: none;
        padding: 1rem;
    }

    .sidebar {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
        order: 1;
    }

    .preview-photo,
    .preview-placeholder {
        width: 200px;
        height: 260px;
    }

    .wa-btn-container {
        bottom: 0.75rem;
        right: 0.75rem;
        left: 0.75rem;
    }

    .wa-btn {
        width: 100%;
        justify-content: center;
    }

    .card-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {

    .preview-photo,
    .preview-placeholder {
        width: 160px;
        height: 210px;
    }

    .frame-preview {
        border-width: 16px !important;
    }

    .card-row {
        grid-template-columns: 1fr;
    }
}

/* =====================
   ANIMATIONS
   ===================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}