/* ===== CSS Variables ===== */
:root {
    --heading-font: 'Funnel Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --background: #09090b;
    --foreground: #fafafa;
    --card: #09090b;
    --card-foreground: #fafafa;
    --popover: #09090b;
    --popover-foreground: #fafafa;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --secondary: #27272a;
    --secondary-foreground: #fafafa;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --accent: #27272a;
    --accent-foreground: #fafafa;
    --destructive: #7f1d1d;
    --destructive-foreground: #fafafa;
    --border: #27272a;
    --input: #27272a;
    --ring: #d4d4d8;
    --radius: 0.5rem;
    --success: #22c55e;
    --warning: #eab308;
    --info: #3b82f6;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    min-height: 100vh;
    position: relative;
}

#ascii-ground-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.main-wrapper {
    position: relative;
    z-index: 1;
}

.index-page {
    background-color: #000000;
    background-image: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8)), url("pictures/alto image.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Heading font (apply Funnel Display to headings across the site) */
h1, h2, h3, h4, h5, h6,
.section-title, .card-title, .modal-title, .alert-title, .function-card-title, .header h1 {
    font-family: var(--heading-font);
    letter-spacing: -0.02em;
    -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar Navigation ===== */
.sidebar {
    width: 240px;
    height: 100vh;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    position: fixed;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 40;
    display: flex;
    flex-direction: column;
}

.sidebar-title {
    padding: 0.75rem 1.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--muted-foreground);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    width: 3px;
    height: 0;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
    background: rgba(250, 250, 250, 0.05);
    color: var(--foreground);
    padding-left: 1.25rem;
}

.nav-item:hover::before {
    height: 100%;
}

.nav-item.active {
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(250, 250, 250, 0.1);
}

.nav-item.active::before {
    height: 100%;
}

/* ===== Main Content Wrapper ===== */
.main-wrapper {
    flex: 1;
    margin-left: 240px;
    width: calc(100% - 240px);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Layout ===== */
.container {
    max-width: 100%;
    margin: 0;
    padding: 2rem;
    width: 100%;
}

.section {
    margin-bottom: 4rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.section-description {
    color: var(--muted-foreground);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* ===== Header ===== */
.header {
    text-align: left;
    padding: 4rem 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 3rem;
}

.header-badge {
    display: inline-block;
    background: var(--secondary);
    color: var(--muted-foreground);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.5s ease;
}

.header h1 {
    font-family: var(--heading-font);
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(to right, var(--foreground), var(--muted-foreground));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInUp 0.6s ease;
}

.header p {
    color: var(--muted-foreground);
    max-width: 600px;
    margin: 0;
    animation: fadeInUp 0.7s ease;
}

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

.btn:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    background: rgba(250, 250, 250, 0.9);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

.btn-secondary:hover {
    background: rgba(39, 39, 42, 0.8);
}

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

.btn-outline:hover {
    background: var(--accent);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-loading.btn-primary::after {
    border-color: var(--primary-foreground);
    border-right-color: transparent;
}

/* ===== Inputs & Textareas ===== */
.input, .textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius);
    color: var(--foreground);
    transition: all 0.2s ease;
}

.textarea {
    min-height: 100px;
    resize: vertical;
    padding: 0.75rem;
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgba(212, 212, 216, 0.1);
}

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

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

.form-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

/* ===== Switch/Toggle ===== */
.switch {
    position: relative;
    width: 2.5rem;
    height: 1.5rem;
    background: var(--input);
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: inline-block;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.25rem;
    height: 1.25rem;
    background: var(--foreground);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
    transform: translateX(1rem);
    background: var(--primary-foreground);
}

.switch:has(input:checked) {
    background: var(--primary);
}

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

/* ===== Cards ===== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1.5rem 1.5rem 0;
}

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

.card-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.card-content {
    padding: 1.5rem;
}

/* ===== List Editor ===== */
.list-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.list-editor-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.quick-start-links {
    flex-wrap: wrap;
    align-items: flex-start;
}

.list-editor-item input {
    flex: 1;
}

.btn-icon-only {
    padding: 0;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge-default {
    background: var(--secondary);
    color: var(--secondary-foreground);
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 150;
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 0.75rem;
    animation: slideInRight 0.3s ease;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid #dc2626; }

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

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

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

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

/* ===== Utility ===== */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.text-muted { color: var(--muted-foreground); }
