/* ============================================
   SPONGEBOOK - SHARED STYLES
   Brand Colors & Typography
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito+Sans:wght@400;500;600;700&display=swap');

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

:root {
    /* Brand Colors */
    --sponge-yellow: #FFD24A;
    --sponge-yellow-dark: #E5BC42;
    --sea-teal: #2EC4B6;
    --sea-teal-dark: #26A89C;
    --coral: #FF6B6B;
    --deep-ink: #1C1C1C;
    --soft-cream: #FFF7DA;
    --midnight: #0D1B2A;
    --white: #FFFFFF;

    /* Semantic aliases */
    --teal: var(--sea-teal);
    --teal-dark: var(--sea-teal-dark);
    --yellow: var(--sponge-yellow);
    --yellow-dark: var(--sponge-yellow-dark);
    --dark: var(--deep-ink);
    --gray: #666;
    --light-gray: var(--soft-cream);
    --border: #e0e0e0;
    --error: var(--coral);
    --success: #27ae60;
}

body {
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--soft-cream);
    color: var(--deep-ink);
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Fredoka', 'Nunito Sans', sans-serif;
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
    background: var(--white);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-logo img {
    height: 40px;
}

.nav-steps {
    display: flex;
    gap: 10px;
}

.step {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--gray);
    background: var(--light-gray);
}

.step.active {
    background: var(--sponge-yellow);
    color: var(--deep-ink);
    font-weight: 600;
}

.step.completed {
    background: var(--sea-teal);
    color: var(--white);
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

@media (max-width: 768px) {
    .container-wide {
        padding: 20px 12px;
    }
}

/* ============================================
   CREATE PAGE
   ============================================ */

.create-header {
    text-align: center;
    margin-bottom: 40px;
}

.create-header h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--gray);
    font-size: 1.1rem;
}

.create-form {
    background: var(--white);
    border-radius: 16px;
    padding: clamp(20px, 5vw, 40px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.form-section {
    margin-bottom: 30px;
}

.section-label {
    display: block;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.section-hint {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.prompt-input {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.3s;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--teal);
}

/* Voice Input Button */
.voice-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: white;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.voice-btn:hover {
    border-color: var(--teal);
    background: var(--teal-light, #e0f7f7);
}
.voice-btn.recording {
    border-color: #e74c3c;
    background: #fde8e8;
    animation: pulse-record 1.2s infinite;
}
@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
}

/* Mobile Upload Buttons */
.mobile-upload-buttons {
    display: none;
    gap: 10px;
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .mobile-upload-buttons {
        display: flex;
    }
}

.mobile-upload-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border: 2px solid var(--teal);
    border-radius: 10px;
    background: white;
    color: var(--teal);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.mobile-upload-btn:active {
    background: var(--teal);
    color: white;
}

.mobile-upload-btn .icon {
    font-size: 1.3rem;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

@media (max-width: 768px) {
    .upload-zone {
        padding: 25px 15px;
    }

    .upload-zone p {
        font-size: 0.9rem;
    }

    .upload-icon {
        font-size: 2rem;
    }
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--teal);
    background: rgba(61, 189, 180, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.upload-link {
    color: var(--teal);
    font-weight: 600;
}

.upload-hint {
    color: var(--gray);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Uploaded Images */
.uploaded-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.uploaded-image {
    position: relative;
    background: var(--light-gray);
    border-radius: 12px;
    overflow: hidden;
}

.uploaded-image img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.uploaded-image .character-name {
    width: 100%;
    padding: 10px;
    border: none;
    font-size: 0.9rem;
    text-align: center;
}

.uploaded-image .remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

/* Examples */
.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.example-card {
    background: var(--light-gray);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.example-card:hover {
    transform: translateY(-4px);
}

.example-cover {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--sea-teal) 0%, var(--sponge-yellow) 100%);
}

.example-title {
    padding: 12px;
    font-weight: 500;
    text-align: center;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--sponge-yellow) 0%, var(--sponge-yellow-dark) 100%);
    color: var(--deep-ink);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 210, 74, 0.45);
}

.btn-secondary {
    background: var(--light-gray);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-yellow {
    background: linear-gradient(135deg, var(--yellow) 0%, var(--yellow-dark) 100%);
    color: var(--dark);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--teal);
    color: var(--teal);
}

.btn-outline:hover {
    background: var(--teal);
    color: white;
}

.btn-large {
    width: 100%;
    padding: 18px;
    font-size: 1.1rem;
}

.btn-group {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

/* ============================================
   TITLE SELECTION PAGE
   ============================================ */

.title-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 30px 0;
}

.title-option {
    padding: 20px 25px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 15px;
}

.title-option:hover {
    border-color: var(--teal);
    background: rgba(61, 189, 180, 0.05);
}

.title-option.selected {
    border-color: var(--teal);
    background: rgba(61, 189, 180, 0.1);
}

.title-option input[type="radio"] {
    display: none;
}

.title-radio {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.title-option.selected .title-radio {
    border-color: var(--teal);
    background: var(--teal);
}

.title-option.selected .title-radio::after {
    content: '✓';
    color: white;
    font-size: 0.8rem;
}

.title-text {
    font-size: 1.2rem;
    font-weight: 500;
}

/* ============================================
   COVER APPROVAL PAGE
   ============================================ */

.cover-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

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

.cover-preview {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.cover-image {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.cover-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.cover-title {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
}

.cover-blurb {
    color: var(--gray);
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.6;
}

.story-preview {
    background: var(--white);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.story-preview h3 {
    margin-bottom: 20px;
}

.page-list {
    max-height: 400px;
    overflow-y: auto;
}

.page-item {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.page-item:last-child {
    border-bottom: none;
}

.page-number {
    font-weight: 600;
    color: var(--teal);
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.page-text {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ============================================
   PAGES REVIEW
   ============================================ */

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.page-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.page-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.page-card.selected {
    outline: 3px solid var(--error);
}

.page-card .page-image {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.page-card .page-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.page-card .page-info {
    padding: 12px;
}

.page-card .page-num {
    font-weight: 700;
    color: var(--teal);
}

.page-card .select-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-card.selected .select-overlay {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.regen-bar {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.regen-info {
    color: var(--gray);
}

.regen-count {
    font-weight: 700;
    color: var(--error);
}

/* ============================================
   COMPLETE PAGE
   ============================================ */

.complete-container {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.complete-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.complete-container h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.complete-container .subtitle {
    margin-bottom: 40px;
}

.book-preview {
    background: var(--white);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.book-preview .cover-image {
    max-width: 300px;
    margin: 0 auto 20px;
}

.download-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
}

.print-cta {
    background: linear-gradient(135deg, var(--yellow) 0%, var(--yellow-dark) 100%);
    padding: 25px;
    border-radius: 12px;
    margin-top: 20px;
}

.print-cta h3 {
    margin-bottom: 10px;
}

.print-cta p {
    margin-bottom: 15px;
    color: var(--dark);
}

/* ============================================
   LOADING STATE
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top-color: var(--sponge-yellow);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Interactive Sponge Logo */
.sponge-chase {
    position: absolute;
    width: 120px;
    height: 120px;
    transition: transform 0.15s ease-out;
    cursor: pointer;
    z-index: 1001;
    pointer-events: none;
}

.sponge-chase img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: sponge-wobble 2s ease-in-out infinite;
}

@keyframes sponge-wobble {
    0%, 100% { transform: rotate(-5deg) scale(1); }
    25% { transform: rotate(5deg) scale(1.05); }
    50% { transform: rotate(-3deg) scale(1); }
    75% { transform: rotate(4deg) scale(1.02); }
}

.loading-text {
    margin-top: 20px;
    font-size: 1.2rem;
    color: var(--gray);
}

.loading-subtext {
    color: var(--gray);
    font-size: 0.9rem;
    margin-top: 8px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .nav-steps {
        flex-wrap: wrap;
        justify-content: center;
    }

    .step {
        font-size: 0.75rem;
        padding: 6px 12px;
    }

    .btn-group {
        flex-direction: column;
    }
}
