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

:root {
    /* Tema Claro (Padrão) - Cores Complementares da Logo */
    --bg-page: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --panel-bg: rgba(255, 255, 255, 0.75);
    --panel-border: rgba(0, 42, 79, 0.08);
    --primary: #002a4f; /* Azul Marinho da Logo */
    --primary-rgb: 0, 42, 79;
    --primary-hover: #001c36;
    --primary-glow: rgba(0, 42, 79, 0.1);
    --secondary: #688195; /* Azul Aço da Logo */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #002a4f; /* Textos Escuros em Marinho */
    --text-title: #002a4f;
    --text-muted: #64748b;
    --input-bg: #ffffff;
    --input-border: rgba(0, 42, 79, 0.12);
    --input-focus: #00508f;
    --sidebar-bg: #ffffff;
    --sidebar-border: rgba(0, 42, 79, 0.08);
    --sidebar-text: #64748b;
    --sidebar-text-active: #002a4f;
    --shadow: 0 10px 30px rgba(0, 42, 79, 0.04);
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Variaveis de Cores Semanticas de Status Alto Contraste (Claro) */
    --danger-text: #c2410c;
    --danger-bg: rgba(194, 65, 12, 0.08);
    --info-text: #1d4ed8;
    --info-bg: rgba(29, 78, 216, 0.08);
    --success-text: #047857;
    --success-bg: rgba(4, 120, 87, 0.08);
}

body.dark {
    /* Tema Escuro (Modo Dark Original) */
    --bg-page: #050b14;
    --bg-gradient: linear-gradient(135deg, #001224 0%, #002a4f 50%, #010810 100%);
    --panel-bg: rgba(30, 41, 59, 0.45);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary: #00508f; /* Azul Royal */
    --primary-rgb: 0, 80, 143;
    --primary-hover: #003e70;
    --primary-glow: rgba(0, 80, 143, 0.35);
    --secondary: #688195;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc; /* Textos Claros */
    --text-title: #ffffff;
    --text-muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus: #688195;
    --sidebar-bg: #0b0f19;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    
    /* Variaveis de Cores Semanticas de Status Alto Contraste (Escuro) */
    --danger-text: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.15);
    --info-text: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.15);
    --success-text: #34d399;
    --success-bg: rgba(52, 211, 153, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-x: hidden;
    padding: 2rem 1rem;
    line-height: 1.5;
}


/* Container principal */
.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    margin-bottom: 2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    box-shadow: 0 25px 50px rgba(99, 102, 241, 0.1);
}

/* Cabeçalho */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #ffffff, #818cf8, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Indicação / Badge de Padrinho */
.ref-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(99, 102, 241, 0.15);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    margin-top: 1rem;
    color: #a5b4fc;
    gap: 0.5rem;
}

.ref-badge strong {
    color: #ffffff;
}

/* Formulário e Grid */
.form-group-full {
    grid-column: span 2;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .form-group-full {
        grid-column: span 1;
    }
}

/* Seleção de Tipo */
.type-selector {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 0.75rem;
    border-radius: 9999px;
    border: 1px solid var(--panel-border);
}

.type-option {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
    padding: 0.5rem 1.5rem;
    border-radius: 9999px;
}

.type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.type-option .checkmark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid var(--text-muted);
    margin-right: 0.75rem;
    display: inline-block;
    transition: border-color 0.2s, background-color 0.2s;
}

.type-option input[type="radio"]:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

.type-option input[type="radio"]:checked ~ span:not(.checkmark) {
    color: #ffffff;
}

.type-option:hover {
    color: #ffffff;
}

/* Seções de Campos */
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary);
    margin: 2.5rem 0 1.5rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--secondary);
    border-radius: 2px;
}

/* Campos de entrada */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

input, select, textarea {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-main);
    padding: 0.85rem 1rem;
    font-size: 1rem;
    font-family: var(--font-sans);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 4px rgba(0, 42, 79, 0.1);
    background-color: var(--input-bg);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}


textarea {
    resize: vertical;
    min-height: 100px;
}

/* Botões */
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: var(--primary);
    color: #ffffff;
    font-weight: 600;
    border: none;
    border-radius: 14px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
    font-family: var(--font-sans);
    width: 100%;
    margin-top: 2rem;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.2);
}

.btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.35);
}

.btn:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

/* Modal / Sucesso */
.success-card {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid var(--success);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 1.5rem auto;
    color: var(--success);
    font-size: 2.5rem;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.success-card h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.success-card p.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.links-container {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: left;
    margin-bottom: 2rem;
}

.link-item {
    margin-bottom: 1.5rem;
}

.link-item:last-child {
    margin-bottom: 0;
}

.link-item label {
    font-weight: 700;
    color: var(--secondary);
    display: block;
    margin-bottom: 0.5rem;
}

.copy-wrapper {
    display: flex;
    gap: 0.75rem;
}

.copy-wrapper input {
    font-family: monospace;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.3);
}

.btn-copy {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    border-radius: 12px;
    width: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Dashboard Styles */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-title);
    margin-bottom: 0.25rem;
    background: none;
    -webkit-text-fill-color: initial;
}

.dashboard-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .dashboard-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

.dashboard-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-nav .nav-link {
    color: var(--text-muted) !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--panel-border) !important;
    padding: 0.5rem 1rem !important;
    border-radius: 8px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.2s !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.35rem !important;
    box-shadow: var(--shadow) !important;
}

.dashboard-nav .nav-link.active, .dashboard-nav .nav-link:hover {
    color: var(--primary) !important;
    background: rgba(var(--primary-rgb), 0.08) !important;
    border-color: var(--primary) !important;
}

body.dark .dashboard-nav .nav-link.active, body.dark .dashboard-nav .nav-link:hover {
    color: #ffffff !important;
    background: rgba(var(--primary-rgb), 0.3) !important;
    border-color: var(--primary) !important;
}

/* Botão Sair premium de alto contraste */
.btn-logout {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #dc2626 !important;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #dc2626;
    color: #ffffff !important;
    border-color: #dc2626;
}

body.dark .btn-logout {
    color: #f87171 !important;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

body.dark .btn-logout:hover {
    background: #ef4444;
    color: #ffffff !important;
    border-color: #ef4444;
}

/* Botões de Ação na Tabela com Alto Contraste */
.btn-action {
    font-size: 11px !important;
    padding: 0.35rem 0.6rem !important;
    cursor: pointer !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    transition: all 0.2s !important;
    outline: none !important;
    text-decoration: none !important;
}

.btn-action.btn-action-primary {
    background: rgba(var(--primary-rgb), 0.08) !important;
    border: 1px solid var(--panel-border) !important;
    color: var(--text-title) !important;
}
.btn-action.btn-action-primary:hover {
    background: var(--primary) !important;
    color: #ffffff !important;
    border-color: var(--primary) !important;
}

.btn-action.btn-action-success {
    background: rgba(16, 185, 129, 0.1) !important;
    border: 1px solid rgba(16, 185, 129, 0.2) !important;
    color: #059669 !important;
}
.btn-action.btn-action-success:hover {
    background: #10b981 !important;
    color: #ffffff !important;
    border-color: #10b981 !important;
}
body.dark .btn-action.btn-action-success {
    background: rgba(16, 185, 129, 0.2) !important;
    border: 1px solid rgba(16, 185, 129, 0.4) !important;
    color: #34d399 !important;
}
body.dark .btn-action.btn-action-success:hover {
    background: #10b981 !important;
    color: #ffffff !important;
    border-color: #10b981 !important;
}

.btn-action.btn-action-danger {
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
    color: #dc2626 !important;
}
.btn-action.btn-action-danger:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}
body.dark .btn-action.btn-action-danger {
    background: rgba(239, 68, 68, 0.2) !important;
    border: 1px solid rgba(239, 68, 68, 0.4) !important;
    color: #f87171 !important;
}
body.dark .btn-action.btn-action-danger:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
}

/* Estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.2s;
    box-shadow: var(--shadow);
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-title);
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.stat-value.primary { color: #00508f; }
.stat-value.secondary { color: #688195; }
.stat-value.success { color: #10b981; }
.stat-value.warning { color: #fbbf24; }

body.dark .stat-value.primary { color: #38bdf8; }
body.dark .stat-value.secondary { color: #a5b4fc; }

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Abas */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 2rem;
    gap: 1.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    position: relative;
    font-family: var(--font-sans);
    transition: color 0.2s;
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 99px;
}


.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* Árvore Genealógica (Genealogy Tree) */
.genealogy-tree {
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 2rem;
    overflow-x: auto;
}

.tree-node {
    margin-left: 2rem;
    position: relative;
    padding-left: 1.5rem;
    border-left: 1px dashed rgba(255, 255, 255, 0.15);
}

.tree-node::before {
    content: '';
    position: absolute;
    top: 1.25rem;
    left: 0;
    width: 1.25rem;
    height: 1px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.tree-node:last-child {
    border-left: none;
}

.tree-node:last-child::before {
    border-left: 1px dashed rgba(255, 255, 255, 0.15);
    height: 1.25rem;
    top: 0;
}

.node-card {
    display: inline-flex;
    align-items: center;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    margin: 0.5rem 0;
    gap: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    box-shadow: var(--shadow);
}

.node-card:hover {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.05);
}

.node-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.node-dot.LDR { background: #818cf8; }
.node-dot.FIL { background: #34d399; }
.node-dot.TER { background: #fbbf24; }
.node-dot.ROOT { background: #f43f5e; }

.node-info {
    display: flex;
    flex-direction: column;
}

.node-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.node-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Tabelas */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th {
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-bottom: 2px solid var(--panel-border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--panel-border);
    color: var(--text-main);
}

tr:hover td {
    background: rgba(var(--primary-rgb), 0.03);
}

/* Badges de Tabela */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-contato { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.badge-entidade { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

.badge-enviado { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-pendente { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-falha { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* Botões de Ação na Tabela */
.btn-action {
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.btn-action:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

.btn-action.resend {
    color: #00508f;
    border-color: rgba(0, 80, 143, 0.2);
}

body.dark .btn-action.resend {
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.2);
}

.btn-action.resend:hover {
    background: rgba(0, 80, 143, 0.1);
}

/* QR Code Display Card */
.qrcode-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

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

.qrcode-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.qrcode-card h4 {
    margin-bottom: 1rem;
    color: var(--text-title);
}

.qrcode-img-wrapper {
    background: #ffffff;
    padding: 1rem;
    border-radius: 12px;
    display: inline-block;

    margin-bottom: 1rem;
}

.qrcode-img-wrapper img {
    display: block;
    width: 160px;
    height: 160px;
}

/* Footer */
footer {
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

footer a {
    color: var(--secondary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

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

/* Classes de Status Semânticos de Alto Contraste adaptativos */
.btn-status-danger {
    background: var(--danger-bg) !important;
    border: 1px solid var(--danger-text) !important;
    color: var(--danger-text) !important;
}
.btn-status-info {
    background: var(--info-bg) !important;
    border: 1px solid var(--info-text) !important;
    color: var(--info-text) !important;
}
.btn-status-success {
    background: var(--success-bg) !important;
    border: 1px solid var(--success-text) !important;
    color: var(--success-text) !important;
}
