/* css/components.css */

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--pdt-red-600);
    color: var(--surface-white);
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
}

.btn-primary:hover {
    background-color: var(--pdt-red-700);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.3);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--pdt-blue-900);
    color: var(--pdt-blue-900);
    background-color: var(--pdt-blue-50);
}

.btn-logout {
    background: linear-gradient(135deg, var(--pdt-red-500) 0%, var(--pdt-red-600) 100%);
    color: var(--surface-white);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    border: none;
}

.btn-logout:hover {
    background: linear-gradient(135deg, var(--pdt-red-600) 0%, var(--pdt-red-700) 100%);
    box-shadow: 0 6px 14px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
    color: var(--surface-white);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--pdt-blue-900);
}

.sidebar .btn-icon {
    color: var(--text-tertiary);
}

.sidebar .btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--surface-white);
}

/* Cards & Panels (Glassmorphism & Standard) */
.card {
    background-color: var(--surface-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: 1.5rem;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.glass-panel {
    background-color: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-glass);
    border-radius: var(--border-radius-lg);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.badge.nacional {
    background-color: var(--pdt-red-100);
    color: var(--pdt-red-700);
    border: 1px solid var(--pdt-red-500);
}

.badge.estadual {
    background-color: var(--pdt-blue-50);
    color: var(--pdt-blue-800);
    border: 1px solid var(--pdt-blue-800);
}

.badge.success {
    background-color: var(--status-success-bg);
    color: var(--status-success);
}

.badge.pending {
    background-color: var(--status-pending-bg);
    color: var(--status-pending);
}

/* Formulários */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 1rem;
    color: var(--text-tertiary);
    font-size: 1.2rem;
}

.input-with-icon input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-md);
    outline: none;
    transition: all 0.2s;
    background-color: var(--bg-main);
}

.input-with-icon input:focus {
    border-color: var(--pdt-blue-800);
    box-shadow: 0 0 0 3px rgba(7, 89, 133, 0.1);
    background-color: var(--surface-white);
}

/* Premium Form Styles */
.form-section {
    background-color: var(--bg-main);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.form-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--pdt-blue-500);
}

.form-section.accent-red::before {
    background-color: var(--pdt-red-500);
}

.form-section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--pdt-blue-900);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Modern Map Tooltip */
.modern-map-tooltip {
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.1) !important;
    padding: 0.75rem !important;
    color: #0f172a !important;
}

.modern-map-tooltip::before {
    border-top-color: rgba(255, 255, 255, 0.96) !important;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.input-block {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border-light);
    border-radius: var(--border-radius-md);
    background-color: var(--surface-white);
    color: var(--text-main);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.input-block:focus,
.input-block:focus-within {
    border-color: var(--pdt-blue-600);
    box-shadow: 0 0 0 4px rgba(7, 89, 133, 0.08);
    outline: none;
}

.input-block:hover:not(:disabled) {
    border-color: #cbd5e1;
}

.input-block:disabled {
    background-color: var(--bg-main);
    color: var(--text-tertiary);
    cursor: not-allowed;
    border-color: var(--border-light);
    opacity: 0.8;
}

select.input-block {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

select.input-block:disabled {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23cbd5e1' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
}

.form-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background-color: var(--bg-main);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    margin: 0 -1.5rem -1.5rem -1.5rem;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, var(--pdt-blue-950) 0%, var(--pdt-blue-900) 50%, var(--pdt-red-700) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    transition: opacity 0.5s ease;
}

.login-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 3rem;
    color: var(--pdt-red-500);
    margin-bottom: 1rem;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pdt-blue-950);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.login-actions {
    margin-top: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border-light);
    padding-top: 1.5rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Equipe / Team Cards */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.team-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.team-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.team-card-actions {
    display: flex;
    gap: 0.25rem;
}

.team-card-actions .btn-icon {
    width: 32px;
    height: 32px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
}

.team-card-actions .btn-icon:hover {
    background-color: var(--border-light);
}

.text-danger {
    color: var(--pdt-red-500) !important;
}

.text-danger:hover {
    color: var(--surface-white) !important;
    background-color: var(--pdt-red-600) !important;
    border-color: var(--pdt-red-600) !important;
}

.team-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1.5rem;
}

.team-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pdt-red-500), var(--pdt-red-700));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.2);
}

.team-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.team-role {
    font-size: 0.875rem;
    color: var(--pdt-blue-800);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.team-email {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.team-card-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.portaria-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.portaria-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.portaria-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Calendar Components --- */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-top: 1.5rem;
    min-width: 700px;
}

.calendar-header-day {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-light);
}

.calendar-day {
    min-height: 100px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day.empty {
    background-color: transparent;
    border-color: transparent;
    cursor: default;
}

.calendar-day.today {
    background-color: var(--pdt-red-50);
    border-color: var(--pdt-red-500);
}

.calendar-day:hover:not(.empty) {
    border-color: var(--pdt-blue-800);
    box-shadow: var(--shadow-sm);
}

.calendar-day .date-num {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.calendar-day.today .date-num {
    color: var(--pdt-red-600);
}

/* Event Chips */
.event-chip {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: var(--pdt-blue-50);
    color: var(--pdt-blue-900);
    border-left: 3px solid var(--pdt-blue-800);
}

.event-chip.nacional {
    background-color: var(--pdt-red-50);
    color: var(--pdt-red-700);
    border-left-color: var(--pdt-red-500);
}

/* --- Select Filter (Dropdowns estilizados como btn-outline) --- */
.select-filter {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 2.25rem 0.625rem 1rem;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    cursor: pointer;
    background-color: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%2364748b' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    height: 100%;
}

.select-filter:hover {
    border-color: var(--pdt-blue-900);
    color: var(--pdt-blue-900);
    background-color: var(--pdt-blue-50);
}

.select-filter:focus {
    outline: none;
    border-color: var(--pdt-blue-800);
    box-shadow: 0 0 0 3px rgba(7, 89, 133, 0.1);
    color: var(--pdt-blue-900);
}

[data-theme="dark"] .select-filter {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23cbd5e1' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
    background-color: transparent;
    color: var(--text-secondary);
}

/* --- Modal Overlay (shared base for all modals) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 47, 73, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeInOverlay 0.2s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUpModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpModal {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-light);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.modal-header .modal-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-sm);
    background: var(--pdt-blue-50);
    color: var(--pdt-blue-800);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-light);
}

/* Loading Spinner */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-light);
    border-top-color: var(--pdt-blue-800);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* --- Profile Modal: campos somente-leitura --- */
.profile-readonly-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background-color: var(--bg-main);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-sm);
    padding: 0.6rem 0.85rem;
}

.profile-field-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.profile-field-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Avatar hover glow */
.header-avatar:hover {
    border-color: var(--pdt-red-500);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
    transition: all 0.2s ease;
}

/* --- Tabela compacta: linhas menores --- */
.table-compact td,
.table-compact th {
    padding: 0.45rem 0.85rem;
    font-size: 0.83rem;
    vertical-align: middle;
}

.table-compact thead th {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-tertiary);
}

/* --- Lista de Metas por Estado --- */
.state-goal-row {
    display: flex;
    flex-direction: column;
    padding: 0.55rem 0.75rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.15s ease;
}

.state-goal-row:hover {
    background: var(--bg-main);
}

/* ========================================= */
/* MOBILE RESPONSIVENESS (Max 900px)         */
/* ========================================= */
@media (max-width: 900px) {

    /* Grids & Flexboxes */
    .stats-grid,
    .team-grid,
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Force columns on specifically marked flex containers */
    .mobile-col {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .mobile-col>* {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Brute-force wrapper for JS inline grids */
    .responsive-grid {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Specific chart containers in Analise */
    .chart-mobile-stack {
        grid-template-columns: 1fr !important;
    }

    /* Exceptions where we want to keep flex-row on mobile */
    .header-user-info,
    .header-user-info div,
    .sidebar-header,
    .form-actions-bar,
    .table-row-actions,
    .input-with-icon,
    .modal-header,
    .modal-footer,
    .state-goal-row>div {
        flex-direction: row !important;
    }

    /* Certificates Exceptions */
    .cert-mobile-header {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 1.25rem !important;
    }

    .cert-mobile-header .section-title {
        border-bottom: 0 !important;
        margin-bottom: 0.5rem !important;
    }

    .cert-mobile-header .actions {
        flex-direction: column !important;
        width: 100% !important;
    }

    /* Form Controls */
    .form-section {
        padding: 1.25rem;
    }

    .form-actions-bar {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: stretch;
    }

    .form-actions-bar .btn {
        flex: 1;
        text-align: center;
        width: 100%;
    }

    /* Typography & Spacing adjustments */
    .section-title {
        font-size: 1.1rem !important;
    }

    .card {
        padding: 1rem;
        max-width: 100%;
        overflow-x: auto;
    }

    /* Ensure tables don't overflow */
    .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--border-radius-md);
        box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.02);
    }

    /* Tables scroll naturally; complex tables set their own min-width inline */
    table {
        min-width: unset;
    }

    /* Modals */
    .modal-content {
        max-width: 95vw;
        margin: 0.5rem;
        padding: 1rem;
        max-height: 85vh;
    }

    /* Heatmap Maps */
    .map-container {
        min-height: 250px !important;
    }

    /* Dashboard Activity flex row overriding */
    .card[style*="flex: 1"],
    .card[style*="flex: 2"] {
        flex: 1 1 100% !important;
        min-width: unset !important;
    }

    /* ── Lista de Núcleos: filtros + grid mobile ── */
    #nc-grid {
        grid-template-columns: 1fr !important;
    }

    #nc-pagination {
        display: none !important;
    }

    /* Filter bars: empilhar no mobile */
    .card > div[style*="display:flex"][style*="flex-wrap:wrap"],
    .card > div[style*="display: flex"][style*="flex-wrap: wrap"] {
        flex-direction: column;
    }

    .card > div[style*="display:flex"][style*="flex-wrap:wrap"] > *,
    .card > div[style*="display: flex"][style*="flex-wrap: wrap"] > * {
        width: 100% !important;
        min-width: unset !important;
        flex: none !important;
    }

    /* Seletor de estado no filtro de equipe */
    #fast-state-selector {
        width: 100%;
        min-width: unset !important;
    }

    /* Touch targets maiores no mobile */
    .btn-icon {
        width: 44px;
        height: 44px;
    }

    .btn-sm {
        padding: 0.55rem 1rem;
        font-size: 0.8rem;
    }

    /* ── Cards de Análise mobile ── */
    #nucleos-detail-modal .modal-content,
    #nucleo-detail-modal .modal-content {
        padding: 1rem !important;
    }

    /* ── Análise: gráfico + metas empilhados ── */
    [id="state-goals-list"] {
        max-height: 240px !important;
    }
}