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

:root {
    --glass-bg: #ffffff;
    --glass-bg-strong: #ffffff;
    --glass-border: rgba(0, 0, 0, 0.06);
    --glass-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    --glass-shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.07);

    --sky: #0ea5e9;
    --sky-light: #38bdf8;
    --sky-dark: #0284c7;
    --sky-glow: rgba(14, 165, 233, 0.2);

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --success: #10b981;
    --danger: #ef4444;

    --radius-card: 16px;
    --radius-pill: 9999px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    background: #f8f9fb;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

#app {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 36px 16px 20px;
    max-width: 480px;
    margin: 0 auto;
}

/* ── HEADER ── */
header {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 24px;
    padding: 4px 22px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    border-radius: 9999px;
    box-shadow: var(--glass-shadow);
}

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

.logo .logo-icon {
    font-size: 20px;
}

.logo .logo-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.logo .logo-badge {
    font-family: 'Inter', sans-serif;
    color: white;
    background: var(--sky);
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1px;
}

#user-info {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

/* ── SECTION HEADINGS ── */
h2 {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    padding-left: 4px;
}

/* ── GRID ── */
.section-header {
    margin-bottom: 16px;
    padding-left: 4px;
}

.section-header .badge {
    display: inline-block;
    padding: 4px 10px;
    background: #f0f9ff;
    color: #0369a1;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 6px;
    margin-bottom: 6px;
}

.section-header p {
    font-size: 12px;
    color: #64748b;
    margin: 0;
}

.grid {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

/* ── CARD ── */
.control-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-card);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--glass-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    animation: fadeSlideUp 0.35s ease both;
    animation-delay: calc(var(--card-i, 0) * 0.06s);
}

.control-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7) 30%, rgba(255, 255, 255, 0.7) 70%, transparent);
}

/* Icon badge */
.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--icon-bg, rgba(14, 165, 233, 0.08));
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    transform: translateY(-1px);
    box-shadow: var(--glass-shadow-hover);
}

.clickable:active {
    transform: scale(0.98);
    box-shadow: var(--glass-shadow);
}

.control-card .info {
    flex: 1;
    min-width: 0;
}

.control-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.control-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 1px;
}

/* Arrow */
.control-card .arrow {
    color: var(--text-muted);
    font-size: 20px;
    font-weight: 300;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s;
}

.clickable:hover .arrow {
    transform: translateX(2px);
    color: var(--sky);
}

/* ── LIQUID GLASS TOGGLE ── */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    border-radius: 100px;
    transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.4s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15),
                inset 0 -1px 2px rgba(255,255,255,0.3),
                0 1px 2px rgba(0,0,0,0.05);
}

/* ── Glass Ball Indicator ── */
.slider::before {
    position: absolute;
    content: '';
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    border-radius: 50%;
    z-index: 2;
    /* Glass ball gradient — specular highlight at top-left */
    background:
        radial-gradient(circle at 35% 25%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.4) 30%, transparent 60%),
        radial-gradient(circle at 50% 80%, rgba(0,0,0,0.04) 0%, transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #f0f0f0 50%, #e8e8e8 100%);
    /* Multi-layer glass shadow */
    box-shadow:
        0 2px 6px rgba(0,0,0,0.2),
        0 4px 12px rgba(0,0,0,0.1),
        inset 0 1px 2px rgba(255,255,255,1),
        inset 0 -2px 4px rgba(0,0,0,0.08);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
                width 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                border-radius 0.15s ease,
                box-shadow 0.4s ease;
}

/* ── Liquid Squish on Press ── */
.switch:active .slider::before {
    width: 28px;
    border-radius: 14px / 11px;
}

.switch:active input:checked + .slider::before {
    transform: translateX(18px);
}

/* ── Checked State ── */
input:checked + .slider {
    background: var(--sky);
    box-shadow:
        inset 0 2px 4px rgba(0,0,0,0.12),
        inset 0 -1px 2px rgba(255,255,255,0.15),
        0 0 14px var(--sky-glow),
        0 0 28px rgba(14,165,233,0.15);
}

input:checked + .slider::before {
    transform: translateX(24px);
    /* Glass ball picks up blue ambient lighting */
    background:
        radial-gradient(circle at 35% 25%, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.5) 25%, transparent 55%),
        radial-gradient(circle at 50% 80%, rgba(14,165,233,0.08) 0%, transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #f4f9ff 50%, #e8f4fd 100%);
    box-shadow:
        0 2px 6px rgba(14,165,233,0.25),
        0 4px 14px rgba(14,165,233,0.12),
        inset 0 1px 2px rgba(255,255,255,1),
        inset 0 -2px 4px rgba(14,165,233,0.06);
}

/* ── BACK BUTTON ── */
#back-btn {
    background: var(--sky);
    border: none;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    padding: 10px 18px;
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 10px var(--sky-glow);
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: fadeSlideUp 0.3s ease both;
}

#back-btn:active {
    transform: scale(0.95);
    opacity: 0.9;
}

#back-btn svg {
    width: 14px;
    height: 14px;
}

/* ── STATUS BADGE ── */
.status-badge {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    background: rgba(209, 250, 229, 0.6);
    color: #059669;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

.status-badge.inactive {
    background: rgba(241, 245, 249, 0.6);
    color: var(--text-muted);
}

.status-badge.inactive::before {
    background: var(--text-muted);
    box-shadow: none;
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ── FOOTER ── */
footer {
    margin-top: auto;
    padding-top: 20px;
    text-align: center;
    animation: fadeSlideUp 0.5s ease both;
    animation-delay: 0.2s;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    box-shadow: var(--glass-shadow);
}

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

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

/* ── LOADING ── */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid rgba(14, 165, 233, 0.15);
    border-top-color: var(--sky);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── ANIMATIONS ── */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

/* ── UTILITIES ── */
.hidden {
    display: none !important;
}

section {
    transition: opacity 0.2s ease;
}

/* ── ACTION BUTTONS ── */
.action-btn {
    background: linear-gradient(135deg, var(--sky), var(--sky-dark));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px var(--sky-glow);
    font-family: 'Outfit', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--sky-glow);
    filter: brightness(1.05);
}

.action-btn:active {
    transform: translateY(0) scale(0.96);
}

.action-btn.loading {
    opacity: 0.85;
    pointer-events: none;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: white;
}

.action-btn .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

/* ── TLDR CONTAINER ── */
#tldr-container {
    margin-top: 12px;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--glass-shadow);
    animation: fadeSlideUp 0.4s ease both;
}

.tldr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.tldr-header span {
    font-size: 12px;
    font-weight: 700;
    color: var(--sky);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#close-tldr-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#tldr-content {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

#tldr-content ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#tldr-content li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 10px;
}

#tldr-content li::before {
    content: '•';
    position: absolute;
    left: 4px;
    color: var(--sky);
    font-weight: bold;
}

#tldr-content p {
    margin-bottom: 10px;
}

#tldr-content strong {
    font-weight: 700;
    color: #0f172a;
}

#tldr-content em {
    font-style: italic;
    color: #475569;
}

#tldr-content .summary-heading,
#tldr-content h3,
#tldr-content h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--sky);
    margin: 14px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f1f5f9;
}

#tldr-content h4 {
    font-size: 12.5px;
    color: #64748b;
    border-bottom: none;
}

/* ── CONFIG INPUTS ── */
.config-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.config-input {
    width: 60px;
    height: 36px;
    border: 1.5px solid var(--glass-border);
    border-radius: 12px;
    text-align: center;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255,255,255,0.6);
    outline: none;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
    appearance: none;
}

.config-input::-webkit-inner-spin-button,
.config-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.config-input:focus {
    background: white;
    border-color: var(--sky);
    box-shadow: 0 0 0 4px var(--sky-glow);
}

.config-unit {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 12px;
}

/* ── FEDERATION CARD ── */
.fed-card {
    margin-bottom: 24px;
}

.fed-card #fed-title {
    color: var(--text-primary);
}

.fed-card #fed-names {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── FEDERATION MGMT ── */
.fed-actions {
    display: none; /* Removed old layout */
}

.fed-action-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
}

.fed-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: rgba(255, 255, 255, 0.4);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.fed-input-wrap .config-input {
    flex: 1;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 8px 12px;
    text-align: left;
}

.fed-input-wrap .action-btn {
    margin: 0;
    padding: 8px 16px;
    white-space: nowrap;
}

.fed-action-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.fed-action-row .action-btn {
    height: 36px;
    padding: 0 16px;
    border-radius: 10px;
}

.fed-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    padding: 10px 14px;
    border-radius: 14px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.fed-item:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.fed-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.03);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
}

.fed-item-info {
    display: flex;
    flex-direction: column;
}

.fed-item-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.fed-item-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.id-badge {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: 500;
}

.copy-badge {
    background: var(--sky-light);
    color: var(--sky-dark);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.copy-badge:hover {
    background: var(--sky);
    color: white;
}

.leave-btn {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.leave-btn:hover {
    background: #fecaca;
}

/* ── SUB-OPTIONS ── */
.sub-options {
    margin: -8px 12px 16px 12px;
    padding: 14px;
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.02);
}

.sub-options.hidden {
    display: none;
}

.sub-option-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sub-option-card h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.sub-option-card p {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── SMALL SWITCH VARIANT ── */
.switch.is-small {
    width: 36px;
    height: 20px;
}

.switch.is-small .slider::before {
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
}

.switch.is-small:active .slider::before {
    width: 20px;
    border-radius: 8px;
}

.switch.is-small input:checked + .slider::before {
    transform: translateX(16px);
}

/* ── BACK BUTTON ── */
.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    width: fit-content;
}

.back-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.08) 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
}

.back-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.back-btn svg {
    transition: transform 0.3s ease;
    color: var(--sky);
}

.back-btn:hover svg {
    transform: translateX(-3px);
}

/* ── DANGER BUTTON ── */
.danger-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2) !important;
}

.danger-btn:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%) !important;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3) !important;
}

/* ── FED ACTION CARD ENHANCEMENTS ── */
.fed-action-card {
    flex-direction: column;
    align-items: stretch;
    height: auto;
}

.fed-action-card .info {
    margin-bottom: 12px;
}

.fed-input-wrap {
    display: flex;
    gap: 8px;
    width: 100%;
}

.fed-input-wrap .config-input {
    flex: 1;
    min-width: 0;
}

.hidden {
    display: none !important;
}

/* ── SINGLE FED ACTION ── */
.fed-actions-single {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.fed-actions-single .fed-action-card {
    max-width: 500px;
    width: 100%;
}
