/* ============================================
   Disegna con Sofia - CSS
   Playful, colorful, super simple for kids
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

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

:root {
    --pink: #F0A3B3;
    --pink-dark: #E88FA0;
    --purple: #9B8EC4;
    --yellow: #FFD93D;
    --blue: #87CEEB;
    --mint: #98D4BB;
    --orange: #FFB347;
    --coral: #FF7F7F;
    --text: #3D2C5E;
    --text-light: #8B7BA8;
    --white: #FFFFFF;
    --bg: linear-gradient(160deg, #FFF0F5 0%, #F0E6FF 40%, #E6F0FF 100%);
    --radius: 20px;
    --shadow: 0 8px 32px rgba(240, 163, 179, 0.2);
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Decorative background --- */
.deco-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.paint-splat {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    filter: blur(40px);
}
.splat-1 { width: 300px; height: 300px; background: var(--pink); top: -50px; left: -50px; }
.splat-2 { width: 250px; height: 250px; background: var(--blue); top: 30%; right: -80px; }
.splat-3 { width: 200px; height: 200px; background: var(--yellow); bottom: 10%; left: 10%; }
.splat-4 { width: 350px; height: 350px; background: var(--purple); bottom: -100px; right: 20%; }

/* --- Header --- */
.draw-header {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(20px);
    border-bottom: 3px solid rgba(240, 163, 179, 0.15);
}
.back-link {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-light);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.3s;
}
.back-link:hover { background: rgba(240, 163, 179, 0.1); color: var(--pink-dark); }
.back-link svg { width: 20px; height: 20px; }

.header-title {
    display: flex; align-items: center; gap: 8px; flex: 1;
}
.header-icon { font-size: 24px; }
.header-title h1 { font-size: 20px; font-weight: 900; color: var(--pink-dark); }

.header-right { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 13px; color: var(--text-light); font-weight: 600; }
.btn-sm-outline {
    font-family: inherit; font-size: 12px; font-weight: 700;
    color: var(--pink); background: none;
    border: 2px solid var(--pink); padding: 5px 14px;
    border-radius: 20px; text-decoration: none; transition: all 0.3s;
}
.btn-sm-outline:hover { background: var(--pink); color: white; }

/* --- Main --- */
.draw-main {
    position: relative; z-index: 5;
    max-width: 700px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

/* --- Sofia Guide --- */
.sofia-guide {
    display: flex; align-items: flex-start; gap: 14px;
    background: white;
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 2px solid rgba(240, 163, 179, 0.15);
}
.sofia-avatar-draw {
    flex-shrink: 0;
    animation: bob 3s ease-in-out infinite;
}
@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
.sofia-speech {
    flex: 1;
}
.sofia-speech p {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.5;
    transition: opacity 0.3s;
}

/* --- Draw Panel --- */
.draw-panel {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 2px solid rgba(240, 163, 179, 0.1);
}

.prompt-label {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    display: block;
}

.prompt-input {
    width: 100%;
    padding: 14px 16px;
    border: 3px solid rgba(240, 163, 179, 0.25);
    border-radius: 16px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    resize: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: #FFFBFC;
}
.prompt-input:focus {
    outline: none;
    border-color: var(--pink);
    box-shadow: 0 0 0 4px rgba(240, 163, 179, 0.15);
}
.prompt-input::placeholder { color: #C4A8B8; }

.char-count {
    text-align: right;
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
    margin-bottom: 16px;
}

/* --- Style selector --- */
.style-section { margin-bottom: 20px; }
.style-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.style-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: 3px solid rgba(240, 163, 179, 0.15);
    border-radius: 14px;
    background: #FFFBFC;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
}
.style-btn:hover { border-color: var(--pink); background: #FFF5F7; }
.style-btn.active {
    border-color: var(--pink);
    background: linear-gradient(135deg, #FFF0F3, #FFE0E8);
    box-shadow: 0 4px 15px rgba(240, 163, 179, 0.25);
    transform: scale(1.03);
}
.style-icon { font-size: 26px; line-height: 1; }
.style-name { font-size: 12px; font-weight: 800; color: var(--text); }

/* --- Generate button --- */
.generate-btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: 18px;
    background: linear-gradient(135deg, #F06292, #E91E63, #AD1457);
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 6px 25px rgba(233, 30, 99, 0.35);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}
.generate-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}
.generate-btn:hover::before { transform: translateX(100%); }
.generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 35px rgba(233, 30, 99, 0.4);
}
.generate-btn:active { transform: translateY(-1px); }
.generate-btn:disabled {
    background: #D1C4E9;
    box-shadow: none;
    cursor: wait;
    transform: none;
}
.btn-content { display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-icon { font-size: 24px; }
.btn-text { font-size: 20px; font-weight: 900; letter-spacing: 1px; }

/* --- Result area --- */
.result-area {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 2px solid rgba(240, 163, 179, 0.1);
    text-align: center;
}

/* Loading */
.loading-state { padding: 30px 0; }
.magic-loader {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
}
.loader-brush {
    font-size: 40px;
    animation: paint-wobble 1.5s ease-in-out infinite;
}
@keyframes paint-wobble {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(15deg); }
}
.loader-stars {
    position: absolute;
    top: -5px; right: -10px;
    display: flex;
    gap: 4px;
}
.loader-stars span {
    font-size: 16px;
    animation: star-pop 1s ease-in-out infinite;
}
.loader-stars span:nth-child(2) { animation-delay: 0.3s; }
.loader-stars span:nth-child(3) { animation-delay: 0.6s; }
@keyframes star-pop {
    0%, 100% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.3); opacity: 1; }
}

.loading-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--pink-dark);
    margin-bottom: 16px;
}
.loading-bar {
    width: 80%;
    max-width: 300px;
    height: 10px;
    background: #F5E6EA;
    border-radius: 5px;
    margin: 0 auto;
    overflow: hidden;
}
.loading-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pink), var(--purple), var(--pink));
    background-size: 200% 100%;
    border-radius: 5px;
    width: 0%;
    transition: width 0.5s ease;
    animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Result image */
.result-image-wrap { animation: reveal 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes reveal {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.result-image {
    width: 100%;
    max-width: 512px;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    border: 4px solid rgba(240, 163, 179, 0.2);
}
.result-prompt {
    font-size: 14px;
    font-style: italic;
    color: var(--text-light);
    margin: 12px 0 16px;
}
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.action-btn {
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s;
}
.download-btn {
    background: var(--mint);
    color: #2D5E4A;
}
.download-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }
.print-btn {
    background: var(--blue);
    color: #2A5B7A;
}
.print-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }
.new-btn {
    background: var(--pink);
    color: white;
}
.new-btn:hover { filter: brightness(1.1); transform: translateY(-2px); }

/* --- Gallery --- */
.gallery-section {
    margin-top: 10px;
}
.gallery-title {
    font-size: 20px;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 16px;
}
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.gallery-item {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    aspect-ratio: 1;
    transition: all 0.3s;
    cursor: pointer;
}
.gallery-item:hover { transform: translateY(-4px); box-shadow: 0 8px 25px rgba(0,0,0,0.12); }
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, transparent 60%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 10px;
    opacity: 0;
    transition: opacity 0.3s;
}
.gallery-item:hover .gallery-overlay { opacity: 1; }
.gallery-prompt {
    font-size: 11px;
    color: white;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.gallery-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,0.9);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-delete:hover { background: #E74C3C; color: white; transform: scale(1.1); }

/* --- Login page --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-card {
    background: white;
    border-radius: 28px;
    padding: 48px 40px;
    text-align: center;
    box-shadow: 0 16px 50px rgba(240, 163, 179, 0.25);
    max-width: 400px;
    width: 100%;
    border: 3px solid rgba(240, 163, 179, 0.15);
}
.login-sofia { margin-bottom: 20px; }
.login-card h1 {
    font-size: 28px;
    font-weight: 900;
    color: var(--pink-dark);
    margin-bottom: 10px;
}
.login-card p {
    font-size: 15px;
    color: var(--text-light);
    margin-bottom: 28px;
    line-height: 1.5;
}
.btn-login {
    display: inline-block;
    font-family: inherit;
    font-size: 16px;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, var(--pink), var(--pink-dark));
    padding: 14px 36px;
    border-radius: 18px;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 6px 20px rgba(240, 163, 179, 0.35);
}
.btn-login:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(240, 163, 179, 0.4); }

/* --- Responsive --- */
@media (max-width: 600px) {
    .style-grid { grid-template-columns: repeat(2, 1fr); }
    .draw-panel { padding: 16px; }
    .sofia-guide { flex-direction: column; align-items: center; text-align: center; }
    .header-title h1 { font-size: 16px; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .btn-text { font-size: 17px; }
}

/* --- Global Navigation Bar --- */
.global-nav {
    background: #1F313F;
    padding: 0;
    position: relative;
    z-index: 10500;
}
.gnav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}
.gnav-brand {
    font-family: "Nunito", sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    padding: 8px 0;
    white-space: nowrap;
    opacity: 0.9;
}
.gnav-brand:hover { opacity: 1; }
.gnav-links {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.gnav-links::-webkit-scrollbar { display: none; }
.gnav-link {
    font-family: "Nunito", sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    padding: 8px 12px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.gnav-link:hover { color: #fff; background: rgba(255,255,255,0.05); }
.gnav-active { color: #fff; border-bottom-color: #25ADDA; }
@media (max-width: 600px) {
    .gnav-brand { display: none; }
    .gnav-inner { justify-content: center; }
    .gnav-link { font-size: 11px; padding: 8px 8px; }
}

