/* =========================================================================
   onevie-index.css - Tela inicial do OneVie Desk (index.html)
   Tema claro/escuro, painel de conexão (esquerda) e sessões recentes (direita)
   ========================================================================= */

/* ---------- Variáveis de tema ---------- */:root {
    --bg-page: #f4f7fb;
    --bg-gradient-center: #ffffff;
    --surface: #ffffff;
    --surface-input: #f8fafc;
    --surface-hover: #f1f5f9;
    --primary: #3373AB;
    --primary-accent: #2C8CFF;
    --primary-hover: #285D8A;
    --primary-glow: rgba(51, 115, 171, 0.25);
    --text-main: #17212b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --shadow-card: 0 10px 40px -10px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-btn: 0 2px 10px rgba(0,0,0,0.05);
    --radius-input: 12px;
    --radius-card: 24px;
    --radius-btn: 12px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-theme {
    --bg-page: #0f141a;
    --bg-gradient-center: #1a232d;
    --surface: #171e26;
    --surface-input: #1b242d;
    --surface-hover: #232e3a;
    --primary: #3373AB;
    --primary-accent: #2C8CFF;
    --primary-hover: #4a8ec9;
    --primary-glow: rgba(44, 140, 255, 0.35);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #2b3743;
    --shadow-card: 0 10px 40px -10px rgba(0, 0, 0, 0.6), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-btn: 0 2px 10px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    background-image: radial-gradient(circle at top left, var(--bg-gradient-center) 0%, var(--bg-page) 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    padding: 24px 16px;
    transition: background-color var(--transition), color var(--transition);
    user-select: none;
}

.theme-toggle {
    position: fixed;
    top: 22px;
    right: 22px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-btn);
    z-index: 100;
}
.theme-toggle:hover { color: var(--primary-accent); border-color: var(--primary-accent); transform: scale(1.05); }
.theme-toggle svg { width: 20px; height: 20px; }
body.dark-theme #icon-moon { display: none; }
body:not(.dark-theme) #icon-sun { display: none; }

.desk-wrapper {
    width: 100%;
    max-width: 940px;
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .desk-wrapper { grid-template-columns: 1fr; max-width: 440px; }
}

.card-panel {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 36px 32px;
    animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.brand-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.login-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #1B5279 0%, #23699C 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px var(--primary-glow);
    flex-shrink: 0;
}
.login-logo img {
    width: 76%;
    height: 76%;
    object-fit: contain;
    filter: brightness(0) invert(1);
    pointer-events: none;
}

.brand-titles h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}
.brand-titles h1 span { color: var(--primary-accent); }
.brand-titles p {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.server-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    margin-bottom: 20px;
    width: 100%;
    justify-content: space-between;
}
.server-badge .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--warning);
    display: inline-block;
    box-shadow: 0 0 8px var(--warning);
}
.server-badge.online .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.server-badge.offline .dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.meuid-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-input);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-input);
    padding: 12px 16px;
    margin-bottom: 20px;
}
.meuid-box .lbl {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.meuid-box .val {
    font-size: 19px;
    font-weight: 800;
    color: var(--primary-accent);
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.input-group {
    margin-bottom: 16px;
    text-align: left;
}
.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}
.input-group input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-input);
    background: var(--surface-input);
    color: var(--text-main);
    font-size: 15px;
    transition: var(--transition);
    user-select: text;
}
.input-group input.id-input {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 5px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.input-group input:focus {
    border-color: var(--primary-accent);
    background: var(--surface);
    outline: none;
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.status-msg {
    min-height: 20px;
    font-size: 13px;
    font-weight: 600;
    margin: 6px 0 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.status-msg.ok { color: var(--success); }
.status-msg.warn { color: var(--warning); }
.status-msg.err { color: var(--danger); }
.status-msg.neutral { color: var(--text-muted); }

/* ---------- Escolha do que fazer (tela, arquivos, prompt) ---------- */
.escolha-titulo {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 4px 0 10px;
}

.opcao-textos { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; text-align: left; }
.opcao-titulo { font-size: 15px; font-weight: 700; }
.opcao-sub { font-size: 12px; font-weight: 500; opacity: 0.85; margin-top: 2px; }

.opcoes-ferramentas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.btn-opcao {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius-btn);
    border: 1px solid var(--border-color);
    background: var(--surface-input);
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.btn-opcao .opcao-titulo { font-size: 14px; }
.btn-opcao .opcao-sub { color: var(--text-muted); opacity: 1; }
.btn-opcao:hover:not(:disabled) {
    border-color: var(--primary-accent);
    background: var(--surface-hover);
    transform: translateY(-1px);
}
.btn-opcao:disabled { opacity: 0.48; cursor: not-allowed; }

.opcao-icone {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--primary-glow);
    color: var(--primary-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.opcao-icone svg { width: 18px; height: 18px; }

/* Processos, Serviços e Monitor: três botões menores lado a lado (ícone em cima, nome embaixo) */
.opcoes-ferramentas.trio { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.opcoes-ferramentas.trio .btn-opcao { flex-direction: column; justify-content: center; gap: 6px; padding: 10px 6px; min-width: 0; }
.opcoes-ferramentas.trio .opcao-textos { align-items: center; text-align: center; min-width: 0; max-width: 100%; }
.opcoes-ferramentas.trio .opcao-titulo { font-size: 13px; }
.opcoes-ferramentas.trio .opcao-sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.opcoes-ferramentas.trio .opcao-icone { width: 32px; height: 32px; }

@media (max-width: 420px) {
    .opcoes-ferramentas { grid-template-columns: 1fr; }
    .opcoes-ferramentas.trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .opcoes-ferramentas.trio .opcao-sub { display: none; }
}

.btn-primary {
    width: 100%;
    height: 58px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 20px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.06);
}
.btn-primary:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    transform: none;
}

/* Painel Direito: Sessões Recentes (igual ConexaoRecenteHost.cs) */
.recents-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.recents-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
}
.btn-refresh {
    background: var(--surface-input);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}
.btn-refresh:hover { border-color: var(--primary-accent); color: var(--primary-accent); }

/* Atualizar pagina: mesmo visual do btn-refresh, so com o icone, a esquerda do botao de tema */
.btn-refresh-pagina {
    position: fixed;
    top: 27px;
    right: 76px;
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    z-index: 100;
}
.btn-refresh-pagina:disabled { cursor: wait; opacity: 0.7; }
.btn-refresh-pagina:disabled svg { animation: girarAtualizarPagina 0.9s linear infinite; }
@keyframes girarAtualizarPagina { to { transform: rotate(360deg); } }

/* Versao do cliente: discreta, no canto inferior do card de conexao */
.versao-app {
    position: absolute;
    right: 16px;
    bottom: 10px;
    font-size: 10px;
    color: gray;
    opacity: 0.7;
    user-select: none;
}

.recents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
    max-height: 430px;
    overflow-y: auto;
    padding-right: 4px;
}

.host-card {
    position: relative;
    height: 148px;
    border-radius: 14px;
    overflow: hidden;
    background: #252f3a;
    border: 2px solid rgba(44, 140, 255, 0.45);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 12px;
    background-size: cover;
    background-position: center;
}
.host-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(15,20,26,0.35) 0%, rgba(15,20,26,0.85) 100%);
    z-index: 1;
}
.host-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary-accent);
    box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}
.host-card-top, .host-card-bottom {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.host-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(15, 20, 26, 0.72);
    color: #fff;
    backdrop-filter: blur(4px);
}
.host-status-pill .s-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}
.host-status-pill.online .s-dot {
    background: #2ecc71;
    box-shadow: 0 0 8px #2ecc71;
}
.host-remove-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 20, 26, 0.65);
    color: #cbd5e1;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.host-remove-btn:hover { background: var(--danger); color: #fff; }

.host-id-label {
    color: #ffffff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 1.5px;
    font-variant-numeric: tabular-nums;
}
.host-date-label {
    color: #cbd5e1;
    font-size: 11px;
}

.empty-recents {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 13px;
    border: 1px dashed var(--border-color);
    border-radius: 14px;
}

.desk-footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- Logo: texto de reserva quando a imagem não carrega ---------- */
.login-logo .logo-texto { color: #fff; font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }

/* ---------- Sessões recentes: aviso de onde ficam salvas ---------- */
.recents-info {
    font-size: 11.5px;
    color: var(--text-muted);
    margin: -10px 0 14px;
}

/* ---------- Card: nome amigável + ID + botões ---------- */
.host-card-acoes { display: flex; gap: 6px; }
.host-edit-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 20, 26, 0.65);
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.host-edit-btn:hover { background: var(--primary-accent); color: #fff; }
.host-edit-btn svg { width: 13px; height: 13px; }

.host-nome-label {
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.host-card .host-nome-label + .host-id-label { font-size: 12.5px; color: #dbe4ee; letter-spacing: 1px; font-weight: 600; }
.host-card-bottom > div { min-width: 0; flex: 1; }

/* Edição do nome no próprio card */
.host-nome-input {
    width: 100%;
    height: 30px;
    padding: 0 8px;
    border: 1.5px solid var(--primary-accent);
    border-radius: 8px;
    background: rgba(15, 20, 26, 0.85);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    outline: none;
    user-select: text;
}
.host-nome-dica { color: #cbd5e1; font-size: 10.5px; margin-top: 3px; }
/* =========================================================================
   PWA (igual ao index_modelo.html): banner de instalação e guia do Safari
   ========================================================================= */
.pwa-install-banner {
    display: none;
    margin-top: 18px;
    padding: 12px 16px;
    background: var(--surface-input);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-input);
    font-size: 12px;
    color: var(--text-muted);
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
}
.pwa-install-banner.show { display: flex; }
.pwa-install-banner button {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.pwa-install-banner button:hover { background: var(--primary-hover); }

/* Modal com os passos de instalação no Safari (iOS / macOS) */
.pwa-safari-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 20, 26, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pwa-safari-modal.show { display: flex; animation: fadeUp 0.25s ease forwards; }
.pwa-safari-box {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
    width: 100%;
    max-width: 370px;
    padding: 26px 22px 22px;
    text-align: left;
    color: var(--text-main);
}
.pwa-safari-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.pwa-safari-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1B5279 0%, #23699C 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 6px 14px var(--primary-glow);
    color: #fff;
    font-weight: 800;
    font-size: 14px;
}
.pwa-safari-icon img { width: 78%; height: 78%; object-fit: contain; filter: brightness(0) invert(1); }
.pwa-safari-title { font-size: 16px; font-weight: 800; line-height: 1.25; }
.pwa-safari-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.pwa-safari-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.pwa-safari-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-main);
}
.pwa-safari-step-badge {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(51, 115, 171, 0.15);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 13px;
    flex-shrink: 0;
}
.pwa-safari-step svg { width: 18px; height: 18px; color: var(--primary); vertical-align: middle; display: inline-block; margin: 0 2px; }
.pwa-safari-close {
    width: 100%;
    height: 44px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}
.pwa-safari-close:hover { background: var(--primary-hover); }