/* Representative Modules Container */
.rep-module-container {
    animation: fadeIn 0.3s ease-out;
}

/* Page Sub-Header */
.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.module-title-box h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
}

.module-title-box p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Search & Filter Toolbar */
.toolbar-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.5rem;
    font-size: 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    background: var(--surface-subtle);
    transition: border-color 0.2s ease;
}

.search-input-wrapper input:focus {
    border-color: var(--primary);
    background: #ffffff;
}

.search-input-wrapper svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-select {
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    background: var(--surface);
    color: var(--text-main);
    cursor: pointer;
}

.btn-filter-fav {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-filter-fav.active, .btn-filter-fav:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #d97706;
}

/* Client Table & Cards */
.btn-fav {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #d1d5db;
    transition: color 0.2s ease;
    padding: 0.2rem;
}

.btn-fav.active {
    color: #f59e0b;
}

.btn-view-details {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-view-details:hover {
    background: var(--primary);
    color: white;
}

/* Pagination Footer & Controls */
.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-info strong {
    color: var(--text-main);
    font-weight: 700;
}

.pagination-nav-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-main);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.page-btn:hover:not(.disabled):not(.active) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    cursor: default;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--surface-subtle);
    border-color: var(--border-color);
}

.page-ellipsis {
    padding: 0 0.35rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    user-select: none;
}

/* Badge colors for all distinct client classes from API */
.status-badge.ativo { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.status-badge.novo { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.status-badge.inativo { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.status-badge.cpf-inativo { background: #fff7ed; color: #ea580c; border: 1px solid #fed7aa; }
.status-badge.baixado { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.status-badge.nao-habilitado { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }

/* Kanban Route Board (Trello-Style) */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.kanban-column {
    background: var(--surface-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

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

.kanban-column-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.col-count {
    background: var(--surface);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid var(--border-subtle);
}

.kanban-cards-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kanban-card.pinned {
    border-top: 3.5px solid #f59e0b;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.client-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}

.priority-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
}

.priority-p1 { background: #fef2f2; color: #dc2626; }
.priority-p2 { background: #fffbeb; color: #d97706; }
.priority-p3 { background: #ecfdf5; color: #059669; }

.card-body-text {
    font-size: 0.825rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.card-footer-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px dashed var(--border-subtle);
    padding-top: 0.5rem;
}

.btn-add-task {
    width: 100%;
    margin-top: 1rem;
    padding: 0.6rem;
    background: transparent;
    border: 1.5px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-task:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Kanban Drag & Drop Visual Effects */
.kanban-card.dragging {
    opacity: 0.35;
    transform: scale(0.96);
    border: 2px dashed var(--primary);
}

.kanban-cards-list.drag-over,
.kanban-column.drag-over .kanban-cards-list {
    background: #f0fdf4 !important;
    border: 2px dashed #059669 !important;
    border-radius: var(--radius-sm);
}

.kanban-column.drag-over {
    border-color: #059669 !important;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.kanban-card {
    user-select: none;
    -webkit-user-drag: element;
}

.kanban-card .card-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.kanban-card .card-btn-action {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    opacity: 0.7;
    transition: all 0.2s;
}

.kanban-card .card-btn-action:hover {
    opacity: 1;
    background: var(--surface-subtle);
}

.client-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.client-search-item {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
    font-size: 0.825rem;
    transition: background 0.15s;
}

.client-search-item:last-child {
    border-bottom: none;
}

.client-search-item:hover {
    background: #f1f5f9;
}


/* Modal Dialog (Client Details & CNPJ API Lookup & Order PDF & Tracking) */
.modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    overflow-y: auto;
    pointer-events: auto !important;
}

.modal-backdrop.d-none {
    display: none !important;
}

.modal-dialog {
    background: var(--surface) !important;
    border-radius: var(--radius-lg) !important;
    width: 100% !important;
    max-width: 850px;
    max-height: 90vh !important;
    margin: auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    pointer-events: auto !important;
    box-shadow: var(--shadow-xl) !important;
    border: 1px solid var(--border-subtle) !important;
    animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-subtle);
    flex-shrink: 0 !important;
    pointer-events: auto !important;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

.modal-body {
    padding: 1.5rem 1.75rem;
    overflow-y: auto !important;
    overflow-x: hidden;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: calc(90vh - 135px);
    pointer-events: auto !important;
    -webkit-overflow-scrolling: touch;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.modal-footer {
    padding: 1rem 1.75rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0 !important;
    pointer-events: auto !important;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.detail-block {
    background: var(--surface-subtle);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.detail-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.2rem;
}

/* CNPJ API Box */
.cnpj-api-box {
    background: #ecfdf5;
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.cnpj-api-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.btn-fetch-cnpj {
    background: var(--primary);
    color: white;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.cnae-tag {
    display: inline-block;
    background: white;
    border: 1px solid var(--primary-border);
    color: var(--primary);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.775rem;
    margin-right: 0.4rem;
    margin-top: 0.4rem;
}

/* Notes / OBS Area */
.notes-section {
    margin-bottom: 1.5rem;
}

.notes-textarea {
    width: 100%;
    height: 90px;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    resize: vertical;
    margin-top: 0.5rem;
}

.notes-textarea:focus {
    border-color: var(--primary);
}

/* Order PDF Preview Table */
.order-pdf-list {
    margin-top: 1.5rem;
}

.btn-pdf-view {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.775rem;
    cursor: pointer;
}

/* Automations Cards */
.automation-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 1rem;
}

.automation-info h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.automation-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 26px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary, #059669);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* Toast Notification Styles */
.crm-toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    pointer-events: none;
}

.crm-toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 420px;
    background: #0f172a;
    color: #f8fafc;
    padding: 0.85rem 1.15rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-left: 4px solid #10b981;
    animation: crmToastSlideIn 0.25s ease-out;
}

.crm-toast.warning {
    border-left-color: #f59e0b;
}

.crm-toast.error {
    border-left-color: #ef4444;
}

.crm-toast.info {
    border-left-color: #3b82f6;
}

@keyframes crmToastSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tracking Timeline Styles */
.tracking-timeline {
    position: relative;
    padding-left: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.tracking-timeline::before {
    content: '';
    position: absolute;
    left: 1.05rem;
    top: 0.75rem;
    bottom: 0.75rem;
    width: 2px;
    background: var(--border-subtle);
    z-index: 0;
}

.timeline-step {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    z-index: 1;
}

.step-dot {
    position: relative;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--surface-subtle);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

.timeline-step.step-done .step-dot {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.timeline-step.step-active .step-dot {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #d97706;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.step-content strong {
    font-size: 0.9rem;
    color: var(--text-main);
    display: block;
}

.step-time {
    font-size: 0.775rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}
