/* ====== CSS CUSTOM PROPERTIES ====== */
:root {
    --primary: #8B5CF6;
    --primary-dark: #7C3AED;
    --primary-light: #A78BFA;
    --secondary: #EC4899;
    --accent: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    
    /* Background Colors */
    --bg: #0F0F23;
    --bg-secondary: #1A1A3E;
    --bg-card: #252550;
    --bg-elevated: #2D2D5F;
    --bg-overlay: rgba(15, 15, 35, 0.9);
    
    /* Text Colors */
    --text: #E5E7EB;
    --text-secondary: #D1D5DB;
    --text-muted: #9CA3AF;
    --text-disabled: #6B7280;
    
    /* Border & Effects */
    --border: #374151;
    --border-light: #4B5563;
    --shadow: rgba(0, 0, 0, 0.3);
    --glow: rgba(139, 92, 246, 0.3);
    --glow-secondary: rgba(236, 72, 153, 0.3);
    
    /* Spacing */
    --radius: 1rem;
    --radius-sm: 0.5rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
}

/* ====== GLOBAL RESET & BASE ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ====== ANIMATED BACKGROUND ====== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.05;
    pointer-events: none;
}

.bg-animation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 25% 25%, var(--primary) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, var(--secondary) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, var(--accent) 0%, transparent 60%);
    animation: float 20s infinite ease-in-out;
}

@keyframes float {
    0%, 100% { 
        transform: translateY(0px) rotate(0deg) scale(1); 
    }
    33% { 
        transform: translateY(-20px) rotate(120deg) scale(1.1); 
    }
    66% { 
        transform: translateY(10px) rotate(240deg) scale(0.9); 
    }
}

/* ====== HEADER ====== */
.header {
    text-align: center;
    padding: 4rem 2rem 2rem;
    position: relative;
}

.header h1 {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
    position: relative;
    animation: gradient-shift 3s ease-in-out infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.header h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--secondary), transparent);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 0.5; 
        transform: translateX(-50%) scaleX(1); 
    }
    50% { 
        opacity: 1; 
        transform: translateX(-50%) scaleX(1.2); 
    }
}

.header .subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.header .tagline {
    font-size: 1rem;
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.9;
    max-width: 500px;
    margin: 0 auto;
}

/* ====== NAVIGATION ====== */
.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    padding: 0 2rem;
    flex-wrap: wrap;
}

.nav-tab {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.nav-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.nav-tab:hover::before {
    left: 100%;
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--glow);
    transform: translateY(-2px);
}

.nav-tab:hover:not(.active) {
    background: var(--bg-elevated);
    border-color: var(--primary);
    transform: translateY(-2px);
    color: var(--text);
}

.tab-icon {
    font-size: 1.1rem;
}

.tab-text {
    font-size: 0.9rem;
}

/* ====== MAIN CONTAINER ====== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 2rem;
    min-height: 60vh;
}

/* ====== TAB CONTENT ====== */
.tab-content {
    animation: fadeIn 0.5s ease-in-out;
}

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

.hidden {
    display: none !important;
}

/* ====== STORY FORM ====== */
.story-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 40px var(--shadow);
}

.story-form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.form-header {
    text-align: center;
    margin-bottom: 2rem;
}

.form-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.form-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1.6;
}

.story-textarea {
    min-height: 150px;
    resize: vertical;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    background: var(--bg-secondary);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.char-counter {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.char-counter.warning {
    color: var(--warning);
}

.char-counter.danger {
    color: var(--danger);
}

/* ====== CATEGORY & MOOD SELECTION ====== */
.category-select,
.mood-select {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.category-pill,
.mood-pill {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    position: relative;
    overflow: hidden;
}

.category-pill:hover,
.mood-pill:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    color: var(--text);
}

.category-pill.selected,
.mood-pill.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--glow);
}

/* ====== BUTTONS ====== */
.submit-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--glow);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

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

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ====== STORIES GRID ====== */
.stories-grid,
.discover-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.story-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.story-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.story-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(139, 92, 246, 0.15);
}

.story-card:hover::before {
    opacity: 1;
}

.story-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.story-avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.story-info {
    flex: 1;
}

.story-info h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.story-info .timestamp {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.story-badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.story-category,
.story-mood {
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary-light);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 500;
}

.story-mood {
    background: rgba(236, 72, 153, 0.2);
    color: var(--secondary);
}

.story-content {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

.story-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
}

.action-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.action-btn:hover {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    transform: scale(1.05);
}

.action-btn.liked {
    color: var(--accent);
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    opacity: 0;
}

.story-card:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ====== DISCOVER SECTION ====== */
.discover-content {
    margin-bottom: 2rem;
}

.discover-filters {
    text-align: center;
    margin-bottom: 2rem;
}

.discover-filters h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

.filter-chips {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-chip {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-chip:hover {
    border-color: var(--primary);
    color: var(--text);
}

.filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ====== CHAT SECTION (Legacy) ====== */
.chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    backdrop-filter: blur(10px);
}

.chat-header {
    text-align: center;
    margin-bottom: 2rem;
}

.chat-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.chat-header p {
    color: var(--text-muted);
}

.chat-list {
    list-style: none;
    margin-bottom: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-elevated);
    border-radius: var(--radius);
}

.chat-list li {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    position: relative;
    transition: transform 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.chat-list li:hover {
    transform: scale(1.02);
}

.chat-input-area {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.chat-input-area input {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.chat-send-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--glow);
}

/* ====== FLOATING ACTION BUTTON ====== */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 10px 30px var(--glow);
    transition: all 0.3s ease;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 15px 40px var(--glow);
}

.fab:active {
    transform: scale(0.95);
}

/* ====== MODAL STYLES ====== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

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

.modal-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    text-align: center;
}

.modal-content p {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
}

.story-detail {
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

/* ====== LOADING SPINNER ====== */
.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ====== FOOTER ====== */
.footer {
    text-align: center;
    padding: 3rem 2rem 2rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: var(--primary-light);
}

.hidden-egg {
    cursor: pointer;
    transition: all 0.3s ease;
    font-style: italic;
}

.hidden-egg:hover {
    color: var(--primary);
    transform: scale(1.05);
}

/* ====== SCROLLBAR STYLING ====== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ====== RESPONSIVE DESIGN ====== */
@media (max-width: 768px) {
    .header {
        padding: 2rem 1rem 1rem;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .story-form {
        padding: 1.5rem;
    }
    
    .nav-tabs {
        padding: 0 1rem;
        gap: 0.5rem;
    }
    
    .nav-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .tab-text {
        display: none;
    }
    
    .category-select,
    .mood-select,
    .filter-chips {
        gap: 0.5rem;
    }
    
    .category-pill,
    .mood-pill,
    .filter-chip {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .story-card {
        padding: 1.25rem;
    }
    
    .story-meta {
        gap: 0.75rem;
    }
    
    .story-avatar {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .story-actions {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .action-group {
        gap: 0.75rem;
    }
    
    .fab {
        bottom: 1rem;
        right: 1rem;
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .chat-input-area {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .chat-input-area input,
    .chat-send-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .story-form {
        padding: 1rem;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
    }
    
    .category-select,
    .mood-select {
        justify-content: center;
    }
    
    .nav-tabs {
        gap: 0.25rem;
    }
    
    .nav-tab {
        padding: 0.4rem 0.8rem;
    }
}

/* ====== UTILITY CLASSES ====== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 2rem; }

.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* ====== ANIMATION CLASSES ====== */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

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

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}