/**
 * Site Survey Styles
 */

#site-survey-container {
    /* max-width: 1200px; */
    margin: 0 auto;
    padding: 20px;
}

#site-survey-container h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: 600;
}

.site-survey-message {
    display: none;
    margin: 10px 0 20px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}

.site-survey-message.message-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.site-survey-message.message-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.site-survey-message.message-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

/* Dashboard Cards Section */
.site-survey-dashboard {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    overflow-x: auto;
}

.site-survey-dashboard-secondary {
    margin-bottom: 12px;
}

.dashboard-card {
    flex: 1 1 auto;
    min-width: 140px;
    max-width: 200px;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.dashboard-card-total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-left: 3px solid #4c63d2;
}

.dashboard-card-total .dashboard-card-label,
.dashboard-card-total .dashboard-card-count {
    color: #fff;
}

.dashboard-card-content {
    padding: 12px 10px;
    text-align: center;
}

.dashboard-card-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
    color: #495057;
    line-height: 1.2;
}

.dashboard-card-count {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

/* Status-specific colors */
/* Internal Status (ACF) */
.dashboard-card[data-status="pending_engineer_review"] {
    background: linear-gradient(135deg, #cfe2ff 0%, #b6d4fe 100%);
    border-left: 3px solid #084298;
}

.dashboard-card[data-status="pending_engineer_review"] .dashboard-card-label,
.dashboard-card[data-status="pending_engineer_review"] .dashboard-card-count {
    color: #084298;
}

.dashboard-card[data-status="in_review"] {
    background: linear-gradient(135deg, #cff4fc 0%, #b8e9f2 100%);
    border-left: 3px solid #055160;
}

.dashboard-card[data-status="in_review"] .dashboard-card-label,
.dashboard-card[data-status="in_review"] .dashboard-card-count {
    color: #055160;
}

.dashboard-card[data-status="pending_customer_review"] {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-left: 3px solid #856404;
}

.dashboard-card[data-status="pending_customer_review"] .dashboard-card-label,
.dashboard-card[data-status="pending_customer_review"] .dashboard-card-count {
    color: #856404;
}

.dashboard-card[data-status="approved"] {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left: 3px solid #155724;
}

.dashboard-card[data-status="approved"] .dashboard-card-label,
.dashboard-card[data-status="approved"] .dashboard-card-count {
    color: #155724;
}

.dashboard-card[data-status="rejected"] {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left: 3px solid #721c24;
}

.dashboard-card[data-status="rejected"] .dashboard-card-label,
.dashboard-card[data-status="rejected"] .dashboard-card-count {
    color: #721c24;
}

/* Submitted Status (Post Status) */
.dashboard-card[data-status="draft"][data-type="post"] {
    background: linear-gradient(135deg, #e2e3e5 0%, #d6d8db 100%);
    border-left: 3px solid #6c757d;
}

.dashboard-card[data-status="draft"][data-type="post"] .dashboard-card-label,
.dashboard-card[data-status="draft"][data-type="post"] .dashboard-card-count {
    color: #383d41;
}

.dashboard-card[data-status="submitted"] {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border-left: 3px solid #0c5460;
}

.dashboard-card[data-status="submitted"] .dashboard-card-label,
.dashboard-card[data-status="submitted"] .dashboard-card-count {
    color: #0c5460;
}

/* Payment Status */
.dashboard-card[data-status="not_paid"] {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-left: 3px solid #721c24;
}

.dashboard-card[data-status="not_paid"] .dashboard-card-label,
.dashboard-card[data-status="not_paid"] .dashboard-card-count {
    color: #721c24;
}

.dashboard-card[data-status="free_trial"] {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-left: 3px solid #856404;
}

.dashboard-card[data-status="free_trial"] .dashboard-card-label,
.dashboard-card[data-status="free_trial"] .dashboard-card-count {
    color: #856404;
}

.dashboard-card[data-status="paid"] {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left: 3px solid #155724;
}

.dashboard-card[data-status="paid"] .dashboard-card-label,
.dashboard-card[data-status="paid"] .dashboard-card-count {
    color: #155724;
}

/* Filters Section */
.site-survey-filters {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-input,
.filter-select {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    color: #495057;
    transition: border-color 0.3s ease;
    height: 45px;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.filter-buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
    flex: 0 0 auto;
    align-items: flex-end;
}

.filter-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    height: 45px;
    box-sizing: border-box;
}

.filter-btn-primary {
    background-color: #007bff;
    color: white;
}

.filter-btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.filter-btn-secondary {
    background-color: #6c757d;
    color: white;
}

.filter-btn-secondary:hover {
    background-color: #545b62;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(108, 117, 125, 0.3);
}

/* Loading and Error States */
.loading, .error, .no-surveys {
    text-align: center;
    padding: 40px 20px;
    font-size: 16px;
}

.loading {
    color: #666;
}

.error {
    color: #d63384;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.no-surveys {
    color: #6c757d;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

/* Table Styles */
.site-survey-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.site-survey-table thead {
    background-color: #f8f9fa;
}

.site-survey-table th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.site-survey-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.site-survey-table th.sortable:hover {
    background-color: #e9ecef;
}

.sort-icon {
    display: inline-block;
    margin-left: 5px;
    font-size: 12px;
    color: #007bff;
    font-weight: bold;
}

.sort-icon-inactive {
    color: #adb5bd;
    opacity: 0.6;
}

.site-survey-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
    color: #495057;
}

/* Columnas con wrap de texto */
.site-survey-table td.contact-email-cell,
.site-survey-table td.internal-status-cell {
    word-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    max-width: 200px;
    min-width: 150px;
}

/* Asegurar que los badges también hagan wrap si es necesario */
.site-survey-table td.internal-status-cell .status-badge {
    white-space: normal;
    word-wrap: break-word;
    display: inline-block;
    max-width: 100%;
}

.site-survey-table tbody tr:hover {
    background-color: #f8f9fa;
}

.site-survey-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges - Internal Status (same colors as admin-survey-list.php) */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    color: #fff;
}

.status-badge.status-pending-engineer-review {
    background-color: #ff9800; /* Orange - same as admin-survey-list.php */
    color: #fff;
}

.status-badge.status-in-review {
    background-color: #ffc107; /* Yellow - same as admin-survey-list.php */
    color: #333; /* Dark text for better contrast */
}

.status-badge.status-pending-customer-review {
    background-color: #2196f3; /* Blue - same as admin-survey-list.php */
    color: #fff;
}

.status-badge.status-approved {
    background-color: #4caf50; /* Green - same as admin-survey-list.php */
    color: #fff;
}

.status-badge.status-rejected {
    background-color: #f44336; /* Red - same as admin-survey-list.php */
    color: #fff;
}

.status-badge.status-draft {
    background-color: #e2e3e5;
    color: #383d41;
}

.status-badge.status-default {
    background-color: #e2e3e5;
    color: #383d41;
}

/* Survey ID Cell */
.survey-id-cell {
    vertical-align: top;
}

/* Order Reference Cell */
.order-reference-cell {
    vertical-align: top;
}

/* Serial Number & Tracking Cell */
.serial-tracking-cell {
   font-size: 13px;
}

.serial-tracking-cell div {
    margin-bottom: 4px;
}

.serial-tracking-cell strong {
    color: #495057;
    font-weight: 600;
}

/* Order Status Badges */
.order-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    color: #fff;
    width: fit-content;
    align-self: flex-start;
    cursor: help;
}

.order-status-badge.order-status-on-hold {
    background-color: #dc3232; /* Red */
    border: 1px solid #dc3232; /* Red border */
    color: #fff; /* White text */
}

.order-status-badge.order-status-shipped {
    background-color: #46b450; /* Green */
    border: 1px solid #46b450; /* Green border */
    color: #fff; /* White text */
}

.order-status-badge.order-status-cancelled {
    background-color: #666; /* Dark Gray */
    border: 1px solid #666; /* Dark Gray border */
    color: #fff; /* White text */
}

.order-status-badge.order-status-missing-information {
    background-color: #f0b849; /* Orange/Yellow */
    border: 1px solid #f0b849; /* Orange/Yellow border */
    color: #333; /* Dark text for better contrast */
}

/* Legacy support for old classes (WooCommerce order statuses) */
.order-status-pending {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.order-status-processing {
    background-color: #cfe2ff;
    color: #084298;
    border: 1px solid #b6d4fe;
}

/* Legacy support for old classes */
.order-status-on-hold {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.order-status-completed {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.order-status-cancelled {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.order-status-refunded {
    background-color: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
}

.order-status-failed {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.order-status-free-trial {
    background-color: #03a9f4;
    color: #ffff;
    border: 1px solid #03a9f4;
}

.order-status-default {
    background-color: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
}

/* Post Status Badge (Submitted Status) */
.post-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    margin-top: 4px;
    white-space: nowrap;
    color: #fff;
}

.post-status-badge.post-status-draft,
.survey-id-cell .post-status-badge.post-status-draft {
    background-color: #ff9800 !important; /* Orange - same as admin-survey-list.php */
    color: #fff !important;
}

.post-status-badge.post-status-submitted,
.post-status-badge.post-status-publish,
.post-status-badge.post-status-published,
.survey-id-cell .post-status-badge.post-status-submitted,
.survey-id-cell .post-status-badge.post-status-publish,
.survey-id-cell .post-status-badge.post-status-published {
    background-color: #4caf50 !important; /* Green - same as admin-survey-list.php */
    color: #fff !important;
}

.post-status-pending {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.post-status-default {
    background-color: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
}

/* Agreement Status Badges (DocuSign) - Same style as post-status-badge */
.post-status-badge.agreement-status-sent,
.post-status-badge.agreement-status-delivered {
    background-color: #cfe2ff !important;
    color: #084298 !important;
    border: 1px solid #b6d4fe !important;
}

.post-status-badge.agreement-status-completed {
    background-color: #4caf50 !important; /* Same green as Submitted */
    color: #fff !important;
}

.post-status-badge.agreement-status-void,
.post-status-badge.agreement-status-declined {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb !important;
}

/* Survey Actions */
.survey-actions {
    text-align: center;
    padding: 10px;
}

.survey-actions-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.action-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background-color: #007cba;
    color: #ffffff;
    border: 1px solid #007cba;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 124, 186, 0.3);
}

.action-icon-btn:hover {
    background-color: #005a87;
    border-color: #005a87;
    color: #ffffff !important;
    box-shadow: 0 3px 6px rgba(0, 90, 135, 0.4);
    transform: translateY(-1px);
}

.action-icon-btn:hover .dashicons {
    color: #ffffff !important;
}

.action-icon-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 124, 186, 0.3);
}

.action-icon-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}


.send-survey-email-btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    animation: spin 1s linear infinite;
}

.view-survey-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-width: 120px;
    justify-content: center;
    text-decoration: none;
}

.view-survey-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    color: white;
}

.view-survey-btn .view-icon {
    font-size: 14px;
    font-weight: bold;
    display: inline-block;
}

/* Pagination */
.site-survey-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.site-survey-pagination a {
    display: inline-block;
    padding: 8px 12px;
    text-decoration: none;
    color: #007bff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 14px;
}

.site-survey-pagination a:hover {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

.site-survey-pagination a.active {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

.site-survey-pagination .dots {
    padding: 8px 4px;
    color: #6c757d;
}

.site-survey-pagination .prev,
.site-survey-pagination .next {
    font-weight: 600;
}

.pagination-info {
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    margin-top: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    #site-survey-container {
        padding: 10px;
    }
    
    .site-survey-dashboard {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .dashboard-card {
        min-width: 120px;
    }
    
    .dashboard-card-label {
        font-size: 10px;
    }
    
    .dashboard-card-count {
        font-size: 24px;
    }
    
    .site-survey-filters {
        padding: 15px;
    }
    
    .filter-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .filter-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .filter-btn {
        width: 100%;
    }
    
    .site-survey-table {
        font-size: 12px;
    }
    
    .site-survey-table th,
    .site-survey-table td {
        padding: 8px 6px;
    }
    
    .site-survey-table th {
        font-size: 11px;
    }
    
    .status-badge {
        font-size: 10px;
        padding: 3px 8px;
    }
}

/* Tooltip Info Icon */
.tooltip-info-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.7;
    vertical-align: middle;
    cursor: help;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.tooltip-info-icon:hover {
    opacity: 1;
}

.tooltip-info-icon .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    line-height: 1;
    color: inherit;
    opacity: 0.8;
}

.order-status-badge .tooltip-info-icon {
    margin-left: 3px;
}

.order-status-badge .tooltip-info-icon .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* Tooltip styling */
.shipping-status-tooltip {
    position: relative;
}

.shipping-status-tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 8px 12px;
    background-color: #333;
    color: #fff;
    font-size: 12px;
    white-space: pre-line;
    border-radius: 4px;
    z-index: 1000;
    min-width: 200px;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.shipping-status-tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 5px solid transparent;
    border-top-color: #333;
    z-index: 1001;
    pointer-events: none;
}

/* Internal Status Tooltip styling */
.internal-status-tooltip {
    position: relative;
}

.internal-status-tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 8px 12px;
    background-color: #333;
    color: #fff;
    font-size: 12px;
    white-space: pre-line;
    border-radius: 4px;
    z-index: 1000;
    min-width: 250px;
    max-width: 400px;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    line-height: 1.5;
}

.internal-status-tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 2px;
    border: 5px solid transparent;
    border-top-color: #333;
    z-index: 1001;
    pointer-events: none;
}

.status-badge .tooltip-info-icon {
    margin-left: 3px;
}

.status-badge .tooltip-info-icon .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
}

/* Related Agreement Column */
.related-agreement-column {
    vertical-align: top;
    min-width: 150px;
}

.related-agreement-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.agreement-link {
    display: inline-block;
}

.agreement-status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.agreement-status-badge.status-sent {
    background-color: #e3f2fd;
    color: #1976d2;
}

.agreement-status-badge.status-delivered {
    background-color: #fff3e0;
    color: #f57c00;
}

.agreement-status-badge.status-completed {
    background-color: #e8f5e9;
    color: #388e3c;
}

.agreement-status-badge.status-void {
    background-color: #fce4ec;
    color: #c2185b;
}

.agreement-status-badge.status-declined {
    background-color: #ffebee;
    color: #d32f2f;
}

.agreement-status-badge.status-shipped {
    background-color: #e8f5e9;
    color: #388e3c;
}

/* View Deal Button (for site-survey) */
.view-deal-btn {
    background: #2271b1;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
    margin-top: 4px;
}

.view-deal-btn:hover {
    background: #135e96;
}

.view-deal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.view-deal-btn .deal-icon {
    font-size: 12px;
}

.view-deal-btn .loading-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

