/* City Initiatives - Dual Theme with Gradient Accents */

/* ===== CSS Variables ===== */
:root {
    /* Accent gradient - Cyan to Purple (shared) */
    --accent-start: #06b6d4;
    --accent-end: #8b5cf6;
    --accent-hover-start: #22d3ee;
    --accent-hover-end: #a78bfa;
    --gradient: linear-gradient(135deg, var(--accent-start), var(--accent-end));

    /* Status colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
}

/* Light Theme (default) */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.15);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #1e293b;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(6, 182, 212, 0.2);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Background effect for dark theme */
[data-theme="dark"] body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 15% 85%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 15%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

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

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

/* ===== Navigation ===== */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .navbar {
    background: rgba(26, 26, 46, 0.9);
}

.navbar-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-nav {
    display: flex;
    gap: 0.5rem;
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

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

.nav-link.active {
    color: var(--accent-start);
    background: rgba(6, 182, 212, 0.1);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    color: var(--accent-start);
    border-color: var(--accent-start);
    box-shadow: var(--shadow-glow);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-fast);
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 25px rgba(6, 182, 212, 0.4);
    transform: translateY(-2px);
}

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

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-start);
    box-shadow: var(--shadow-glow);
}

.btn-outline {
    background: transparent;
    color: var(--accent-start);
    border: 1px solid var(--accent-start);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(6, 182, 212, 0.1);
}

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

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

.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }

.btn-icon {
    padding: 0.625rem;
    width: 44px;
    height: 44px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: rgba(6, 182, 212, 0.3);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-input);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

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

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

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

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

.form-error {
    color: var(--error);
    font-size: 0.8125rem;
    margin-top: 0.375rem;
}

/* ===== Alerts ===== */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--info);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    padding: 0;
}

.alert-close:hover { opacity: 1; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}

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

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-error { background: rgba(239, 68, 68, 0.15); color: var(--error); }
.badge-secondary { background: var(--bg-input); color: var(--text-secondary); }

/* ===== Proposal Card ===== */
.proposal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: all var(--transition-normal);
    cursor: pointer;
}

.proposal-card:hover {
    transform: translateY(-4px);
    border-color: rgba(6, 182, 212, 0.4);
    box-shadow: var(--shadow-glow);
}

.proposal-card-image {
    height: 180px;
    background: var(--bg-input);
    position: relative;
    overflow: hidden;
}

.proposal-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.proposal-card-category {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
}

.proposal-card-body {
    padding: 1.25rem;
}

.proposal-card-title {
    font-size: 1.0625rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.proposal-card-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.proposal-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.proposal-card-votes {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--accent-start);
    font-weight: 600;
}

/* ===== Vote Button ===== */
.vote-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.vote-btn:hover {
    border-color: var(--accent-start);
    color: var(--accent-start);
}

.vote-btn.voted {
    background: var(--gradient);
    border-color: transparent;
    color: white;
}

.vote-btn-count {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.vote-btn-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== Sidebar ===== */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    width: 360px;
    max-width: 100%;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-title {
    font-size: 1.125rem;
    font-weight: 600;
}

/* ===== Auth Pages ===== */
.auth-container {
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
}

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

.auth-title {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== Dropdown ===== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

[data-theme="dark"] .dropdown-menu {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.dropdown.active .dropdown-menu,
.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    color: var(--text-secondary);
    border-radius: 8px;
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* ===== Loading ===== */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient);
    z-index: 9999;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.loading-indicator.active {
    opacity: 1;
    animation: loading-progress 1.5s ease-in-out infinite;
}

@keyframes loading-progress {
    0% { transform: scaleX(0); transform-origin: left; }
    50% { transform: scaleX(1); transform-origin: left; }
    51% { transform-origin: right; }
    100% { transform: scaleX(0); transform-origin: right; }
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-start);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-top: auto;
}

.footer-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ===== Map ===== */
.map-layout {
    display: flex;
    height: calc(100vh - 64px);
}

.map-container {
    flex: 1;
    position: relative;
}

.map-container #map {
    width: 100%;
    height: 100%;
}

/* ===== Grid ===== */
.grid {
    display: grid;
    gap: 1.5rem;
}

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

@media (min-width: 640px) {
    .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Container ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent-start); }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-auto { margin-top: auto; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.hidden { display: none; }

/* ===== HTMX ===== */
[x-cloak] { display: none !important; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }

/* ===== Notifications ===== */
.notification-bell {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    color: white;
    background: var(--error);
    border-radius: 9999px;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.4);
}

.notification-badge:empty,
.notification-badge[data-count="0"] {
    display: none !important;
}

.notification-menu {
    width: 380px;
    max-height: 480px;
    padding: 0;
    display: flex;
    flex-direction: column;
}

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

.notification-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.notification-list-container {
    flex: 1;
    overflow-y: auto;
    max-height: 340px;
}

.notification-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.notification-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

/* Notification items */
.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--bg-input);
}

.notification-item.unread {
    background: rgba(6, 182, 212, 0.05);
}

.notification-item.unread:hover {
    background: rgba(6, 182, 212, 0.1);
}

.notification-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-icon.vote {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.notification-icon.comment {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-end);
}

.notification-icon.status {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.notification-icon.status.rejected {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.notification-icon.system {
    background: var(--bg-input);
    color: var(--text-muted);
}

.notification-content {
    flex: 1;
    min-width: 0;
}

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

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.notification-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.notification-empty svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    opacity: 0.5;
}

.notification-empty p {
    font-size: 0.875rem;
}

/* Mobile notifications */
@media (max-width: 480px) {
    .notification-menu {
        width: calc(100vw - 2rem);
        right: -0.5rem;
    }
}

/* ===== Proposal List Item ===== */
.proposal-list-item:hover {
    background: var(--bg-input);
}

/* ===== Mobile Menu ===== */
.mobile-menu-btn {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex !important;
    }

    .navbar-actions > .btn-ghost:not(.btn-icon),
    .navbar-actions > .btn-primary {
        display: none !important;
    }

    .dropdown:not(.notification-dropdown) {
        display: none;
    }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar-nav { display: none; }
    .sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 40vh;
    }
    .map-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 64px);
    }
    .map-container {
        min-height: 50vh;
    }
    .auth-card { padding: 1.5rem; }
    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.5rem; }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
        max-width: 100%;
    }

    .navbar-container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card {
        border-radius: 12px;
        max-width: 100%;
    }

    .card-header,
    .card-body {
        padding: 1rem;
    }

    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* Fix potential overflow sources */
    img, video, iframe {
        max-width: 100%;
        height: auto;
    }

    pre, code {
        max-width: 100%;
        overflow-x: auto;
    }

    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .navbar-container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    .navbar-brand svg {
        width: 24px;
        height: 24px;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }

    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }

    .view-mode-tabs {
        top: 10px;
        right: 10px;
        padding: 2px;
    }

    .view-mode-tabs button {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .viewer-info {
        top: 10px;
        left: 10px;
        max-width: calc(100% - 120px);
        padding: 12px;
    }

    .viewer-info h2 {
        font-size: 1rem;
    }

    .viewer-controls {
        padding: 6px 12px;
    }

    .viewer-controls button {
        width: 36px;
        height: 36px;
    }
}

/* ===== Prevent horizontal overflow ===== */
main {
    overflow-x: hidden;
    max-width: 100vw;
}

.container,
.navbar-container {
    box-sizing: border-box;
}

/* ===== Animated Background ===== */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

/* Floating orbs */
.animated-bg .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: orb-float 20s ease-in-out infinite;
}

.animated-bg .orb-1 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.3), rgba(6, 182, 212, 0.1));
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.animated-bg .orb-2 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(139, 92, 246, 0.1));
    top: 60%;
    right: -10%;
    animation-delay: -7s;
}

.animated-bg .orb-3 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.2));
    bottom: -5%;
    left: 30%;
    animation-delay: -14s;
}

@keyframes orb-float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -30px) scale(1.05);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
    75% {
        transform: translate(-30px, -10px) scale(1.02);
    }
}

/* Geometric shapes */
.animated-bg .shape {
    position: absolute;
    opacity: 0.15;
    animation: shape-float 15s ease-in-out infinite;
}

.animated-bg .shape-square {
    width: 60px;
    height: 60px;
    border: 2px solid var(--accent-start);
    top: 15%;
    left: 10%;
    animation-delay: -2s;
    animation-duration: 18s;
}

.animated-bg .shape-circle {
    width: 40px;
    height: 40px;
    border: 2px solid var(--accent-end);
    border-radius: 50%;
    top: 70%;
    left: 85%;
    animation-delay: -5s;
    animation-duration: 16s;
}

.animated-bg .shape-triangle {
    width: 0;
    height: 0;
    border-left: 25px solid transparent;
    border-right: 25px solid transparent;
    border-bottom: 43px solid var(--accent-start);
    top: 40%;
    right: 15%;
    animation-delay: -8s;
    animation-duration: 20s;
}

.animated-bg .shape-diamond {
    width: 50px;
    height: 50px;
    border: 2px solid var(--accent-end);
    transform: rotate(45deg);
    bottom: 20%;
    left: 20%;
    animation-delay: -11s;
    animation-duration: 22s;
}

@keyframes shape-float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.15;
    }
    50% {
        transform: translateY(-30px) rotate(180deg);
        opacity: 0.25;
    }
}

/* Particles */
.animated-bg .particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-start);
    border-radius: 50%;
    opacity: 0;
    animation: particle-rise 8s ease-in-out infinite;
}

@keyframes particle-rise {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1);
    }
}

/* Glowing lines */
.animated-bg .glow-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-start), transparent);
    opacity: 0;
    animation: glow-travel 12s linear infinite;
}

@keyframes glow-travel {
    0% {
        opacity: 0;
        transform: translateX(-100%);
    }
    10% {
        opacity: 0.5;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        opacity: 0;
        transform: translateX(100vw);
    }
}

/* Wave effect */
.animated-bg .wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 100px;
    background: linear-gradient(transparent, rgba(6, 182, 212, 0.03));
    animation: wave-move 25s linear infinite;
}

.animated-bg .wave::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120'%3E%3Cpath fill='rgba(6,182,212,0.05)' d='M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z'/%3E%3C/svg%3E") repeat-x;
    background-size: 1200px 100%;
}

@keyframes wave-move {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Light theme adjustments */
[data-theme="light"] .animated-bg .orb {
    opacity: 0.25;
}

[data-theme="light"] .animated-bg .shape {
    opacity: 0.1;
}

[data-theme="light"] .animated-bg .particle {
    background: var(--accent-end);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .animated-bg * {
        animation: none !important;
    }
}
