/* ============================================================
   JWT Token Inspector — Styles
   Security dark mode — jwt.io inspired but better
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --primary: #00CEC9;
    --primary-light: #55EFC4;
    --primary-dark: #00A89E;
    --secondary: #636E72;
    --accent-red: #FF6B6B;
    --accent-orange: #F39C12;
    --accent-purple: #A29BFE;
    --bg: #0D1117;
    --bg-elevated: #161B22;
    --bg-surface: #21262D;
    --bg-card: #1C2128;
    --bg-hover: #2D333B;
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #484F58;
    --border: #30363D;
    --header-color: #FF6B6B;
    --payload-color: #A29BFE;
    --signature-color: #00CEC9;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-pill: 50px;
    --shadow: 0 4px 16px rgba(0, 0, 0, .4);
    --transition: 200ms ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

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

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

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

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

/* --- Layout --- */
.app {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 100px;
}

/* --- Header --- */
.header {
    text-align: center;
    padding: 32px 0 24px;
}

.header-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 8px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: var(--text-secondary);
    font-size: .9rem;
    margin-top: 4px;
}

/* --- Token Input --- */
.token-input-area {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.input-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.token-textarea {
    width: 100%;
    min-height: 100px;
    background: transparent;
    border: none;
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: .85rem;
    padding: 16px;
    resize: vertical;
    outline: none;
    word-break: break-all;
    line-height: 1.7;
}

.token-textarea::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

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

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

.btn-primary {
    background: var(--primary-dark);
    border-color: var(--primary);
    color: #fff;
}

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

.btn-sm {
    padding: 4px 10px;
    font-size: .75rem;
}

/* --- Token Stats Bar --- */
.token-stats {
    display: flex;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    flex-wrap: wrap;
    font-size: .8rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-label {
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* --- Decoded Sections --- */
.decoded-section {
    display: none;
}

.decoded-section.visible {
    display: block;
}

.decoded-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.decoded-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.decoded-card.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
    font-weight: 700;
}

.card-header .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.dot-header {
    background: var(--header-color);
}

.dot-payload {
    background: var(--payload-color);
}

.dot-signature {
    background: var(--signature-color);
}

.card-body {
    padding: 16px;
}

.json-display {
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
}

.json-key {
    color: var(--primary);
}

.json-string {
    color: var(--accent-purple);
}

.json-number {
    color: var(--accent-orange);
}

.json-bool {
    color: var(--accent-red);
}

.json-null {
    color: var(--text-muted);
}

/* --- Claims Table --- */
.claims-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
}

.claims-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .5px;
}

.claims-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

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

.claim-name {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--primary);
}

.claim-explanation {
    color: var(--text-secondary);
    font-size: .75rem;
}

.claim-value {
    font-family: var(--font-mono);
    font-size: .75rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.copy-claim {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: .8rem;
    padding: 2px 4px;
}

.copy-claim:hover {
    color: var(--primary);
}

/* --- Timeline --- */
.timeline {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 20px 16px;
    position: relative;
}

.timeline-line {
    flex: 1;
    height: 4px;
    background: var(--border);
    position: relative;
}

.timeline-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width .5s ease;
}

.timeline-point {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

.timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
}

.timeline-dot.active {
    border-color: var(--primary);
    background: var(--primary);
}

.timeline-dot.now {
    border-color: var(--accent-orange);
    background: var(--accent-orange);
}

.timeline-dot.expired {
    border-color: var(--accent-red);
    background: var(--accent-red);
}

.timeline-label {
    font-size: .65rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.timeline-time {
    font-family: var(--font-mono);
    font-size: .7rem;
}

/* --- Expiry Banner --- */
.expiry-banner {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .85rem;
    font-weight: 600;
}

.expiry-banner.show {
    display: flex;
}

.expiry-banner.valid {
    background: rgba(0, 206, 201, .1);
    border: 1px solid rgba(0, 206, 201, .3);
    color: var(--primary);
}

.expiry-banner.expired {
    background: rgba(255, 107, 107, .1);
    border: 1px solid rgba(255, 107, 107, .3);
    color: var(--accent-red);
}

.expiry-countdown {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: .8rem;
}

/* --- Comparison --- */
.compare-section {
    margin-top: 24px;
}

.compare-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.compare-body {
    display: none;
}

.compare-body.open {
    display: block;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* --- Error --- */
.error-banner {
    display: none;
    padding: 12px 16px;
    background: rgba(255, 107, 107, .1);
    border: 1px solid rgba(255, 107, 107, .3);
    border-radius: var(--radius);
    color: var(--accent-red);
    font-size: .85rem;
    margin-bottom: 16px;
}

.error-banner.show {
    display: block;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: .85rem;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    z-index: 200;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .decoded-grid {
        grid-template-columns: 1fr;
    }

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

    .token-stats {
        gap: 8px;
    }

    .header h1 {
        font-size: 1.4rem;
    }
}

@media (prefers-reduced-motion: reduce) {

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

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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