/* ========================================
   JWT Inspector — Arctic Blue Theme
   ======================================== */

:root {
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --secondary: #60A5FA;
    --accent: #F59E0B;
    --bg: #0A1022;
    --bg-surface: #111830;
    --bg-elevated: #172040;
    --bg-input: #0D1428;
    --border: #1E2D50;
    --border-focus: #3B82F6;
    --text: #E0E8F5;
    --text-muted: #6B82A8;
    --text-dim: #3D5278;
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
    --success: #10B981;
    --error: #EF4444;
    --seg-header: #F43F5E;
    --seg-payload: #8B5CF6;
    --seg-sig: #3B82F6;
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    font-size: 1.05rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
}

.header-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--primary);
}

/* Main */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px;
    gap: 20px;
}

/* JWT Input */
.jwt-input {
    width: 100%;
    min-height: 80px;
    background: var(--bg-surface);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    word-break: break-all;
    transition: border-color var(--transition);
}

.jwt-input:focus {
    border-color: var(--border-focus);
}

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

/* Placeholder */
.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 60px 20px;
    color: var(--text-dim);
    text-align: center;
}

/* Segments */
.segments {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 0.75rem;
    line-height: 1.6;
    word-break: break-all;
    overflow-x: auto;
    margin-bottom: 20px;
}

.seg-header {
    color: var(--seg-header);
}

.seg-payload {
    color: var(--seg-payload);
}

.seg-signature {
    color: var(--seg-sig);
}

.seg-dot {
    color: var(--text-dim);
}

/* Panels */
.panels {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

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

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

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

.panel-json {
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    max-height: 300px;
}

.btn-copy {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

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

/* Claims */
.claims {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.claim-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    padding: 4px 0;
}

.claim-key {
    font-family: var(--mono);
    color: var(--secondary);
    font-weight: 500;
    min-width: 40px;
}

.claim-value {
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.8rem;
}

.claim-desc {
    color: var(--text-muted);
    font-size: 0.78rem;
    flex: 1;
}

.claim-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

.claim-badge.expired {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.claim-badge.valid {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.claim-badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent);
}

/* Verify */
.verify-section {
    padding: 14px 16px;
}

.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.form-row input {
    flex: 1;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 0.85rem;
    outline: none;
}

.form-row input:focus {
    border-color: var(--border-focus);
}

.form-row input::placeholder {
    color: var(--text-dim);
}

.btn-primary-sm {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary-sm:hover {
    filter: brightness(1.1);
}

.verify-result {
    font-size: 0.85rem;
    font-weight: 500;
}

.verify-result.verified {
    color: var(--success);
}

.verify-result.failed {
    color: var(--error);
}

/* JSON colors */
.json-key {
    color: var(--secondary);
}

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

.json-number {
    color: #F472B6;
}

.json-boolean {
    color: #34D399;
}

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

/* Compare Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-wide {
    width: 95%;
    max-width: 800px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

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

.compare-col label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.compare-input {
    width: 100%;
    min-height: 60px;
    background: var(--bg-input);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 0.78rem;
    resize: vertical;
    outline: none;
    word-break: break-all;
}

.compare-input:focus {
    border-color: var(--border-focus);
}

.compare-json {
    margin-top: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    max-height: 200px;
    overflow: auto;
}

.compare-diff {
    margin-top: 14px;
    font-size: 0.82rem;
}

.diff-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    font-family: var(--mono);
    font-size: 0.78rem;
}

.diff-key {
    color: var(--secondary);
    min-width: 50px;
}

.diff-a {
    color: var(--seg-header);
}

.diff-b {
    color: var(--seg-sig);
}

.diff-same {
    color: var(--text-dim);
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    max-width: 300px;
}

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

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

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

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

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

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

@media (max-width: 600px) {
    .compare-grid {
        grid-template-columns: 1fr;
    }

    .header-actions {
        gap: 4px;
    }
}