/* ============================================
   Vitae Group - Direcionador de Subscrição
   Layout Profissional - Consistente com broker_panel
   ============================================ */

/* CSS Variables - Mesma paleta do broker_panel */
:root {
    --primary-color: #35455E;
    --primary-dark: #2a3649;
    --primary-light: #4a5d7a;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #0ea5e9;

    --bg-color: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 12px;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;

    /* Legado alias */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ============================================
   Header - Compacto e profissional
   ============================================ */
.header {
    background: var(--primary-color);
    color: white;
    padding: 0;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo h1 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0;
    line-height: 1.2;
}

.header-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.header-title {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    opacity: 0.95;
    white-space: nowrap;
}

.nav-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.nav-info .version {
    display: none;
}

.btn-admin {
    background: rgba(255,255,255,0.12);
    color: white;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: background var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-admin:hover {
    background: rgba(255,255,255,0.22);
}

.btn-admin i {
    font-size: 0.7rem;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    padding: 1.5rem 0 2rem;
    min-height: calc(100vh - 56px - 50px);
}

/* Page Title */
.page-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.page-title i {
    font-size: 1rem;
    color: var(--primary-color);
}

.page-title h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================
   Seção de Consulta - Compacta
   ============================================ */
.consulta-section {
    margin-bottom: 1.25rem;
}

.consulta-card {
    background: var(--bg-card);
    padding: 1.25rem 1.5rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* Força selects a abrirem para baixo garantindo espaço */
.consulta-card select.form-control {
    position: relative;
    z-index: 10;
}

.consulta-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.consulta-card h2 i {
    color: var(--primary-color);
    font-size: 0.85rem;
}

.consulta-card .description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    height: 38px;
}

.form-control:hover {
    border-color: var(--gray-300);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(53, 69, 94, 0.12);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    height: 38px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 0.8rem;
}

/* ============================================
   Seção de Resultados
   ============================================ */
.resultados-section {
    background: var(--bg-card);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.resultados-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.resultados-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.resultados-header h3 i {
    color: var(--primary-color);
    font-size: 0.8rem;
}

.resultados-header .highlight {
    color: var(--primary-color);
    font-weight: 700;
}

.badge {
    background: var(--bg-color);
    color: var(--text-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

/* Cards Grid - Alinhado */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* Card de Direcionamento - Profissional */
.card-direcionamento {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.card-direcionamento:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header .seguradora-logo {
    width: 36px;
    height: 36px;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    color: var(--primary-color);
}

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

.card-header .seguradora-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-header .seguradora-info .produto-tag {
    display: inline-block;
    background: rgba(14, 165, 233, 0.1);
    color: var(--info-color);
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Card Body */
.card-body {
    flex: 1;
}

.card-body .info-row {
    margin-bottom: 0.6rem;
}

.card-body .info-row:last-child {
    margin-bottom: 0;
}

.card-body .info-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.15rem;
}

.card-body .info-value {
    color: var(--text-primary);
    font-size: 0.83rem;
    line-height: 1.5;
}

.card-body .parecer-text {
    background: var(--bg-color);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary-color);
    font-style: normal;
    color: var(--text-secondary);
    font-size: 0.83rem;
    line-height: 1.5;
}

/* Card Footer */
.card-footer {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-footer .underwriter-avatar {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.65rem;
}

.card-footer .underwriter-info {
    flex: 1;
}

.card-footer .underwriter-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.83rem;
}

.card-footer .underwriter-contact a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.78rem;
}

.card-footer .underwriter-contact a:hover {
    text-decoration: underline;
}

.card-footer .data-atualizacao {
    font-size: 0.73rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
}

.card-footer .data-atualizacao i {
    font-size: 0.6rem;
}

/* ============================================
   Contatos no Card
   ============================================ */
.card-contatos {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.contatos-secao {
    background: var(--bg-color);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
}

.contatos-titulo {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.contatos-titulo i {
    font-size: 0.65rem;
}

.contatos-lista {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.contato-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.contato-icone {
    font-size: 0.75rem;
    flex-shrink: 0;
    color: var(--text-muted);
    width: 18px;
    text-align: center;
}

.contato-dados {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    flex: 1;
}

.contato-nome {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
    line-height: 1.3;
}

.contato-email {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.75rem;
    word-break: break-all;
    line-height: 1.3;
}

.contato-email:hover {
    text-decoration: underline;
}

.contato-telefone {
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.3;
}

/* Bordas coloridas por tipo */
.subscritores-secao {
    border-left: 3px solid var(--info-color);
}

.comerciais-secao {
    border-left: 3px solid var(--success-color);
}

/* Underwriter Legado */
.underwriter-legado {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem;
    background: var(--bg-color);
    border-radius: var(--radius-sm);
}

.underwriter-legado .underwriter-avatar {
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.65rem;
    flex-shrink: 0;
}

.underwriter-legado .underwriter-info {
    flex: 1;
    min-width: 0;
}

.underwriter-legado .underwriter-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.78rem;
}

.underwriter-legado .underwriter-contact a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.72rem;
    word-break: break-all;
}

.underwriter-legado .underwriter-contact a:hover {
    text-decoration: underline;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2.5rem 1.25rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    color: var(--border-color);
}

.empty-state .empty-icon i {
    font-size: 2.5rem;
}

.empty-state p {
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.6;
    font-size: 0.85rem;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    background: var(--gray-800);
    color: var(--gray-400);
    padding: 0.75rem 0;
    text-align: center;
    font-size: 0.7rem;
}

.footer p {
    margin-bottom: 0.2rem;
}

.footer-links a {
    color: var(--primary-light);
    text-decoration: none;
}

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

.footer-links .separator {
    margin: 0 0.5rem;
    color: var(--gray-500);
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    gap: 0.75rem;
}

.loading-overlay.hidden {
    display: none;
}

.loading-overlay p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Toast Notifications
   ============================================ */
.toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    background: var(--gray-800);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    font-size: 0.78rem;
    font-weight: 500;
    animation: slideIn 0.25s ease;
}

.toast.hidden { display: none; }
.toast.error { background: var(--error-color); }
.toast.success { background: var(--success-color); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Responsividade
   ============================================ */
@media (max-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .header-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 0.3rem;
        justify-items: center;
    }
    
    .header { height: auto; padding: 0.6rem 0; }

    .nav-info { justify-content: center; }
    .consulta-card { padding: 1rem; }
    
    .cards-grid { grid-template-columns: 1fr; }
    
    .resultados-header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .toast { left: 1rem; right: 1rem; bottom: 1rem; }
    
    .toggle-buttons { flex-direction: column; }
}

@media (max-width: 480px) {
    .logo h1 { font-size: 0.85rem; }
    .header-title { font-size: 0.75rem; }
    .consulta-card { padding: 0.75rem; }
}

/* Utilitários */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ============================================
   Toggle Buttons - Compactos
   ============================================ */
.toggle-buttons {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    height: 36px;
}

.toggle-btn i {
    font-size: 0.7rem;
}

.toggle-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--gray-50);
}

.toggle-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.toggle-btn.active:hover {
    background: var(--primary-dark);
}

/* ============================================
   Autocomplete / Search
   ============================================ */
.search-container {
    position: relative;
    width: 100%;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.autocomplete-results.hidden { display: none; }

.autocomplete-item {
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-50);
    transition: background-color var(--transition-fast);
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.5rem;
    align-items: center;
    font-size: 0.78rem;
}

.autocomplete-item.hidden { display: none; }
.autocomplete-item:hover { background-color: var(--bg-color); }
.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item .cnae-code {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.75rem;
    min-width: 65px;
}

.autocomplete-item .cnae-name {
    color: var(--text-primary);
    font-size: 0.75rem;
    flex: 1;
}

.autocomplete-item .cnae-section {
    color: var(--text-muted);
    font-size: 0.65rem;
    width: 100%;
    font-style: italic;
}

.autocomplete-item.selected {
    background-color: var(--primary-color);
    color: white;
}

.autocomplete-item.selected .cnae-code,
.autocomplete-item.selected .cnae-name {
    color: white;
}

.autocomplete-item.selected .cnae-section {
    color: rgba(255,255,255,0.8);
}

.autocomplete-loading {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.autocomplete-empty {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ============================================
   Searchable Select Component
   ============================================ */
.searchable-select {
    position: relative;
    width: 100%;
}

.searchable-select .ss-input {
    width: 100%;
    padding: 0.55rem 2rem 0.55rem 0.75rem;
    font-size: 0.85rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    height: 38px;
    cursor: pointer;
    outline: none;
}

.searchable-select .ss-input::placeholder {
    color: var(--text-muted);
}

.searchable-select .ss-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(53, 69, 94, 0.12);
    cursor: text;
}

.searchable-select .ss-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
}

.searchable-select.open .ss-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.searchable-select .ss-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.searchable-select.open .ss-dropdown {
    display: block;
}

.searchable-select .ss-option {
    padding: 0.45rem 0.75rem;
    font-size: 0.83rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-select .ss-option:hover,
.searchable-select .ss-option.highlighted {
    background: var(--bg-color);
}

.searchable-select .ss-option.selected {
    background: var(--primary-color);
    color: white;
}

.searchable-select .ss-no-results {
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}
