/* ============================================
   Cromavo - Modern Dark Theme
   ============================================ */

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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-card-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f0ece4;
    --text-secondary: rgba(240, 236, 228, 0.6);
    --text-tertiary: rgba(240, 236, 228, 0.35);
    --accent: #E8B4B8;
    --accent2: #B8D4E8;
    --accent3: #D4E8B8;
    --accent4: #E8D4B8;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --transition-fast: 0.2s ease;
    --transition: 0.3s ease;
}

html {
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Subtle background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(232, 180, 184, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(184, 212, 232, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(212, 232, 184, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============ Header ============ */
.header {
    text-align: center;
    padding: 48px 0 32px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 8px;
}

.lang-switcher {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
}

.lang-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-tertiary);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    letter-spacing: 0.5px;
}

.lang-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-hover);
}

.lang-btn.active {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.logo-icon svg {
    width: 40px;
    height: 40px;
}

.logo h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -0.5px;
}

.logo h1 span {
    font-weight: 700;
}

.tagline {
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============ Main ============ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 32px;
    padding-bottom: 48px;
}

/* ============ Upload Section ============ */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

.upload-area {
    width: 100%;
    max-width: 600px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 64px 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(232, 180, 184, 0.05), transparent 70%);
    opacity: 0;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.upload-area:hover::before,
.upload-area.dragover::before {
    opacity: 1;
}

.upload-content {
    position: relative;
    z-index: 1;
}

.upload-icon {
    margin-bottom: 20px;
}

.upload-icon svg {
    width: 64px;
    height: 64px;
    color: var(--text-tertiary);
    transition: var(--transition);
}

.upload-area:hover .upload-icon svg {
    color: var(--accent);
}

.upload-area h2 {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-weight: 400;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-hint {
    margin-top: 8px;
    color: var(--text-tertiary) !important;
    font-size: 12px !important;
}

/* ============ Preview ============ */
.preview-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: fadeInUp 0.5s ease;
}

.preview-wrapper img {
    display: block;
    max-width: 100%;
    max-height: 500px;
}

.btn-remove {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-remove:hover {
    background: rgba(220, 60, 60, 0.8);
    transform: scale(1.1);
}

/* ============ Zone Overlays on Preview ============ */
.preview-wrapper {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    user-select: none;
    -webkit-user-select: none;
    max-width: 100%;
    width: fit-content;
}

.zone-overlay {
    position: absolute;
    cursor: grab;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: box-shadow 0.15s ease;
}

.zone-overlay:hover {
    box-shadow: 0 0 0 1px rgba(255,255,255,0.2);
}

.zone-overlay.dragging-move {
    cursor: grabbing;
}

.zone-overlay-top {
    background: rgba(232, 180, 184, 0.28);
    border-color: rgba(232, 180, 184, 0.55);
}

.zone-overlay-bottom {
    background: rgba(184, 212, 232, 0.28);
    border-color: rgba(184, 212, 232, 0.55);
}

.zone-overlay-shoes {
    background: rgba(212, 232, 184, 0.28);
    border-color: rgba(212, 232, 184, 0.55);
}

.zone-overlay-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 3px;
    pointer-events: none;
    white-space: nowrap;
}

.zone-overlay-top .zone-overlay-label {
    background: rgba(232, 180, 184, 0.75);
    color: #1a1a1a;
}

.zone-overlay-bottom .zone-overlay-label {
    background: rgba(184, 212, 232, 0.75);
    color: #1a1a1a;
}

.zone-overlay-shoes .zone-overlay-label {
    background: rgba(212, 232, 184, 0.75);
    color: #1a1a1a;
}

/* Edge handles for resize – desktop */
.zone-handle {
    position: absolute;
    z-index: 10;
}

.zone-handle-n, .zone-handle-s {
    left: -4px;
    right: -4px;
    height: 14px;
    cursor: ns-resize;
}

.zone-handle-n { top: -7px; }
.zone-handle-s { bottom: -7px; }

.zone-handle-w, .zone-handle-e {
    top: -4px;
    bottom: -4px;
    width: 14px;
    cursor: ew-resize;
}

.zone-handle-w { left: -7px; }
.zone-handle-e { right: -7px; }

/* Visible pill-shaped grip on each edge */
.zone-handle::after {
    content: '';
    position: absolute;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.zone-handle-n::after, .zone-handle-s::after {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 5px;
}

.zone-handle-w::after, .zone-handle-e::after {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 5px;
    height: 32px;
}

.zone-handle:hover::after {
    opacity: 1;
}

/* Corner dots */
.zone-corner {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 3px rgba(0,0,0,0.35);
    pointer-events: none;
    z-index: 12;
    display: none;
}
.zc-nw { top: -4px; left: -4px; }
.zc-ne { top: -4px; right: -4px; }
.zc-sw { bottom: -4px; left: -4px; }
.zc-se { bottom: -4px; right: -4px; }

@media (pointer: coarse) {
    .zone-corner {
        display: block;
        width: 12px;
        height: 12px;
    }
    .zc-nw { top: -6px; left: -6px; }
    .zc-ne { top: -6px; right: -6px; }
    .zc-sw { bottom: -6px; left: -6px; }
    .zc-se { bottom: -6px; right: -6px; }
}

/* ---- Touch / mobile: always visible, bigger targets ---- */
@media (pointer: coarse) {
    .zone-overlay {
        border-width: 3px;
    }

    .zone-handle-n, .zone-handle-s {
        height: 30px;
    }
    .zone-handle-n { top: -15px; }
    .zone-handle-s { bottom: -15px; }

    .zone-handle-w, .zone-handle-e {
        width: 30px;
    }
    .zone-handle-w { left: -15px; }
    .zone-handle-e { right: -15px; }

    /* Always show grips on touch (no hover) */
    .zone-handle::after {
        opacity: 1;
    }

    .zone-handle-n::after, .zone-handle-s::after {
        width: 44px;
        height: 6px;
        border-radius: 3px;
    }

    .zone-handle-w::after, .zone-handle-e::after {
        width: 6px;
        height: 44px;
        border-radius: 3px;
    }

    .zone-overlay-label {
        font-size: 12px;
        padding: 4px 12px;
        border-radius: 4px;
    }

    .zone-drag-hint {
        font-size: 13px;
    }
}

.zone-drag-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: -8px;
}

/* ============ Generate Button ============ */
.btn-generate {
    width: 100%;
    align-self: stretch;
    padding: 16px 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #c49ca0);
    color: #1a1a1a;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    letter-spacing: 0.3px;
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(232, 180, 184, 0.3);
}

.btn-generate:active {
    transform: translateY(0);
}

/* ============ Loading ============ */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 80px 0;
    animation: fadeIn 0.3s ease;
}

.loading-spinner {
    position: relative;
    width: 80px;
    height: 80px;
}

.watercolor-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(8px);
    animation: blobPulse 2s ease-in-out infinite;
}

.blob1 {
    width: 40px;
    height: 40px;
    background: var(--accent);
    top: 0;
    left: 20px;
    opacity: 0.6;
    animation-delay: 0s;
}

.blob2 {
    width: 35px;
    height: 35px;
    background: var(--accent2);
    bottom: 5px;
    left: 5px;
    opacity: 0.6;
    animation-delay: 0.4s;
}

.blob3 {
    width: 35px;
    height: 35px;
    background: var(--accent3);
    bottom: 5px;
    right: 5px;
    opacity: 0.6;
    animation-delay: 0.8s;
}

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 0.5px;
}

/* ============ Result Section ============ */
.result-section {
    animation: fadeInUp 0.6s ease;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.result-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    font-weight: 400;
}

.result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-action {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.btn-action--primary {
    background: rgba(232, 180, 184, 0.12);
    border-color: rgba(232, 180, 184, 0.3);
    color: var(--accent);
}

.btn-action:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.btn-action--primary:hover {
    background: rgba(232, 180, 184, 0.2);
    border-color: rgba(232, 180, 184, 0.5);
}

.action-divider {
    width: 1px;
    align-self: stretch;
    background: var(--border);
    margin: 0 2px;
}

.btn-social {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    padding: 0;
}

.btn-social:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

#btnWhatsapp:hover {
    color: #25D366;
    border-color: rgba(37, 211, 102, 0.4);
    background: rgba(37, 211, 102, 0.08);
}

#btnPinterest:hover {
    color: #E60023;
    border-color: rgba(230, 0, 35, 0.4);
    background: rgba(230, 0, 35, 0.08);
}

#btnTwitter:hover {
    color: #f0ece4;
    border-color: rgba(240, 236, 228, 0.3);
    background: rgba(240, 236, 228, 0.08);
}

#btnFacebook:hover {
    color: #1877F2;
    border-color: rgba(24, 119, 242, 0.4);
    background: rgba(24, 119, 242, 0.08);
}

/* ============ Style Card Canvas ============ */
.stylecard-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.stylecard-wrapper canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* ============ Color Details ============ */
.color-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

.color-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.color-section h3 {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.complement-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    margin-top: -6px;
}

.palette-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.color-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.color-chip:hover {
    transform: translateY(-2px);
}

.color-swatch {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-xs);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.color-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 30%, rgba(255,255,255,0.15), transparent 60%);
}

.color-hex {
    font-size: 10px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.color-name {
    font-size: 10px;
    color: var(--text-tertiary);
    text-align: center;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============ Harmony Info ============ */
.harmony-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.harmony-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(232, 180, 184, 0.1);
    border: 1px solid rgba(232, 180, 184, 0.15);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
}

.harmony-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============ Footer ============ */
.footer {
    text-align: center;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.footer p {
    font-size: 12px;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}

/* ============ Animations ============ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blobPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.3); opacity: 0.3; }
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .header {
        padding: 32px 0 24px;
    }

    .header-top {
        flex-direction: column;
        gap: 12px;
    }

    .lang-switcher {
        position: static;
        transform: none;
    }

    .logo h1 {
        font-size: 22px;
    }

    .upload-area {
        padding: 48px 24px;
    }

    .color-details {
        grid-template-columns: 1fr;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        justify-content: flex-start;
    }

    .btn-social {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .app {
        padding: 0 16px;
    }

    .logo h1 {
        font-size: 20px;
    }

    .tagline {
        font-size: 11px;
    }
}

/* ============ Legal Pages ============ */
a.logo {
    text-decoration: none;
    color: inherit;
}

a.logo:hover {
    opacity: 0.8;
}

.legal-header .header-top {
    margin-bottom: 0;
}

.lang-switcher a.lang-btn {
    text-decoration: none;
    display: inline-block;
}

.footer a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer a:hover {
    color: var(--accent);
}

.legal-page {
    max-width: 720px;
    margin: 0 auto;
    padding-bottom: 48px;
}

.legal-page h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 400;
    margin-bottom: 24px;
}

.legal-page h2 {
    font-size: 18px;
    font-weight: 600;
    margin-top: 28px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.legal-page h3 {
    font-size: 15px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.legal-page p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 10px;
}

.legal-page ul {
    margin: 8px 0 12px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.legal-page a {
    color: var(--accent);
    text-decoration: none;
}

.legal-page a:hover {
    text-decoration: underline;
}

.legal-page em {
    color: var(--text-tertiary);
}

/* ============ SEO Content ============ */
.seo-content {
    margin-top: 16px;
    padding: 48px 0 32px;
    border-top: 1px solid var(--border);
}

.seo-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    font-weight: 400;
    text-align: center;
    margin-bottom: 32px;
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.seo-step {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 24px;
    text-align: center;
}

.seo-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(232, 180, 184, 0.12);
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.seo-step h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.seo-step p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.seo-about {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

.seo-about h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.seo-about p {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.7;
}

@media (max-width: 768px) {
    .seo-grid {
        grid-template-columns: 1fr;
    }
}

/* ============ Footer Legal ============ */
.footer-legal {
    margin-top: 8px;
    font-size: 12px;
}

.footer-legal a {
    color: var(--text-tertiary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.footer-legal a:hover {
    color: var(--accent);
}

/* ============ Toast ============ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 12px 20px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    z-index: 1000;
    transition: transform 0.3s ease;
    backdrop-filter: blur(20px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}
