@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-deep: #030712;
    --bg-base: #0b1120;
    --surface: rgba(15, 23, 42, 0.72);
    --surface-elevated: rgba(30, 41, 59, 0.55);
    --surface-hover: rgba(51, 65, 85, 0.45);
    --border: rgba(148, 163, 184, 0.12);
    --border-strong: rgba(148, 163, 184, 0.22);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.35);
    --success: #10b981;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.08);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.5) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.45);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.55);
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.code-font {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* === App shell & ambient background === */
.app-shell {
    background: var(--bg-deep);
    color: var(--text);
    position: relative;
    min-height: 100vh;
}

.app-shell::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59, 130, 246, 0.18), transparent 50%),
        radial-gradient(ellipse 60% 40% at 90% 10%, rgba(16, 185, 129, 0.12), transparent 45%),
        radial-gradient(ellipse 50% 30% at 50% 100%, rgba(139, 92, 246, 0.08), transparent 50%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-base) 100%);
}

.app-shell > * {
    position: relative;
    z-index: 1;
}

.screen-overlay {
    background: rgba(3, 7, 18, 0.92) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* === Glass cards (auto-upgrade existing panels) === */
#app-principal .bg-slate-800.rounded-xl,
#view-terminal .bg-slate-800.rounded-xl,
#view-individual .bg-slate-800.rounded-xl,
#view-catalog .bg-slate-800.rounded-xl,
#view-verif .bg-slate-800.rounded-xl,
#view-help .bg-slate-800.rounded-xl,
#view-reset .bg-slate-800.rounded-xl,
.ui-card {
    background: var(--surface) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-card), var(--shadow-glow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#app-principal .bg-slate-800.rounded-xl:hover {
    border-color: var(--border-strong) !important;
}

.ui-card-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.ui-card-header i {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.625rem;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    font-size: 0.875rem;
}

/* === Header === */
.ui-header {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-card);
}

.ui-header #header-badge {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.ui-header #header-titulo {
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ui-header-actions button,
.ui-header-actions label {
    background: rgba(30, 41, 59, 0.6) !important;
    border: 1px solid var(--border) !important;
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
}

.ui-header-actions button:hover,
.ui-header-actions label:hover {
    background: rgba(51, 65, 85, 0.7) !important;
    border-color: var(--border-strong) !important;
    transform: translateY(-1px);
}

/* === Navigation tabs === */
.ui-nav {
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border) !important;
    border-radius: 1rem !important;
    padding: 0.375rem !important;
    gap: 0.25rem !important;
    max-width: none !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ui-tab {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 0.75rem;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    border: 1px solid transparent;
}

.ui-tab:hover {
    color: var(--text);
    background: rgba(51, 65, 85, 0.35);
}

.ui-tab-active {
    color: #fff !important;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    border-color: rgba(96, 165, 250, 0.3) !important;
    box-shadow: 0 4px 16px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* === Inputs === */
.ui-input,
#app-principal input[type="text"],
#app-principal input[type="number"],
#app-principal input[type="password"],
#app-principal select,
#view-terminal input,
#view-terminal select {
    background: rgba(15, 23, 42, 0.8) !important;
    border: 1px solid var(--border) !important;
    border-radius: 0.75rem !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ui-input:focus,
#app-principal input:focus,
#app-principal select:focus {
    border-color: rgba(59, 130, 246, 0.5) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
    outline: none !important;
}

/* === Vendor selection cards === */
.vendor-card {
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border) !important;
    border-radius: 1.25rem !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.vendor-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.25s;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent);
}

.vendor-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.vendor-card:hover::before {
    opacity: 1;
}

/* === Switch chassis === */
.switch-chassis {
    background: linear-gradient(165deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -2px 8px rgba(0, 0, 0, 0.3),
        0 12px 32px rgba(0, 0, 0, 0.4);
}

#portas-grid-container {
    display: grid;
    gap: 0.35rem;
    padding: 0.75rem !important;
    background: rgba(2, 6, 23, 0.85) !important;
    border: 1px solid rgba(51, 65, 85, 0.5) !important;
    border-radius: 0.875rem !important;
}

.ui-port-btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s;
    border-radius: 0.375rem !important;
}

.ui-port-btn:hover {
    transform: scale(1.08);
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ui-port-btn:active {
    transform: scale(0.96);
}

/* === Palette profiles === */
.ui-palette-btn {
    border-radius: 0.875rem !important;
    transition: all 0.2s ease;
}

.ui-palette-btn.ui-palette-active {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15), 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* === CLI blocks === */
.ui-cli-block {
    background: rgba(15, 23, 42, 0.85) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
    transition: border-color 0.2s;
}

.ui-cli-block:hover {
    border-color: var(--border-strong) !important;
}

.ui-cli-block-header {
    background: rgba(30, 41, 59, 0.5) !important;
    border-bottom: 1px solid var(--border) !important;
}

.ui-cli-code {
    background: rgba(2, 6, 23, 0.9) !important;
    line-height: 1.6;
}

/* === Terminal === */
.terminal-screen {
    background: rgba(2, 6, 23, 0.95) !important;
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
    border-radius: var(--radius-lg);
    box-shadow:
        inset 0 2px 20px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(16, 185, 129, 0.05);
}

/* === Buttons primary glow === */
.ui-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    border: 1px solid rgba(96, 165, 250, 0.3) !important;
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: all 0.2s ease;
}

.ui-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.ui-btn-success {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    border: 1px solid rgba(52, 211, 153, 0.3) !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

/* === Validation & alerts panels === */
#painel-validacao,
#painel-avisos-modelo {
    border-radius: 0.875rem !important;
    backdrop-filter: blur(8px);
}

/* === Modal import === */
@keyframes import-fade-up {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes import-pulse-ring {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
    50% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
}

@keyframes import-scan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

#app-principal:not(.hidden) {
    animation: page-in 0.4s ease-out;
}

.import-modal-panel {
    animation: import-fade-up 0.35s ease-out;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98)) !important;
    border: 1px solid var(--border-strong) !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04) !important;
}

.import-loading-icon {
    animation: import-pulse-ring 1.6s ease-out infinite;
}

.import-scan-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.35), transparent);
    animation: import-scan 1.8s ease-in-out infinite;
}

.import-port-chip {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.import-port-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

#modal-import-switch .absolute.inset-0 {
    backdrop-filter: blur(12px);
}

/* === Model list cards (JS injected) === */
.model-card-btn {
    background: rgba(15, 23, 42, 0.7) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border) !important;
    border-radius: 1rem !important;
    transition: all 0.22s ease;
}

.model-card-btn:hover {
    border-color: rgba(59, 130, 246, 0.4) !important;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

/* === Custom alert toast === */
#custom-alert {
    backdrop-filter: blur(12px);
    border-radius: 1rem !important;
    animation: page-in 0.3s ease-out;
}

/* === Landing hero === */
.landing-badge {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.15));
    border: 1px solid rgba(96, 165, 250, 0.25);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.1);
}

.landing-title {
    background: linear-gradient(135deg, #ffffff 20%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* === App layout: sidebar + main === */
.app-layout {
    display: flex;
    min-height: calc(100vh - 2rem);
    max-width: 1680px;
    margin: 0 auto;
    position: relative;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0 0 2rem 0;
}

@media (min-width: 1024px) {
    .app-main {
        padding-left: 1.5rem;
    }
}

.app-views {
    flex: 1;
}

/* Sidebar */
.ui-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    position: sticky;
    top: 1rem;
    align-self: flex-start;
    max-height: calc(100vh - 2rem);
    z-index: 40;
}

.ui-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.ui-sidebar-logo {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
    flex-shrink: 0;
}

.ui-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.ui-sidebar-section {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.75rem 0.75rem 0.35rem;
    opacity: 0.7;
}

.ui-sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-align: left;
}

.ui-sidebar-item:hover {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border);
}

.ui-sidebar-item-active {
    color: #fff !important;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    border-color: rgba(96, 165, 250, 0.35) !important;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.ui-sidebar-item-danger:hover {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.ui-sidebar-item-muted {
    opacity: 0.85;
}

.ui-sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Topbar */
.ui-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.ui-breadcrumb {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
}

.ui-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.ui-topbar-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.625rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all 0.2s ease;
    cursor: pointer;
}

.ui-topbar-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.ui-mobile-menu {
    display: none;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.625rem;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 35;
}

.sidebar-backdrop.visible {
    display: block;
}

@media (max-width: 1023px) {
    .app-layout {
        flex-direction: column;
    }

    .ui-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(280px, 85vw);
        max-height: 100vh;
        border-radius: 0;
        transform: translateX(-105%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .ui-sidebar.sidebar-open {
        transform: translateX(0);
    }

    .ui-mobile-menu {
        display: inline-flex;
    }

    .app-main {
        padding-left: 0;
        width: 100%;
    }
}

body.sidebar-mobile-open {
    overflow: hidden;
}

#app-principal .ui-header {
    margin-bottom: 1.25rem;
}

/* === Light theme === */
[data-theme="light"] {
    --bg-deep: #f1f5f9;
    --bg-base: #e2e8f0;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-elevated: rgba(248, 250, 252, 0.95);
    --surface-hover: rgba(241, 245, 249, 0.95);
    --border: rgba(148, 163, 184, 0.35);
    --border-strong: rgba(100, 116, 139, 0.4);
    --text: #0f172a;
    --text-muted: #64748b;
    --accent-glow: rgba(59, 130, 246, 0.2);
    --shadow-card: 0 4px 24px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--border);
    --shadow-glow: 0 0 40px rgba(59, 130, 246, 0.06);
}

[data-theme="light"] .app-shell::before {
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59, 130, 246, 0.12), transparent 50%),
        radial-gradient(ellipse 60% 40% at 90% 10%, rgba(16, 185, 129, 0.08), transparent 45%),
        linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

[data-theme="light"] .screen-overlay {
    background: rgba(241, 245, 249, 0.94) !important;
}

[data-theme="light"] .landing-title {
    background: linear-gradient(135deg, #0f172a 20%, #475569 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .ui-header #header-titulo {
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

[data-theme="light"] .ui-sidebar-item-active {
    color: #fff !important;
}

[data-theme="light"] #app-principal input,
[data-theme="light"] #app-principal select,
[data-theme="light"] #view-terminal input,
[data-theme="light"] #view-terminal select {
    color: #0f172a !important;
    background: rgba(255, 255, 255, 0.9) !important;
}

[data-theme="light"] .terminal-screen {
    background: #0f172a !important;
    color: #34d399 !important;
}

[data-theme="light"] .switch-chassis {
    background: linear-gradient(165deg, #cbd5e1 0%, #94a3b8 100%);
    border-color: #64748b;
}

[data-theme="light"] #portas-grid-container {
    background: rgba(15, 23, 42, 0.06) !important;
    border-color: rgba(100, 116, 139, 0.35) !important;
}

[data-theme="light"] .ui-breadcrumb span:last-child {
    color: var(--text) !important;
}

[data-theme="light"] .vendor-card,
[data-theme="light"] .model-card-btn {
    background: rgba(255, 255, 255, 0.75) !important;
}

[data-theme="light"] .text-white {
    color: #0f172a !important;
}

[data-theme="light"] .ui-sidebar-item-active .text-white,
[data-theme="light"] .ui-sidebar-item-active,
[data-theme="light"] .ui-btn-primary,
[data-theme="light"] .ui-btn-success,
[data-theme="light"] #header-badge,
[data-theme="light"] .terminal-screen,
[data-theme="light"] .import-modal-panel .text-white,
[data-theme="light"] button.bg-blue-600,
[data-theme="light"] button.bg-emerald-600 {
    color: #fff !important;
}

[data-theme="light"] .text-slate-100,
[data-theme="light"] .text-slate-200,
[data-theme="light"] .text-slate-300 {
    color: #334155 !important;
}

[data-theme="light"] .text-slate-400,
[data-theme="light"] .text-slate-500 {
    color: #64748b !important;
}

[data-theme="light"] .bg-slate-950,
[data-theme="light"] .bg-slate-900 {
    background-color: rgba(241, 245, 249, 0.9) !important;
}

[data-theme="light"] .ui-cli-code {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

/* === Login === */
.login-panel {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-strong);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: import-fade-up 0.4s ease-out;
}

.login-logo {
    width: 4rem;
    height: 4rem;
    border-radius: 1.125rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px var(--accent-glow);
}

#login-erro span {
    flex: 1;
}

.serial-compat-ok {
    background: rgba(6, 78, 59, 0.25);
    border-color: rgba(16, 185, 129, 0.35);
}

.serial-compat-warn {
    background: rgba(120, 53, 15, 0.2);
    border-color: rgba(245, 158, 11, 0.35);
}

[data-theme="light"] .login-panel h1 {
    color: var(--text);
}

