/* ═══════════════════════════════════════════════════════
   Eagle RTA Proof — Design System (index.css)
   Shared tokens, resets, and components for all views.
   ═══════════════════════════════════════════════════════ */

/* Google Fonts loaded via <link> in HTML for non-blocking rendering */

:root {
    /* ── Brand ── */
    --brand-red: #E53935;
    --brand-blue: #1565C0;

    /* ── Colors ── */
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --primary-dim: rgba(59, 130, 246, 0.08);
    --accent: #F97316;
    --accent-hover: #EA580C;
    --accent-dim: rgba(249, 115, 22, 0.08);
    --success: #22C55E;
    --success-dim: rgba(34, 197, 94, 0.08);
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --danger-dim: rgba(239, 68, 68, 0.08);
    --warning: #F59E0B;
    --warning-hover: #D97706;
    --warning-dim: rgba(245, 158, 11, 0.08);

    /* ── Surfaces ── */
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-hover: #F1F5F9;
    --bg-active: #E2E8F0;
    --bg-overlay: rgba(15, 23, 42, 0.4);
    --border: #E2E8F0;
    --border-focus: #93C5FD;

    /* ── Text ── */
    --text-1: #0F172A;
    --text-2: #475569;
    --text-3: #94A3B8;
    --text-inv: #FFFFFF;

    /* ── Spacing ── */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;

    /* ── Radii ── */
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-pill: 100px;
    --r-full: 50%;

    /* ── Shadows ── */
    --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --sh-md: 0 2px 8px rgba(0, 0, 0, 0.06);
    --sh-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
    --sh-xl: 0 8px 32px rgba(0, 0, 0, 0.10);

    /* ── Transitions ── */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur: 200ms;

    /* ── Font ── */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

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

html {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-1);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    min-height: 100dvh;
    overscroll-behavior: contain;
}

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

a:hover {
    color: var(--primary-hover);
}

img {
    display: block;
    max-width: 100%;
}

input,
select,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
}

/* ── Typography ── */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h2 {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

h3 {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.4;
}

.text-sm {
    font-size: 0.8125rem;
}

.text-xs {
    font-size: 0.75rem;
}

.text-mono {
    font-family: var(--mono);
    font-size: 0.8125rem;
    letter-spacing: -0.02em;
}

.text-2 {
    color: var(--text-2);
}

.text-3 {
    color: var(--text-3);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    min-height: 40px;
    white-space: nowrap;
    user-select: none;
    outline: none;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px var(--border-focus);
}

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

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

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

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

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

.btn-accent {
    background: var(--accent);
    color: var(--text-inv);
}

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

.btn-warning {
    background: var(--warning);
    color: var(--text-inv);
}

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

.btn-outline {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--bg-hover);
    color: var(--text-1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: none;
    padding: var(--sp-2);
}

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

.btn-lg {
    padding: var(--sp-4) var(--sp-6);
    font-size: 1rem;
    min-height: 48px;
    border-radius: var(--r-lg);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    padding: var(--sp-2);
    min-height: 36px;
    min-width: 36px;
    border-radius: var(--r-md);
}

/* ── Inputs ── */
.input {
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-1);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    min-height: 42px;
    outline: none;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

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

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

.label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--sp-1);
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--sp-5);
    box-shadow: var(--sh-sm);
}

.card-hover {
    cursor: pointer;
    transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.card-hover:hover {
    box-shadow: var(--sh-md);
    border-color: var(--primary);
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--r-pill);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-blue {
    background: var(--primary-dim);
    color: var(--primary);
}

.badge-green {
    background: var(--success-dim);
    color: #16A34A;
}

.badge-red {
    background: var(--danger-dim);
    color: var(--danger);
}

.badge-orange {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-gray {
    background: var(--bg-hover);
    color: var(--text-2);
}

.badge-amber {
    background: var(--warning-dim);
    color: var(--warning);
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    text-align: left;
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
}

.table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-1);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background var(--dur) var(--ease);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr[onclick] {
    cursor: pointer;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: var(--sp-6);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    background: var(--text-1);
    color: var(--text-inv);
    padding: var(--sp-3) var(--sp-5);
    border-radius: var(--r-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--sh-lg);
    opacity: 0;
    transform: translateY(10px);
    animation: toast-in 300ms var(--ease) forwards;
    pointer-events: auto;
}

@keyframes toast-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.toast-out {
    animation: toast-out 200ms var(--ease) forwards;
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* ── Skeleton Loading ── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-active) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite ease-in-out;
    border-radius: var(--r-sm);
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ── Dialog / Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    opacity: 0;
    transition: opacity 200ms var(--ease);
}

.modal-overlay.active {
    opacity: 1;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--r-xl);
    padding: var(--sp-6);
    max-width: 420px;
    width: 100%;
    box-shadow: var(--sh-xl);
    transform: scale(0.95);
    transition: transform 200ms var(--ease);
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

/* ── View transitions ── */
.view-enter {
    animation: view-fade-in 250ms var(--ease) forwards;
}

@keyframes view-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: var(--sp-12) var(--sp-6);
    color: var(--text-3);
}

.empty-state svg {
    margin: 0 auto var(--sp-4);
    opacity: 0.4;
}

.empty-state h3 {
    color: var(--text-2);
    margin-bottom: var(--sp-2);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

/* ── Utility ── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ── Loading States ── */
.upload-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    z-index: 10000;
    display: none;
}

.upload-progress.active {
    display: block;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    width: 0%;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
    color: var(--text-inv);
}

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

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

/* ── Field Validation ── */
.field-error {
    display: block;
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: var(--sp-1);
}

/* ── Pull to Refresh ── */
.ptr-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: top 0.2s var(--ease), opacity 0.2s var(--ease);
    opacity: 0;
    pointer-events: none;
    z-index: 100;
}

.ptr-indicator.visible {
    top: 10px;
    opacity: 1;
}

.ptr-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner 0.8s linear infinite;
}

/* ── Enhanced Animations ── */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.view-enter {
    animation: slideInRight 300ms var(--ease) forwards;
}

.view-exit {
    animation: slideOutLeft 300ms var(--ease) forwards;
}

.fade-in {
    animation: fadeIn 400ms var(--ease) forwards;
}

button:active,
.action-card:active {
    transform: scale(0.98);
}

/* ── Empty States ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-10) var(--sp-4);
    text-align: center;
    min-height: 300px;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: var(--sp-4);
    color: var(--text-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: var(--sp-2);
}

.empty-state-message {
    font-size: 0.875rem;
    color: var(--text-3);
    max-width: 300px;
    margin-bottom: var(--sp-6);
    line-height: 1.5;
}

.empty-state-action {
    padding: var(--sp-3) var(--sp-6);
    background: var(--primary);
    color: var(--text-inv);
    border: none;
    border-radius: var(--r-md);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--dur) var(--ease), transform 100ms var(--ease);
}

.empty-state-action:hover {
    background: var(--primary-h);
}

.empty-state-action:active {
    transform: scale(0.98);
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}