/* Variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --success: #27ae60;
    --warning: #f39c12;
    --error: #e74c3c;
    --info: #3498db;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border: #dfe6e9;
    --background: #f8f9fa;
    --surface: #ffffff;
}

/* Filters Section */
.filters-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.search-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 250px;
}

.search-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-select {
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--primary-color);
}

.btn-create-planning {
    padding: 10px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-create-planning:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.2);
}

.btn-create-planning svg {
    width: 16px;
    height: 16px;
}

.stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 700;
    color: var(--primary-color);
}

/* Orders Table */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 20px;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.orders-table thead {
    background: var(--background);
    border-bottom: 2px solid var(--border);
}

.orders-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.813rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.orders-table th.col-order-id {
    width: 100px;
}

.orders-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.order-row {
    transition: background-color 0.2s ease;
}

.order-row:hover {
    background: rgba(52, 73, 94, 0.02);
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background: rgba(52, 73, 94, 0.05) !important;
}

.order-order-id {
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
    font-size: 0.875rem;
}

.order-date {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.order-id {
    font-weight: 600;
    color: var(--primary-color);
}

.order-patient {
    font-weight: 500;
    color: var(--text-primary);
}

.order-partner {
    color: var(--text-secondary);
}

.order-state {
    text-align: center;
}

.state-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-badge.placed {
    background: #fff3e0;
    color: #f57c00;
}

.state-badge.pickup {
    background: #e3f2fd;
    color: #1976d2;
}

.state-badge.waiting_for_model {
    background: #f3e5f5;
    color: #7b1fa2;
}

.state-badge.waiting_approval {
    background: #e8f5e9;
    color: #388e3c;
}

.state-badge.production {
    background: #e8f5e9;
    color: #2e7d32;
}

.state-badge.incident {
    background: #fff3e0;
    color: #f57c00;
}

.state-badge.triage_rejected {
    background: #ffebee;
    color: #c62828;
}

.state-badge.waiting-supervisor {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.state-badge.waiting-admin {
    background: rgba(156, 39, 176, 0.15);
    color: #9c27b0;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

.state-badge.completed {
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.order-actions {
    text-align: center;
    white-space: nowrap;
}

.order-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.order-actions .btn-view {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    background: var(--primary-color) !important;
    color: white !important;
}

.order-actions .btn-view:hover {
    background: var(--secondary-color) !important;
    transform: scale(1.05) !important;
}

.order-actions svg {
    width: 16px !important;
    height: 16px !important;
    stroke: white !important;
    fill: none !important;
}

.order-products {
    text-align: center;
    font-weight: 500;
    color: var(--text-primary);
}

.order-total {
    text-align: right;
    font-weight: 600;
    color: var(--success);
}

/* No Orders */
.no-orders {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
}

.no-orders svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--text-secondary);
    opacity: 0.5;
}

.no-orders h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.no-orders p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Loading */
.loading {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    min-height: 120px;
}

.loading[style*="display: none"] {
    display: none !important;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Pagination Section */
.pagination-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

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

.pagination-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-page {
    padding: 6px 12px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 4px;
}

.page-number,
.btn-page-number {
    min-width: 32px;
    padding: 6px 8px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.page-number:hover,
.btn-page-number:hover {
    background: var(--background);
    border-color: var(--primary-color);
}

.page-number.active,
.btn-page-number.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 700;
}

.items-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.items-per-page label {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .filters-section {
        padding: 12px;
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-group {
        min-width: 100%;
    }

    .btn-create-planning {
        width: 100%;
        justify-content: center;
    }

    .pagination-section {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn-page {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .page-numbers {
        order: -1;
        width: 100%;
        justify-content: center;
        margin-bottom: 8px;
    }

    .items-per-page {
        width: 100%;
        justify-content: center;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .orders-table {
        min-width: 750px;
    }
    
    .orders-table th,
    .orders-table td {
        padding: 8px 12px;
        font-size: 0.813rem;
    }
    
    .order-actions .btn-view {
        width: 28px !important;
        height: 28px !important;
    }
    
    .order-actions svg {
        width: 14px !important;
        height: 14px !important;
    }
}

/* Loading en la tabla */
.loading-row {
    background: var(--surface);
}

.loading-cell {
    text-align: center;
    padding: 40px 20px !important;
    vertical-align: middle;
}

.loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: 2px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

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

.confirm-modal .modal-body {
    text-align: center;
    padding: 30px 20px;
}

.confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: rgba(39, 174, 96, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-icon svg {
    width: 32px;
    height: 32px;
    color: var(--success);
}

.confirm-modal p {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

.btn-cancel {
    padding: 10px 20px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: var(--background);
}

.btn-confirm {
    padding: 10px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-confirm:hover {
    background: #229954;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

/* Alert Modal */
.alert-modal .modal-body {
    text-align: center;
    padding: 20px;
}

.alert-modal p {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 0;
}

/* Checkboxes en tabla */
.orders-table th input[type="checkbox"],
.orders-table td input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Botón de aprobar individual */
.btn-approve-single {
    padding: 6px 12px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.813rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-approve-single:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

.btn-approve-single svg {
    flex-shrink: 0;
}