/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin-bottom: 0;
}

/* Genre Selection */
.genre-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}

.genre-btn {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.genre-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-light);
}

.genre-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Generate Button */
.generate-section {
    text-align: center;
    margin: 2rem 0;
}

.generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

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

.btn-icon {
    font-size: 1.25rem;
}

/* Results */
.results-container {
    display: grid;
    gap: 1.5rem;
}

.result-card {
    position: relative;
}

.prompt-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #fcd34d;
}

.prompt-card h2 {
    color: #92400e;
}

.result-text {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.7;
}

.prompt-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: #78350f;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
}

/* Copy Button */
.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.copy-icon {
    font-size: 1rem;
}

/* Character & Setting Lists */
.character-list,
.setting-details {
    list-style: none;
}

.character-list li,
.setting-details li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.character-list li:last-child,
.setting-details li:last-child {
    border-bottom: none;
}

.character-name,
.setting-label {
    font-weight: 600;
    color: var(--primary-color);
}

/* Plot Outline */
.plot-outline {
    list-style: none;
    counter-reset: plot-counter;
}

.plot-outline li {
    position: relative;
    padding: 0.75rem 0 0.75rem 3rem;
    border-left: 2px solid var(--primary-light);
    margin-left: 1rem;
}

.plot-outline li::before {
    counter-increment: plot-counter;
    content: counter(plot-counter);
    position: absolute;
    left: -1rem;
    top: 0.75rem;
    width: 2rem;
    height: 2rem;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.plot-label {
    display: block;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

/* History Section */
.history-section {
    background: var(--surface);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background: var(--primary-light);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-genre {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.history-prompt {
    font-size: 0.875rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.clear-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.clear-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

/* Footer */
.footer {
    background: var(--text-primary);
    color: var(--text-muted);
    padding: 1.5rem;
    text-align: center;
    margin-top: auto;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: white;
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

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

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    animation: fadeIn 0.3s ease forwards;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .main-content {
        padding: 1rem;
    }

    .card {
        padding: 1.25rem;
    }

    .genre-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 0.5rem;
    }

    .genre-btn {
        padding: 0.625rem 0.75rem;
        font-size: 0.8rem;
    }

    .generate-btn {
        width: 100%;
        justify-content: center;
        padding: 1rem 1.5rem;
        font-size: 1rem;
    }

    .card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .plot-outline li {
        padding-left: 2.5rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .genre-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-text {
        font-size: 0.9375rem;
    }

    .prompt-text {
        font-size: 1rem;
    }
}

/* Scrollbar Styling */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Focus States for Accessibility */
.genre-btn:focus,
.generate-btn:focus,
.copy-btn:focus,
.clear-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
