:root {
    /* Color Palette */
    --bg-main: #0B0F19;
    --bg-sidebar: #131A2A;
    --bg-card: #1C2438;
    --bg-hover: #26314A;
    
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    --accent-gold: #D4AF37;
    --accent-gold-hover: #F2D06B;
    --accent-purple: #8B5CF6;
    --accent-purple-hover: #A78BFA;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(212, 175, 55, 0.5);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 15px rgba(212, 175, 55, 0.2);
    
    /* Typography */
    --font-sans: 'Inter', sans-serif;
    --font-serif: 'Playfair Display', serif;
    
    /* Transitions */
    --transition: all 0.3s ease;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.app-container {
    display: flex;
    height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 320px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: var(--shadow-lg);
}

.brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand h1 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.icon-gold {
    color: var(--accent-gold);
    font-size: 1.5rem;
}

.badge {
    background: linear-gradient(135deg, var(--accent-gold), #B8860B);
    color: #000;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.settings-group {
    padding: 20px 24px 0;
}

#generatorForm {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.form-scroll-area {
    padding: 20px 24px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group label i {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.input-group input, 
.input-group select {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 12px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.input-group input:focus, 
.input-group select:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.1);
}

.input-group small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.form-actions {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
}

#generateBtn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-gold), #B8860B);
    color: #0B0F19;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-glow);
}

#generateBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
}

#generateBtn:active {
    transform: translateY(0);
}

#generateBtn:disabled {
    background: var(--bg-card);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ===== MAIN CONTENT ===== */
.content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.content-header {
    height: 73px; /* Match brand height */
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.content-header h2 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.action-btn.primary-action {
    background-color: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: var(--accent-purple-hover);
}

.action-btn.primary-action:hover {
    background-color: rgba(139, 92, 246, 0.2);
}

.action-btn.word-action {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #60A5FA;
}

.action-btn.word-action:hover {
    background-color: rgba(59, 130, 246, 0.2);
}

.workspace {
    flex-grow: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
}

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

.empty-state, .loading-state {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.icon-pulse {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.05));
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    font-size: 2rem;
    color: var(--accent-gold);
    box-shadow: var(--shadow-glow);
    animation: float 6s ease-in-out infinite;
}

.empty-state h3 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Spinner */
.spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(212, 175, 55, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-gold);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 24px;
}

.loading-state h3 {
    font-family: var(--font-serif);
    color: var(--accent-gold);
    margin-bottom: 8px;
}

.loading-text {
    color: var(--text-secondary);
    animation: pulse 2s infinite;
}

/* Generated Content Typography - Markdown Rendered */
.result-content {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px;
    max-width: 900px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
    position: relative;
}

.markdown-body {
    color: var(--text-primary);
    font-size: 1.05rem;
    line-height: 1.7;
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3 {
    font-family: var(--font-serif);
    color: var(--accent-gold);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.markdown-body h1 {
    font-size: 2.2rem;
    margin-top: 0;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 30px;
}

.markdown-body h2 {
    font-size: 1.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 8px;
}

.markdown-body h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
}

.markdown-body p {
    margin-bottom: 1.2em;
}

.markdown-body strong {
    color: #fff;
    font-weight: 600;
}

.markdown-body em {
    color: var(--text-secondary);
    font-style: italic;
}

.markdown-body blockquote {
    border-left: 4px solid var(--accent-purple);
    background-color: rgba(139, 92, 246, 0.05);
    padding: 16px 20px;
    margin: 1.5em 0;
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

.markdown-body blockquote p {
    margin-bottom: 0;
}

.markdown-body ul, 
.markdown-body ol {
    margin-bottom: 1.5em;
    padding-left: 2em;
}

.markdown-body li {
    margin-bottom: 0.5em;
}

.markdown-body hr {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 2em 0;
}

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

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

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none !important;
    opacity: 0;
}

.modal-content {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-history {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
}

.history-item {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item:hover {
    border-color: var(--accent-gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.history-title {
    font-weight: 600;
    color: var(--accent-gold);
    font-size: 1.1rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 50vh;
    }
    
    .result-content {
        padding: 20px;
    }
}
