/* ============================================
   DRAW OR DECEASE — Design System
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a26;
    --bg-input: #22222e;
    --bg-hover: #2a2a38;

    --text-primary: #e8e8f0;
    --text-secondary: #9898b0;
    --text-muted: #5e5e78;

    --accent-primary: #7c5cfc;
    --accent-secondary: #5c8cfc;
    --accent-gradient: linear-gradient(135deg, #7c5cfc 0%, #5c8cfc 100%);
    --accent-glow: 0 0 20px rgba(124, 92, 252, 0.3);

    --success: #4ccc6a;
    --warning: #fcb85c;
    --danger: #fc5c6a;

    --border-color: #2a2a3a;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    /* Typography */
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    --font-size-3xl: 2.5rem;
    --font-size-hero: 3.5rem;

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

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(124, 92, 252, 0.15);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated gradient background */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 20%, rgba(124, 92, 252, 0.06) 0%, transparent 60%),
                radial-gradient(circle at 70% 80%, rgba(92, 140, 252, 0.04) 0%, transparent 60%);
    z-index: -1;
    animation: bgShift 30s ease-in-out infinite;
}

@keyframes bgShift {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(-5%, 3%); }
    66% { transform: translate(3%, -5%); }
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--accent-secondary); }

img { max-width: 100%; height: auto; }

/* --- Layout --- */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#page-content {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    padding-top: calc(64px + var(--space-xl));
}

.page { animation: fadeIn var(--transition-normal) ease; }

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

/* --- Navbar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    z-index: 100;
}

.navbar-brand {
    font-size: var(--font-size-lg);
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
    letter-spacing: -0.5px;
}

.navbar-brand:hover {
    filter: brightness(1.2);
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    list-style: none;
}

.navbar-links a, .navbar-links button {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
}

.navbar-links a:hover, .navbar-links button:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.navbar-links .btn-play {
    background: var(--accent-gradient);
    color: white !important;
    font-weight: 600;
    padding: var(--space-sm) var(--space-lg);
}

.navbar-links .btn-play:hover {
    box-shadow: var(--accent-glow);
    transform: translateY(-1px);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    box-shadow: var(--accent-glow);
    transform: translateY(-1px);
}

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

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-size-md);
    border-radius: var(--border-radius);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: rgba(124, 92, 252, 0.3);
    box-shadow: var(--shadow-glow);
}

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

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.card-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
}

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

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

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

/* --- Auth Forms --- */
.auth-container {
    max-width: 420px;
    margin: var(--space-3xl) auto;
}

.auth-container h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--space-xs);
}

.auth-container .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    font-size: var(--font-size-sm);
}

.auth-container .btn {
    width: 100%;
    padding: var(--space-md);
    font-size: var(--font-size-md);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* --- Hero Section --- */
.hero {
    text-align: center;
    padding: var(--space-3xl) 0;
}

.hero h1 {
    font-size: var(--font-size-hero);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: var(--space-lg);
    letter-spacing: -1.5px;
}

.hero h1 .gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: var(--font-size-lg);
    color: var(--text-secondary);
    max-width: 550px;
    margin: 0 auto var(--space-xl);
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Chain Grid --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.chain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
}

.chain-card {
    cursor: pointer;
}

.chain-card .chain-prompt {
    font-size: var(--font-size-md);
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    font-weight: 500;
}

.chain-card .chain-stats {
    display: flex;
    gap: var(--space-lg);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.chain-card .chain-stats span {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* --- Canvas / Play Area --- */
.play-container {
    max-width: 900px;
    margin: 0 auto;
}

.play-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.play-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.play-header .prompt-text {
    font-size: var(--font-size-lg);
    color: var(--accent-primary);
    font-weight: 500;
    padding: var(--space-md) var(--space-lg);
    background: rgba(124, 92, 252, 0.1);
    border-radius: var(--border-radius);
    border: 1px solid rgba(124, 92, 252, 0.2);
    display: inline-block;
}

.canvas-wrapper {
    position: relative;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-lg);
}

.canvas-wrapper canvas {
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.play-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Drawing Toolbar --- */
.drawing-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.tools-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.tool-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-md);
}

.tool-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.tool-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 var(--space-xs);
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: white;
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.size-slider {
    width: 80px;
    -webkit-appearance: none;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

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

/* --- Chain Viewer --- */
.chain-viewer {
    max-width: 700px;
    margin: 0 auto;
}

.chain-viewer h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-xl);
}

.chain-entry {
    margin-bottom: var(--space-xl);
    position: relative;
}

.chain-entry::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 50px;
    bottom: -32px;
    width: 2px;
    background: var(--border-color);
}

.chain-entry:last-child::before {
    display: none;
}

.chain-entry-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.chain-entry-number {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: var(--accent-primary);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.chain-entry-meta {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.chain-entry-meta .username {
    color: var(--text-primary);
    font-weight: 500;
}

.chain-entry-content {
    margin-left: 60px;
}

.chain-entry-content.description {
    font-size: var(--font-size-lg);
    color: var(--text-primary);
    font-weight: 500;
    padding: var(--space-lg);
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.chain-entry-content.drawing img {
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: white;
}

.entry-actions {
    margin-left: 60px;
    margin-top: var(--space-sm);
    display: flex;
    gap: var(--space-md);
}

.like-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
}

.like-btn:hover {
    border-color: #fc5c6a;
    color: #fc5c6a;
}

.like-btn.liked {
    background: rgba(252, 92, 106, 0.1);
    border-color: #fc5c6a;
    color: #fc5c6a;
}

/* --- Profile --- */
.profile-header {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-2xl);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.profile-info h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
}

.profile-info .joined {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
}

.stat-card {
    text-align: center;
    padding: var(--space-lg);
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: var(--space-xs);
}

/* --- Admin Dashboard --- */
.admin-panel {
    max-width: 900px;
    margin: 0 auto;
}

.report-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
}

.report-item .report-info {
    flex: 1;
}

.report-item .report-reason {
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.report-item .report-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.report-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-sm);
}

.toast {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-lg);
    animation: slideIn var(--transition-normal) ease;
    max-width: 350px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

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

/* --- Loading & Empty States --- */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    color: var(--text-muted);
}

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

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

.empty-state {
    text-align: center;
    padding: var(--space-3xl);
    color: var(--text-muted);
}

.empty-state .emoji {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.empty-state p {
    font-size: var(--font-size-md);
}

/* --- Image in describe mode --- */
.prompt-image {
    max-width: 100%;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: white;
    margin-bottom: var(--space-lg);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --font-size-hero: 2.5rem;
    }

    #page-content {
        padding: var(--space-md);
        padding-top: calc(64px + var(--space-md));
    }

    .chain-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .drawing-toolbar {
        justify-content: center;
    }

    .navbar-links {
        gap: var(--space-sm);
    }

    .hero h1 {
        font-size: var(--font-size-2xl);
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0 var(--space-md);
    }

    .navbar-brand {
        font-size: var(--font-size-md);
    }

    .navbar-links a, .navbar-links button {
        font-size: var(--font-size-xs);
        padding: var(--space-xs) var(--space-sm);
    }
}
