/* ============================================
   History Charts — Global Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- Design Tokens (B&W Professional) --- */
:root {
    /* Surface Colors */
    --bg-body: #000;
    --bg-canvas: #060606;
    --bg-card: rgba(255, 255, 255, 0.02);
    --bg-card-hover: rgba(255, 255, 255, 0.05);
    --bg-panel: #080808;
    --bg-elevated: rgba(255, 255, 255, 0.04);
    --bg-overlay: rgba(0, 0, 0, 0.8);

    /* Text */
    --text-primary: #fff;
    --text-secondary: rgba(255, 255, 255, 0.5);
    --text-muted: rgba(255, 255, 255, 0.3);
    --text-inverse: #000;

    /* Accent Colors (kept for editor/viewer node colors) */
    --color-blue: #3b82f6;
    --color-blue-soft: rgba(59, 130, 246, 0.15);
    --color-red: #ef4444;
    --color-red-soft: rgba(239, 68, 68, 0.15);
    --color-orange: #f59e0b;
    --color-orange-soft: rgba(245, 158, 11, 0.15);
    --color-green: #10b981;
    --color-green-soft: rgba(16, 185, 129, 0.15);
    --color-grey: #8b5cf6;
    --color-grey-soft: rgba(139, 92, 246, 0.15);
    --color-cyan: #06b6d4;
    --color-pink: #ec4899;

    /* Brand — B&W clean */
    --gradient-brand: linear-gradient(135deg, #fff, rgba(255, 255, 255, 0.6));
    --gradient-brand-hover: linear-gradient(135deg, #fff, rgba(255, 255, 255, 0.8));
    --gradient-subtle: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.15);
    --border-active: rgba(255, 255, 255, 0.3);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
    --shadow-glow-blue: 0 0 30px rgba(255, 255, 255, 0.08);
    --shadow-glow-purple: 0 0 30px rgba(255, 255, 255, 0.05);

    /* 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;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-xs: 0.75rem;
    --font-sm: 0.85rem;
    --font-base: 1rem;
    --font-md: 1.125rem;
    --font-lg: 1.25rem;
    --font-xl: 1.5rem;
    --font-2xl: 2rem;
    --font-3xl: 2.5rem;
    --font-4xl: 3.5rem;
    --font-5xl: 4.5rem;
}

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: rgba(255, 255, 255, 0.8);
}

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

input,
textarea,
select {
    font-family: inherit;
    outline: none;
}

/* --- Utility Classes --- */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* --- Common Components --- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.7rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    font-weight: 600;
    transition: all var(--transition-base);
    white-space: nowrap;
    border: 1px solid transparent;
}

.btn-primary {
    background: #fff;
    color: #000;
    border: none;
    font-weight: 700;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.06);
}

.btn-primary:hover {
    background: #e5e5e5;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
    color: #000;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: var(--font-xs);
}

.btn-lg {
    padding: 0.9rem 2rem;
    font-size: var(--font-base);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-size: var(--font-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-draft {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-orange);
}

.badge-published {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-green);
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

/* Input */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-canvas);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: var(--font-base);
    transition: border-color var(--transition-fast);
}

.input:focus {
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input::placeholder {
    color: var(--text-muted);
}

/* Textarea */
.textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-canvas);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    line-height: 1.6;
    min-height: 80px;
    resize: vertical;
    transition: border-color var(--transition-fast);
}

.textarea:focus {
    border-color: var(--color-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Glass effect */
.glass {
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 460px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Fade animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Tooltip */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.35rem 0.7rem;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: var(--font-xs);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    border: 1px solid var(--border-subtle);
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
}