/* ============================================================
   Triage IFrame – Global Design System
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --color-bg: #fff;
    --color-surface: #f6f5f1;
    --color-surface-2: #f6f5f1;
    --color-surface-3: #f6f5f1;
    --color-border: rgba(0, 0, 0, 0.08);
    --color-border-bright: rgba(0, 0, 0, 0.16);

    --color-primary: #0b3b4a;
    --color-primary-glow: #1c4c5b;
    --color-primary-light: #386c7c;
    --color-accent: #00ada6;
    --color-accent-glow: rgba(0, 173, 166, 0.25);
    --color-danger: #ff4d6d;
    --color-warning: #ffb347;
    --color-success: #4ade80;

    --color-text-primary: #00ada6;
    --color-text-secondary: #364485;
    --color-text-muted: #4d5580;

    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-glow: 0 0 40px rgba(108, 99, 255, 0.15);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-float: 0 8px 40px rgba(0, 0, 0, 0.6);

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-med: 280ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
    height: 100%;
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* ---------- Loading Screen ---------- */
.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 24px;
    background: var(--color-bg);
}

.loader-ring {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    animation: spin 1s linear infinite;
    position: relative;
}

.loader-ring-inner {
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--color-accent);
    animation: spin 0.7s linear infinite reverse;
}

.loader-text {
    color: var(--color-text-secondary);
    font-size: 13px;
    letter-spacing: 0.05em;
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* ---------- Error UI ---------- */
#blazor-error-ui {
    background: var(--color-danger);
    bottom: 0;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.4);
    display: none;
    left: 0;
    padding: 0.8rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: white;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#blazor-error-ui .reload {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    margin-left: auto;
    opacity: 0.8;
}

#blazor-error-ui[style*="display: none"],
#blazor-error-ui:not([style]) {
    display: none !important;
}

/* ---------- App Shell ---------- */
.app-shell {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Top Navigation Bar ---------- */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: 56px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.top-bar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    opacity: 0.4;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
    color: var(--color-text-primary);
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 0 12px var(--color-primary-glow);
}

.top-bar-divider {
    width: 1px;
    height: 24px;
    background: var(--color-border);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--color-text-secondary);
    background: var(--color-surface-2);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--color-border);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-text-muted);
    transition: background var(--transition-med), box-shadow var(--transition-med);
}

.status-dot.active {
    background: var(--color-accent);
    box-shadow: 0 0 8px var(--color-accent-glow);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        box-shadow: 0 0 6px var(--color-accent-glow);
    }

    50% {
        box-shadow: 0 0 14px var(--color-accent-glow), 0 0 6px var(--color-accent);
    }
}

.top-bar-spacer {
    flex: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    outline: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: 0 0 20px var(--color-primary-glow);
}

.btn-primary:hover {
    background: var(--color-primary-light);
    box-shadow: 0 0 28px var(--color-primary-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.btn-ghost:hover {
    background: var(--color-surface-2);
    color: var(--color-text-primary);
    border-color: var(--color-border-bright);
}

.btn-danger {
    background: transparent;
    color: var(--color-danger);
    border-color: rgba(255, 77, 109, 0.3);
}

.btn-danger:hover {
    background: rgba(255, 77, 109, 0.12);
    border-color: var(--color-danger);
}

.request-count-badge {
    background: var(--color-primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ---------- Main Content Layout ---------- */
.main-content {
    display: grid;
    grid-template-columns: 1fr 420px;
    overflow: hidden;
    height: 100%;
}

/* ---------- IFrame Panel ---------- */
.iframe-panel {
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
    position: relative;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.panel-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.panel-url {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--color-text-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 3px 8px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.iframe-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.iframe-wrapper iframe {
    width: 100vw;
    height: 100vh;
    border: none;
    display: block;
    background: white;
}
    .iframe-wrapper iframe.aside-menu {
        width: 78.1vw;
        height: 89.1vh;
    }

.iframe-overlay-label {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 20px;
    pointer-events: none;
}

/* ---------- Capture Panel ---------- */
.capture-panel {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    overflow: hidden;
}

.label-autoscroll {
    font-size: 11px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.input-accent-primary {
    accent-color: var(--color-primary);
}

/* ---------- Capture Toolbar ---------- */
.capture-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    flex-wrap: wrap;
    background: var(--color-surface-2);
}

.filter-input {
    flex: 1;
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

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

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

.btn-cancel {
    padding: 5px 8px;
}

.btn-wrapper-copy-json {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.btn-copy-json {
    font-size: 10px;
    padding: 4px 8px;
}

/* ---------- Request List ---------- */
.request-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.request-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--color-text-muted);
    user-select: none;
}

.request-list-empty .empty-icon {
    font-size: 36px;
    opacity: 0.5;
}

.request-list-empty p {
    font-size: 13px;
    text-align: center;
}

/* ---------- Request Item ---------- */
.request-item {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    animation: slideIn 200ms ease-out;
    overflow: hidden;
    min-height: 40px;
}

.status-item {
    font-size: 10px;
    font-family: var(--font-mono);
}

    .status-item.success {
        color: #4ade80;
    }

    .status-item.redirect {
        color: #ffb347;
    }

    .status-item.client-error {
        color: #ff4d6d;
    }

    .status-item.server-error {
        color: #ff4d6d;
    }

    .status-item.unknown {
        color: #8b93b8;
    }

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(8px);
    }

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

.request-item:hover {
    border-color: var(--color-border-bright);
    background: var(--color-surface-3);
    transform: translateX(-2px);
}

.request-item.expanded {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary-glow), var(--shadow-card);
    min-height: 310px;
}

.request-item.expanded .request-detail{
    height: 200px;
}

.request-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
}

.method-badge {
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 2px 7px;
    border-radius: 4px;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.method-GET {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.method-POST {
    background: rgba(108, 99, 255, 0.15);
    color: #8b85ff;
    border: 1px solid rgba(108, 99, 255, 0.3);
}

.method-PUT {
    background: rgba(255, 179, 71, 0.15);
    color: #ffb347;
    border: 1px solid rgba(255, 179, 71, 0.3);
}

.method-DELETE {
    background: rgba(255, 77, 109, 0.15);
    color: #ff4d6d;
    border: 1px solid rgba(255, 77, 109, 0.3);
}

.method-PATCH {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
    border: 1px solid rgba(0, 212, 170, 0.3);
}

.method-OPTIONS {
    background: rgba(139, 147, 184, 0.15);
    color: #8b93b8;
    border: 1px solid rgba(139, 147, 184, 0.3);
}

.method-other {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.request-url {
    flex: 1;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.request-time {
    font-size: 10px;
    color: var(--color-text-muted);
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.request-source-tag {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.source-postmessage {
    background: rgba(0, 212, 170, 0.15);
    color: var(--color-accent);
    border: 1px solid rgba(0, 212, 170, 0.25);
}

.source-network {
    background: rgba(255, 179, 71, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(255, 179, 71, 0.25);
}

.source-performance {
    background: rgba(108, 99, 255, 0.15);
    color: var(--color-primary-light);
    border: 1px solid rgba(108, 99, 255, 0.25);
}

/* ---------- Request Detail (expanded) ---------- */
.request-detail {
    border-top: 1px solid var(--color-border);
    padding: 10px;
    background: var(--color-bg);
    animation: expandDown 150ms ease-out;
}

@keyframes expandDown {
    from {
        opacity: 0;
        transform: scaleY(0.95);
    }

    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

.detail-section {
    margin-bottom: 10px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.detail-value {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--color-text-secondary);
    word-break: break-all;
    background: var(--color-surface-2);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* ---------- Capture Stats Bar ---------- */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 12px;
    background: var(--color-surface-2);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--color-text-muted);
}

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

/* ---------- Animated Enter ---------- */
.fade-in {
    animation: fadeIn 300ms ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* ---------- Error Container ---------- */

.error-container {
    width: 200px;
    height: 140px;
    position: absolute;
    top: 44%;
    left: 45%;
    padding: 20px;
    background-color: #fff;
    border: red solid 1px;
    border-radius: 10px;
    margin-bottom: 15px;
    color: black;
}

.error-code {
    color: darkgray;
}