/* Color Variables */
:root {
    --purple-dark: #2A0D3B;
    --purple-mid: #3B0F5A;
    --light-blue: #76D7FF;
    --accent-light: #E9D9FF;
    --muted-text: #9AA0A6;
    --white: #FFFFFF;
    --error-red: #FF4444;
}

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

body {
    font-family: 'Lexend', sans-serif;
    color: var(--white);
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* Background Container */
#background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

/* Text Shadow for All Text */
h1, h2, h3, p, label, button, input, textarea, select, span, li, a {
    text-shadow: 0 0 40px var(--purple-dark);
}

/* Sidebar */
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: rgba(42, 13, 59, 0.85);
    backdrop-filter: blur(10px);
    padding: 20px;
    overflow-y: auto;
    z-index: 100;
    border-right: 2px solid rgba(118, 215, 255, 0.3);
}

#sidebar h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--light-blue);
}

#stories-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stories-empty-state {
    color: #888;
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
    line-height: 1.5;
}

.story-item {
    background: rgba(233, 217, 255, 0.1);
    border: 1px solid rgba(233, 217, 255, 0.3);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.story-item:hover {
    background: rgba(233, 217, 255, 0.2);
    transform: translateY(-2px);
}

.story-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--light-blue);
    text-transform: capitalize;
}

.story-item-preview {
    font-size: 0.75rem;
    color: var(--accent-light);
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-item-btn {
    background: var(--light-blue);
    color: var(--purple-dark);
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: none;
}

.story-item-btn:hover {
    background: var(--accent-light);
}

/* Main Content */
#main-content {
    margin-left: 280px;
    padding: 40px;
    min-height: 100vh;
}

/* Hero Section */
#hero-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
}

.hero-title {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--white);
}

.hero-subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    margin-bottom: 30px;
    color: var(--accent-light);
}

#job-title-input {
    width: 100%;
    max-width: 500px;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-family: 'Lexend', sans-serif;
    background: rgba(15, 0, 24, 0.397);
    border: 2px solid rgba(118, 215, 255, 0.4);
    border-radius: 25px;
    color: var(--white);
    outline: none;
    transition: all 0.3s ease;
}

#job-title-input::placeholder {
    color: var(--muted-text);
}

#job-title-input:focus {
    border-color: var(--light-blue);
    background: rgba(233, 217, 255, 0.25);
}

.helper-text {
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--accent-light);
    max-width: 500px;
    transition: all 0.4s ease;
}

.helper-text.error {
    animation: pulseRed 0.4s ease;
}

@keyframes pulseRed {
    0%, 100% {
        text-shadow: 0 0 40px var(--purple-dark);
    }
    50% {
        text-shadow: 0 0 40px var(--error-red);
    }
}

.bounce {
    animation: bounce 0.2s ease-in-out;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Questions Section */
#questions-section {
    max-width: 800px;
    margin: 60px auto;
    padding: 40px;
    background: rgba(42, 13, 59, 0.6);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 2px solid rgba(118, 215, 255, 0.3);
}

.question-container {
    margin-bottom: 35px;
}

.question-container label {
    display: block;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--light-blue);
}

.question-container textarea {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: 'Lexend', sans-serif;
    background: rgba(233, 217, 255, 0.15);
    border: 2px solid rgba(118, 215, 255, 0.4);
    border-radius: 12px;
    color: var(--white);
    outline: none;
    resize: vertical;
    transition: all 0.3s ease;
}

.question-container textarea:focus {
    border-color: var(--light-blue);
    background: rgba(233, 217, 255, 0.25);
}

.save-answer-btn {
    margin-top: 10px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Lexend', sans-serif;
    background: var(--light-blue);
    color: var(--purple-dark);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: none;
}

.save-answer-btn:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
}

.save-confirmation {
    margin-left: 12px;
    color: var(--light-blue);
    font-size: 0.9rem;
    font-weight: 500;
}

.org-form-container {
    margin: 30px 0;
}

.org-form-container label {
    display: block;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--light-blue);
}

#org-form-select {
    width: 100%;
    padding: 12px 18px;
    font-size: 1rem;
    font-family: 'Lexend', sans-serif;
    background: rgba(233, 217, 255, 0.15);
    border: 2px solid rgba(118, 215, 255, 0.4);
    border-radius: 12px;
    color: var(--white);
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

#org-form-select:focus {
    border-color: var(--light-blue);
}

#generate-story-btn,
#regenerate-story-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Lexend', sans-serif;
    background: var(--light-blue);
    color: var(--purple-dark);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    text-shadow: none;
}

#generate-story-btn:hover,
#regenerate-story-btn:hover {
    background: var(--accent-light);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(118, 215, 255, 0.3);
}

#generation-progress {
    text-align: center;
    margin-top: 30px;
}

.spinner {
    border: 4px solid rgba(233, 217, 255, 0.3);
    border-top: 4px solid var(--light-blue);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#progress-text {
    font-size: 1rem;
    color: var(--accent-light);
}

/* Story Output Section */
#story-output-section {
    max-width: 900px;
    margin: 60px auto;
    padding: 40px;
    background: rgba(42, 13, 59, 0.7);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    border: 2px solid rgba(118, 215, 255, 0.3);
}

#story-output-section h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--light-blue);
    text-align: center;
}

#story-scores {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.score-badge-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.score-badge {
    background: rgba(118, 215, 255, 0.2);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    color: var(--accent-light);
    border: 1px solid rgba(118, 215, 255, 0.4);
    position: relative;
    transition: all 0.3s ease;
}

.score-badge strong {
    color: var(--light-blue);
    font-weight: 700;
}

.score-badge.clickable-score {
    cursor: pointer;
}

.score-badge.clickable-score:hover {
    background: rgba(118, 215, 255, 0.3);
    transform: translateY(-2px);
    border-color: var(--light-blue);
}

.improvement-hint {
    font-size: 0.75rem;
    color: var(--light-blue);
    text-decoration: underline;
    text-align: center;
    padding-top: 0.5px;
}

#story-text {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--white);
    margin-bottom: 30px;
    white-space: pre-wrap;
}

#story-rationale {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--accent-light);
    padding: 20px;
    background: rgba(233, 217, 255, 0.1);
    border-radius: 12px;
    border-left: 4px solid var(--light-blue);
    margin-bottom: 30px;
}

#copy-story-btn {
    padding: 14px 30px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Lexend', sans-serif;
    background: var(--light-blue);
    color: var(--purple-dark);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 15px;
    text-shadow: none;
}

#copy-story-btn:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--purple-mid);
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    border: 2px solid var(--light-blue);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--light-blue);
}

.modal-content p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 20px;
    color: var(--accent-light);
}

#ethics-modal-body {
    margin-bottom: 25px;
}

.ethics-concern {
    background: rgba(255, 68, 68, 0.15);
    border-left: 4px solid var(--error-red);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
}

.ethics-concern-title {
    font-weight: 600;
    color: var(--error-red);
    margin-bottom: 8px;
}

.ethics-suggestion {
    background: rgba(118, 215, 255, 0.15);
    border-left: 4px solid var(--light-blue);
    padding: 15px;
    margin-top: 20px;
    border-radius: 8px;
}

.ethics-suggestion-title {
    font-weight: 600;
    color: var(--light-blue);
    margin-bottom: 8px;
}

#api-key-input {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    font-family: 'Lexend', sans-serif;
    background: rgba(233, 217, 255, 0.15);
    border: 2px solid rgba(118, 215, 255, 0.4);
    border-radius: 12px;
    color: var(--white);
    outline: none;
    margin-bottom: 20px;
}

#api-key-input:focus {
    border-color: var(--light-blue);
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.modal-actions button {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Lexend', sans-serif;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: none;
}

#ethics-close-btn,
#api-key-save-btn {
    background: var(--light-blue);
    color: var(--purple-dark);
}

#api-key-cancel-btn {
    background: rgba(233, 217, 255, 0.2);
    color: var(--white);
}

.modal-actions button:hover {
    transform: translateY(-2px);
}

.modal-note {
    font-size: 0.85rem;
    color: var(--muted-text);
    margin-top: 15px;
}

.score-improvement-content {
    position: relative;
    max-width: 500px;
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--accent-light);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-shadow: none;
}

.modal-close-btn:hover {
    color: var(--light-blue);
    transform: rotate(90deg);
}

.improvement-tip {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--white);
    background: rgba(118, 215, 255, 0.1);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid var(--light-blue);
}

/* Fade-in animation for fourth question */
.fade-in {
    animation: fadeIn 2s ease-in;
}

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

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    #sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 2px solid rgba(118, 215, 255, 0.3);
    }

    #main-content {
        margin-left: 0;
        padding: 20px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    #questions-section,
    #story-output-section {
        padding: 20px;
    }

    .modal-content {
        padding: 25px;
    }
}
