/* Routes 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;
}

#routesMap {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.map-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

.route-icon {
    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;
}

.route-details {
    flex: 1;
}

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

.route-desc {
    font-size: 12px;
    color: #7f8c8d;
}

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

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

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

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

.schedule-day {
    font-weight: 500;
    color: #2c3e50;
}

.schedule-time {
    color: #7f8c8d;
    font-size: 12px;
}

/* Clients Count */
.clients-count {
    text-align: center;
}

.clients-number {
    font-size: 18px;
    font-weight: bold;
    color: #3498db;
    display: block;
}

.clients-label {
    font-size: 11px;
    color: #7f8c8d;
    text-transform: uppercase;
}

/* Deliveries Progress */
.deliveries-progress {
    text-align: center;
}

.progress-text {
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 5px;
}

.progress-bar {
    background: #e9ecef;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #27ae60, #2ecc71);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* Distance Info */
.distance-info {
    text-align: center;
    font-weight: 500;
    color: #2c3e50;
}

/* 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;
}

.status-in-progress {
    background-color: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

/* 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;
}

/* Clients Selection Styles */
.clients-selection {
    margin-top: 20px;
}

.selection-header {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.selection-filters {
    display: flex;
    gap: 10px;
}

.clients-list-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 400px;
}

.available-clients, .assigned-clients {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border: 2px solid #e9ecef;
}

.available-clients h5, .assigned-clients h5 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 14px;
    font-weight: 600;
}

.clients-list {
    height: 320px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: white;
}

.client-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid #f1f1f1;
    cursor: pointer;
    transition: background 0.3s;
}

.client-item:hover {
    background: #f8f9fa;
}

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

.client-info {
    flex: 1;
}

.client-name {
    font-weight: 500;
    color: #2c3e50;
    font-size: 13px;
    margin-bottom: 2px;
}

.client-location {
    font-size: 11px;
    color: #7f8c8d;
}

.add-client-btn, .remove-client-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    color: #6c757d;
    transition: all 0.3s;
}

.add-client-btn:hover {
    color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}

.remove-client-btn:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* Optimization Styles */
.optimization-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-top: 4px solid #3498db;
}

.optimization-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.route-order-list {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.route-order-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f1f1f1;
}

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

.order-number {
    width: 30px;
    height: 30px;
    background: #3498db;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.order-client-info {
    flex: 1;
}

/* Sortable List */
.sortable-list {
    min-height: 300px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 15px;
}

.sortable-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: move;
    transition: all 0.3s;
}

.sortable-item:hover {
    background: #f8f9fa;
    border-color: #3498db;
}

.sortable-item.sortable-ghost {
    opacity: 0.4;
}

.sortable-item.sortable-chosen {
    background: #e3f2fd;
    border-color: #3498db;
}

.sortable-handle {
    margin-right: 12px;
    color: #6c757d;
    cursor: move;
}

/* Route Map Styles */
.route-path {
    stroke: #3498db;
    stroke-width: 4;
    stroke-dasharray: 10, 5;
    fill: none;
    animation: dash 1s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -15;
    }
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-family: inherit;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid #3498db;
    color: #3498db;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    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;
}

/* 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;
}

/* MODAL STYLES - ESTOS SON LOS MÁS IMPORTANTES */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background-color: #fff;
    margin: 2% auto;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.3s ease;
}

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

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

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

.modal-content.xlarge {
    width: 95%;
    max-width: 1200px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
}

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

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

.modal-close:hover {
    background: #e9ecef;
    color: #e74c3c;
}

.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

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

/* Form Styles */
.form-tabs {
    margin-bottom: 20px;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    color: #6c757d;
    font-weight: 500;
}

.tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

.tab-btn:hover:not(.active) {
    color: #495057;
    background: #f8f9fa;
}

.tab-content {
    display: none;
}

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

.form-section {
    margin-bottom: 25px;
}

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

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

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

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

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

/* Responsive */
@media (max-width: 768px) {
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .filter-group {
        flex-direction: column;
    }
    
    .clients-list-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .optimization-stats {
        grid-template-columns: 1fr;
    }
    
    .details-grid {
        grid-template-columns: 1fr;
    }
    
    .route-info {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .action-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .quick-stats {
        grid-template-columns: 1fr;
    }
    
    .map-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .pagination {
        flex-direction: column;
        gap: 10px;
    }
    
    .pagination-info {
        margin-left: 0;
        margin-top: 10px;
    }
    
    .modal-content.xlarge,
    .modal-content.large {
        width: 95%;
        margin: 5% auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .tab-buttons {
        flex-direction: column;
    }
    
    .tab-btn {
        text-align: left;
        border-bottom: 1px solid #dee2e6;
        border-left: 3px solid transparent;
    }
    
    .tab-btn.active {
        border-left-color: #3498db;
        border-bottom-color: #dee2e6;
    }
}

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

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