/* Clients Specific Styles */
.filters-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.filters-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

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

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #777;
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 35px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    min-width: 150px;
}

.actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Map Section */
#mapSection {
    margin-bottom: 20px;
}

#clientsMap, #locationPickerMap {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

/* Client Cards in Table */
.client-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.client-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
}

.client-details {
    flex: 1;
}

.client-details strong {
    display: block;
    color: #2c3e50;
    margin-bottom: 4px;
}

.client-code {
    font-size: 11px;
    color: #7f8c8d;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

/* Location Info */
.location-info {
    font-size: 13px;
    line-height: 1.4;
}

.location-info .city {
    font-weight: 500;
    color: #2c3e50;
}

.location-info .address {
    color: #7f8c8d;
    font-size: 12px;
    margin-top: 2px;
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    display: inline-block;
}

.status-active {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-inactive {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Frequency Badges */
.frequency-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    display: inline-block;
}

.frequency-diaria {
    background: #e7f4e4;
    color: #2e7d32;
}

.frequency-semanal {
    background: #e3f2fd;
    color: #1565c0;
}

.frequency-quincenal {
    background: #fff3e0;
    color: #ef6c00;
}

.frequency-mensual {
    background: #fce4ec;
    color: #c2185b;
}

.frequency-ocasional {
    background: #f5f5f5;
    color: #616161;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s;
    color: #555;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
}

.action-btn.edit:hover {
    color: #3498db;
}

.action-btn.delete:hover {
    color: #e74c3c;
}

.action-btn.view:hover {
    color: #27ae60;
}

.action-btn.map:hover {
    color: #e67e22;
}

/* Modal Styles - CORREGIDO */
.modal {
    display: none;
    position: fixed;
    z-index: 10000; /* Aumentado para estar por encima de todo */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: modalAppear 0.3s ease;
    position: relative;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes modalAppear {
    from { 
        opacity: 0; 
        transform: translateY(-50px) scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.modal-content.large {
    width: 85%;
    max-width: 800px;
}

.modal-content.xlarge {
    width: 90%;
    max-width: 1000px;
}

.modal-content.small {
    width: 90%;
    max-width: 500px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.4em;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background-color: #f8f9fa;
    color: #e74c3c;
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
    background: #ffffff;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

/* Form Tabs - MEJORADO */
.form-tabs {
    margin-bottom: 0;
}

.tab-buttons {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 25px;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    padding: 5px;
    gap: 5px;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: #6c757d;
    transition: all 0.3s;
    flex: 1;
    text-align: center;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.tab-btn:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

.tab-btn.active {
    color: #3498db;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: #3498db;
    border-radius: 3px 3px 0 0;
}

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

.tab-content.active {
    display: block;
}

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

/* Form Styles - MEJORADO */
.form-section {
    margin-bottom: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #3498db;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.form-section h4 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.2em;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.form-group label::after {
    content: '*';
    color: #e74c3c;
    margin-left: 2px;
    display: none;
}

.form-group.required label::after {
    display: inline;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #bdc3c7;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* Geolocation Styles - MEJORADO */
.geolocation-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.geocode-status {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    font-style: normal;
    flex: 1;
    text-align: center;
}

.geocode-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.geocode-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.coordinates-display {
    display: flex;
    gap: 25px;
    font-size: 14px;
    color: #2c3e50;
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    font-family: 'Courier New', monospace;
    justify-content: center;
}

.coordinates-display span {
    font-weight: 600;
}

/* Map Modal Styles */
.map-instructions {
    background: #e7f3ff;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
    font-size: 14px;
}

.map-instructions i {
    color: #3498db;
    margin-right: 10px;
}

.selected-coordinates {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    margin-top: 20px;
    text-align: center;
    border: 2px solid #e9ecef;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #2c3e50;
}

/* Buttons - MEJORADO */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-family: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transition: all 0.3s;
    transform: translate(-50%, -50%);
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.btn-outline {
    background: transparent;
    border: 2px solid #3498db;
    color: #3498db;
    position: relative;
    z-index: 1;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 14px;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Last Order Info */
.last-order {
    font-size: 12px;
    color: #7f8c8d;
}

.last-order .date {
    font-weight: 500;
    color: #2c3e50;
}

/* Route Assignment */
.route-assignment {
    font-size: 12px;
}

.route-name {
    font-weight: 500;
    color: #2c3e50;
}

.route-seller {
    color: #7f8c8d;
    font-size: 11px;
}

/* Details Modal */
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.details-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.details-section h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
    font-size: 1.1em;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

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

.detail-label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.detail-value {
    color: #6c757d;
    font-size: 14px;
    text-align: right;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 20px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    min-width: 36px;
}

.pagination button:hover:not(:disabled) {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.pagination button:disabled {
    background: #f8f9fa;
    color: #bdc3c7;
    cursor: not-allowed;
    border-color: #e9ecef;
}

.pagination-info {
    font-size: 14px;
    color: #777;
    margin-left: 15px;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 50px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #777;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
    font-size: 16px;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: #27ae60;
}

.notification.error {
    background: #e74c3c;
}

.notification.warning {
    background: #f39c12;
}

.hidden {
    display: none;
}

/* Responsive */
/* Responsive para Modal */
@media (max-width: 768px) {
    .modal-content.large,
    .modal-content.xlarge {
        width: 95%;
        margin: 5% auto;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        padding: 15px 20px;
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .tab-buttons {
        flex-direction: column;
        gap: 5px;
    }
    
    .tab-btn {
        flex: none;
    }
    
    .geolocation-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .coordinates-display {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Scrollbar personalizado para modal */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

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

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

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


@media (max-width: 768px) {
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .details-grid {
        grid-template-columns: 1fr;
    }
    
    .client-info {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .action-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .quick-stats {
        grid-template-columns: 1fr;
    }
    
    .modal-content.xlarge {
        width: 98%;
        margin: 2% auto;
    }
    
    .tab-buttons {
        flex-direction: column;
    }
    
    .tab-btn {
        flex: none;
    }
    
    .geolocation-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .coordinates-display {
        flex-direction: column;
        gap: 5px;
    }
    
    .pagination {
        flex-direction: column;
        gap: 10px;
    }
    
    .pagination-info {
        margin-left: 0;
        margin-top: 10px;
    }
}

/* Specific table column widths */
#clientsTable th:nth-child(1),
#clientsTable td:nth-child(1) {
    min-width: 200px;
}

#clientsTable th:nth-child(2),
#clientsTable td:nth-child(2) {
    min-width: 150px;
}

#clientsTable th:nth-child(3),
#clientsTable td:nth-child(3) {
    min-width: 180px;
}

#clientsTable th:nth-child(8),
#clientsTable td:nth-child(8) {
    min-width: 120px;
    text-align: center;
}