/* ==========================================================================
   CRM & PAINEL DE CONSULTORES - NUTRI AN-T (UX DESIGN SYSTEM)
   ========================================================================== */

:root {
    --brand-blue: #232f84;
    --brand-blue-hover: #161f5c;
    --brand-blue-light: rgba(35, 47, 132, 0.08);
    --brand-orange: #e05315;
    --brand-orange-hover: #b8400c;
    --brand-orange-light: rgba(224, 83, 21, 0.08);
    --wa-green: #25D366;
    --wa-green-hover: #1da851;
    --wa-green-light: rgba(37, 211, 102, 0.12);
    --bg-page: #f8f9fc;
    --bg-card: rgba(255, 255, 255, 0.95);
    --text-primary: #1d1d1f;
    --text-secondary: #515154;
    --text-tertiary: #86868b;
    --border-color: #e5e7eb;
    --border-focus: #232f84;
    --success-green: #10b981;
    --error-red: #ef4444;
    --shadow-subtle: 0 10px 40px -10px rgba(0, 0, 0, 0.08), 0 2px 10px -2px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.05);
    --border-radius-card: 20px;
    --border-radius-input: 12px;
    --transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 10% 10%, rgba(224, 83, 21, 0.04) 0%, transparent 40%),
                radial-gradient(circle at 90% 90%, rgba(35, 47, 132, 0.05) 0%, transparent 50%),
                var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   TELA DE LOGIN (AUTH GATE)
   ========================================================================== */
.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 20% 30%, rgba(224, 83, 21, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(35, 47, 132, 0.1) 0%, transparent 50%),
                #f4f5f9;
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.login-card {
    background: var(--bg-card);
    border-radius: 28px;
    box-shadow: 0 25px 60px -15px rgba(35, 47, 132, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.8);
    max-width: 420px;
    width: 100%;
    padding: 44px 36px;
    text-align: center;
    backdrop-filter: blur(16px);
    animation: loginIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes loginIn {
    from { transform: scale(0.92) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.login-logo {
    height: 48px;
    margin-bottom: 20px;
    object-fit: contain;
}

.login-badge {
    display: inline-block;
    padding: 4px 14px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand-blue);
    background: var(--brand-blue-light);
    border-radius: 20px;
    margin-bottom: 12px;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.login-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.login-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: block;
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-icon {
    position: absolute;
    left: 14px;
    font-size: 1rem;
    color: var(--text-tertiary);
}

.login-input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 42px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-input);
    outline: none;
    transition: var(--transition);
}

.login-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3.5px rgba(35, 47, 132, 0.12);
}

.login-error {
    color: var(--error-red);
    font-size: 0.8rem;
    margin-top: 4px;
    display: none;
    text-align: center;
    font-weight: 500;
}

.login-error.is-visible {
    display: block;
}

.btn-login {
    width: 100%;
    height: 50px;
    margin-top: 10px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand-blue) 0%, #172166 100%);
    color: #ffffff;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 20px -2px rgba(35, 47, 132, 0.35);
    transition: var(--transition);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -2px rgba(35, 47, 132, 0.45);
}

/* ==========================================================================
   CRM APP HEADER & NAVBAR
   ========================================================================== */
.crm-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.crm-nav-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.crm-brand-side {
    display: flex;
    align-items: center;
    gap: 16px;
}

.crm-logo {
    height: 38px;
    width: auto;
}

.crm-tagline {
    border-left: 2px solid var(--border-color);
    padding-left: 14px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--brand-blue);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.crm-user-side {
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-crm-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

.btn-refresh {
    background: var(--brand-blue-light);
    color: var(--brand-blue);
}

.btn-refresh:hover {
    background: var(--brand-blue);
    color: #ffffff;
}

.btn-export {
    background: #ecfdf5;
    color: var(--success-green);
}

.btn-export:hover {
    background: var(--success-green);
    color: #ffffff;
}

.btn-logout {
    background: #fef2f2;
    color: var(--error-red);
}

.btn-logout:hover {
    background: var(--error-red);
    color: #ffffff;
}

/* ==========================================================================
   CRM MAIN CONTENT & METRICS
   ========================================================================== */
.crm-main {
    max-width: 1300px;
    width: 100%;
    margin: 28px auto 60px;
    padding: 0 24px;
    flex: 1;
}

.crm-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.crm-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.crm-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-card);
    padding: 22px 24px;
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px -5px rgba(0, 0, 0, 0.08);
}

.kpi-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.icon-blue { background: rgba(35, 47, 132, 0.1); color: var(--brand-blue); }
.icon-orange { background: rgba(224, 83, 21, 0.1); color: var(--brand-orange); }
.icon-green { background: rgba(16, 185, 129, 0.1); color: var(--success-green); }
.icon-purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }

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

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    margin-top: 2px;
}

/* ==========================================================================
   CRM DATA TABLE CONTAINER & CONTROLS
   ========================================================================== */
.crm-table-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-card);
    box-shadow: var(--shadow-subtle);
    border: 1px solid rgba(255, 255, 255, 0.9);
    padding: 24px;
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    max-width: 380px;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 0.95rem;
}

.search-input {
    width: 100%;
    height: 44px;
    padding: 0 16px 0 42px;
    font-family: inherit;
    font-size: 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-input);
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(35, 47, 132, 0.1);
}

.table-stats-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f1f3f8;
    padding: 6px 14px;
    border-radius: 20px;
}

/* Table Design */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.crm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.crm-table th {
    background: #f8f9fc;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 18px;
    border-bottom: 1.5px solid var(--border-color);
    white-space: nowrap;
}

.crm-table th:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.crm-table th:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.crm-table td {
    padding: 16px 18px;
    border-bottom: 1px solid #f1f3f7;
    font-size: 0.9rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.crm-table tr:last-child td {
    border-bottom: none;
}

.crm-table tbody tr {
    transition: background-color 0.15s ease;
}

.crm-table tbody tr:hover {
    background-color: rgba(35, 47, 132, 0.02);
}

/* Table Cells Components */
.consultant-name-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.consultant-fullname {
    font-weight: 700;
    color: var(--text-primary);
}

.consultant-nick-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--brand-blue-light);
    color: var(--brand-blue);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    width: fit-content;
}

.contact-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-wa-direct {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #128C7E;
    background: var(--wa-green-light);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    width: fit-content;
    transition: var(--transition);
}

.btn-wa-direct:hover {
    background: #25D366;
    color: #ffffff;
    transform: translateY(-1px);
}

.email-link {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-decoration: none;
}

.email-link:hover {
    color: var(--brand-blue);
    text-decoration: underline;
}

.links-action-group {
    display: flex;
    gap: 8px;
}

.btn-link-action {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-link-action:hover {
    border-color: var(--brand-blue);
    color: var(--brand-blue);
    background: var(--brand-blue-light);
}

.btn-inspect {
    padding: 7px 12px;
    background: var(--brand-blue);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-inspect:hover {
    background: var(--brand-blue-hover);
    transform: translateY(-1px);
}

.btn-edit {
    padding: 7px 12px;
    background: var(--brand-orange-light);
    color: var(--brand-orange);
    border: 1px solid rgba(224, 83, 21, 0.2);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-edit:hover {
    background: var(--brand-orange);
    color: #ffffff;
    border-color: var(--brand-orange);
    transform: translateY(-1px);
}

.btn-delete {
    padding: 7px 10px;
    background: #fef2f2;
    color: var(--error-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-delete:hover {
    background: var(--error-red);
    color: #ffffff;
    border-color: var(--error-red);
    transform: translateY(-1px);
}

.action-buttons-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Empty State */
.table-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

/* Loading Skeleton */
.skeleton-row td {
    padding: 20px 18px;
}

.skeleton-box {
    height: 18px;
    background: linear-gradient(90deg, #f0f0f4 25%, #e4e4eb 50%, #f0f0f4 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
    border-radius: 6px;
}

@keyframes skeletonLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   MODAL DE DETALHES DO CONSULTOR
   ========================================================================== */
.details-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.details-modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.details-modal-card {
    background: #ffffff;
    border-radius: 24px;
    max-width: 580px;
    width: 100%;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.95);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.details-modal-overlay.is-active .details-modal-card {
    transform: scale(1);
}

.details-modal-header {
    background: linear-gradient(135deg, var(--brand-blue) 0%, #161f5c 100%);
    color: #ffffff;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.details-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-close-details {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-close-details:hover {
    background: rgba(255, 255, 255, 0.35);
}

.details-modal-body {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 70vh;
    overflow-y: auto;
}

.detail-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid #f1f3f7;
    padding-bottom: 12px;
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
}

.detail-val {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-all;
}

/* Edit Modal Specific */
.edit-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.edit-col-span-2 {
    grid-column: span 2;
}

.edit-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.edit-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.edit-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 0.88rem;
    background: #fdfdfd;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    outline: none;
    transition: var(--transition);
}

.edit-input:focus {
    border-color: var(--brand-blue);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(35, 47, 132, 0.1);
}

.edit-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel-edit {
    padding: 10px 18px;
    background: #f1f3f8;
    color: var(--text-secondary);
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-cancel-edit:hover {
    background: #e2e5ec;
}

.btn-save-edit {
    padding: 10px 22px;
    background: linear-gradient(135deg, var(--brand-blue) 0%, #161f5c 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-save-edit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(35, 47, 132, 0.3);
}

.btn-save-edit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Delete Modal Specific */
.delete-warning-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 14px;
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
}

.delete-warning-icon {
    font-size: 1.8rem;
    color: var(--error-red);
    flex-shrink: 0;
}

.delete-warning-text {
    font-size: 0.9rem;
    color: #991b1b;
    line-height: 1.5;
}

.delete-consultant-preview {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.btn-confirm-delete {
    padding: 10px 22px;
    background: linear-gradient(135deg, var(--error-red) 0%, #b91c1c 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-confirm-delete:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(239, 68, 68, 0.35);
}

.btn-confirm-delete:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Toast Notifications */
.toast-notice {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1d1d1f;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 14px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 99999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-notice.is-active {
    transform: translateY(0);
    opacity: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .crm-nav-container {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .crm-user-side {
        width: 100%;
        justify-content: space-between;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: 100%;
    }

    .crm-main {
        padding: 0 16px;
        margin: 20px auto 40px;
    }
}
