/**
 * Machine Hallucination Visualizer - Modern CSS
 * Professional, responsive, dark-themed design
 */

/* ============================================================================
   VARIABLES & RESET
   ============================================================================ */

:root {
    /* Bright theme colors */
    --primary-color: #2563eb;       /* Blue-600 */
    --primary-dark: #1e40af;        /* Blue-800 */
    --secondary-color: #f97316;     /* Orange-500 */
    --accent-color: #a855f7;        /* Purple-500 */

    --bg-dark: #f7f9fc;             /* Page background (light) */
    --bg-darker: #edf2f7;           /* Input background */
    --bg-card: #ffffff;             /* Card/containers */
    --bg-hover: #f1f5f9;            /* Hovered surfaces */

    --text-primary: #0f172a;        /* Slate-900 */
    --text-secondary: #334155;      /* Slate-700 */
    --text-muted: #64748b;          /* Slate-500 */

    --success: #16a34a;             /* Green-600 */
    --warning: #d97706;             /* Amber-600 */
    --error: #dc2626;               /* Red-600 */

    --border-color: #e2e8f0;        /* Slate-200 */
    --shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
    --shadow-lg: 0 14px 40px rgba(2, 6, 23, 0.12);

    /* Fonts */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Space Grotesk', sans-serif;

    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Transitions */
    --transition: all 0.25s ease;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* Full-page video background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -10;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 400% 400%;
    animation: gradientShift 20s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.body-video-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -9;
    pointer-events: none;
    overflow: hidden;
}

.body-video-bg video {
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    /* Start hidden; JS will reveal to 1 only when video mode is active */
    opacity: 0;
    filter: saturate(1.6) contrast(1.2) brightness(0.95) hue-rotate(20deg);
    transition: opacity 1s ease-in-out;
}

.body-video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -8;
    background: linear-gradient(180deg, 
        rgba(247,249,252,0.78) 0%, 
        rgba(247,249,252,0.72) 30%, 
        rgba(247,249,252,0.75) 70%, 
        rgba(247,249,252,0.82) 100%);
    pointer-events: none;
}

/* Procedural canvas fallback */
.bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -9;
}

/* ============================================================================
   NAVIGATION
   ============================================================================ */

.navbar {
    background: rgba(255,255,255,0.8);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-sm) 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.nav-brand {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    color: var(--primary-dark);
}

.nav-links {
    display: flex;
    gap: var(--spacing-sm);
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

.nav-status {
    display: flex;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: #eef2ff;
    border-radius: 20px;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error);
    animation: pulse 2s infinite;
}

.status-indicator.loaded .status-dot {
    background: var(--success);
}

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

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */

.main-content {
    min-height: calc(100vh - 200px);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* ============================================================================
   HERO SECTION
   ============================================================================ */

.hero-section {
    position: relative;
    padding: var(--spacing-xl) 0;
    text-align: center;
    margin-bottom: var(--spacing-lg);
    border-radius: 20px;
    overflow: visible;
}

.hero-title {
    font-family: var(--font-display);
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    line-height: 1.1;
}

.gradient-text { color: var(--primary-dark); }.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.hero-buttons {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
}

/* ============================================================================
   FEATURE CARDS
   ============================================================================ */

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--spacing-lg);
    text-align: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.feature-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto var(--spacing-sm);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.feature-card h3 {
    font-family: var(--font-display);
    margin-bottom: var(--spacing-xs);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================================================
   PAGE HEADER
   ============================================================================ */

.page-header {
    margin-bottom: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h1 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    margin-bottom: var(--spacing-xs);
}

.page-header p {
    color: var(--text-secondary);
}

/* ============================================================================
   FORMS & INPUTS
   ============================================================================ */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: var(--spacing-sm);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.radio-label:hover {
    border-color: var(--primary-color);
}

.radio-label input[type="radio"] {
    accent-color: var(--primary-color);
}

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

.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-large {
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   LAYOUTS
   ============================================================================ */

.create-layout,
.analyze-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--spacing-lg);
}

.input-panel,
.output-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--spacing-lg);
    box-shadow: var(--shadow);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--spacing-md);
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--spacing-lg);
    box-shadow: var(--shadow);
}

/* Auth/Forms enhancements */
.auth-cta {
    text-align: center;
    margin-top: var(--spacing-sm);
}

.form-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}
.btn-outline:hover { background: rgba(37,99,235,0.08); }

.settings-card h3 {
    margin-bottom: var(--spacing-sm);
}

/* ============================================================================
   ACCORDION
   ============================================================================ */

.settings-accordion {
    margin-bottom: var(--spacing-md);
}

.accordion-header {
    width: 100%;
    padding: var(--spacing-sm);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.accordion-header:hover {
    border-color: var(--primary-color);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-content.active {
    max-height: 500px;
    padding-top: var(--spacing-sm);
}

/* ============================================================================
   OUTPUT & GALLERY
   ============================================================================ */

.placeholder-content {
    padding: var(--spacing-xl);
    text-align: center;
    color: var(--text-muted);
}

.placeholder-content i {
    font-size: 4rem;
    margin-bottom: var(--spacing-sm);
    opacity: 0.3;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing-md);
}

.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.gallery-item img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
}

/* ============================================================================
   STATUS MESSAGES
   ============================================================================ */

.status-message {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    border-radius: 8px;
    border-left: 4px solid;
}

.status-message.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
    color: var(--success);
}

.status-message.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
    color: var(--error);
}

.status-message.info {
    background: rgba(102, 126, 234, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ============================================================================
   LOADING OVERLAY
   ============================================================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-sm);
}

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

/* ============================================================================
   MODAL
   ============================================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 12px;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    font-size: 2rem;
    color: #fff;
    cursor: pointer;
}

/* ============================================================================
   FOOTER
   ============================================================================ */

.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: var(--spacing-lg) 0;
    text-align: center;
    color: var(--text-muted);
    margin-top: var(--spacing-xl);
}

.footer p {
    margin: var(--spacing-xs) 0;
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

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

.directory-list {
    list-style: none;
    padding: 0;
}

.directory-list li {
    padding: var(--spacing-xs) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

code {
    background: var(--bg-darker);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

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

@media (max-width: 1024px) {
    .create-layout,
    .analyze-layout {
        grid-template-columns: 1fr;
    }
    
    .hero-title {
        font-size: 3rem;
    }
}

@media (max-width: 768px) {
    .nav-links {
        flex-wrap: wrap;
    }
    
    .nav-link span {
        display: none;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
    
    .hero-buttons {
        flex-direction: column;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   NOTIFICATION ANIMATIONS
   ============================================================================ */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
