/**
 * Sale Club Frontend Styles
 *
 * @package SaleClub
 */

/* Base Styles */
.sale-club-form-wrapper,
.sale-club-user-forms-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
}

.sale-club-form-wrapper *,
.sale-club-user-forms-wrapper * {
    box-sizing: border-box;
}

/* Form Container */
.sale-club-form-wrapper {
    max-width: 800px;
    margin: 0 auto 30px;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Form Sections */
.sale-club-form-section {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #e5e5e5;
    border-radius: 5px;
    background: #fafafa;
}

.sale-club-form-section:last-child {
    margin-bottom: 0;
}

.sale-club-form-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 10px;
    font-size: 18px;
    font-weight: 600;
}

/* Form Layout */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
    min-width: 250px;
}

/* Form Elements */
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 5px rgba(0, 115, 170, 0.3);
}

.form-group input[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
}

/* Error States */
.form-group input.error,
.form-group select.error {
    border-color: #dc3545;
    background-color: #fff5f5;
}

.field-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 3px;
    display: block;
}

/* Serial Items */
.serial-item {
    margin-bottom: 15px;
    padding: 15px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    position: relative;
}

.serial-item:last-child {
    margin-bottom: 0;
}

.serial-item .form-row {
    margin-bottom: 0;
    align-items: end;
}

.serial-item .remove-serial-btn {
    background: #dc3545;
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    height: 38px;
    margin-top: 23px;
    transition: background-color 0.3s ease;
}

.serial-item .remove-serial-btn:hover {
    background: #c82333;
}

/* Form Actions */
.form-actions {
    text-align: center;
    margin: 20px 0;
    padding-top: 15px;
    border-top: 1px solid #e5e5e5;
}

.form-submit-section {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #e5e5e5;
}

/* Buttons */
.button {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    line-height: 1;
    min-height: 40px;
}

.button.primary {
    background: #0073aa;
    color: white;
}

.button.primary:hover {
    background: #005a87;
}

.button.secondary {
    background: #6c757d;
    color: white;
}

.button.secondary:hover {
    background: #545b62;
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Form Messages */
.form-messages {
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: 4px;
    font-size: 14px;
}

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

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

.form-messages ul {
    margin: 10px 0 0 0;
    padding-right: 20px;
}

.form-messages li {
    margin-bottom: 5px;
}

/* Utility Classes */
.serial-info {
    margin-right: 15px;
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
}

.sale-club-login-message {
    text-align: center;
    padding: 30px 20px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    color: #6c757d;
    font-size: 16px;
}

/* User Forms Styles */
.sale-club-user-forms-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Statistics Section */
.stats-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stats-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
}

.stat-item {
    padding: 20px 15px;
    text-align: center;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.stat-item.total { 
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: #adb5bd;
}
.stat-item.pending { 
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-color: #ffeaa7;
}
.stat-item.approved { 
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border-color: #bee5eb;
}
.stat-item.installed { 
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #c3e6cb;
}
.stat-item.paid { 
    background: linear-gradient(135deg, #d4edda 0%, #28a745 100%);
    color: white;
    border-color: #28a745;
}
.stat-item.rewards { 
    background: linear-gradient(135deg, #e2e3e5 0%, #6f42c1 100%);
    color: white;
    border-color: #6f42c1;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

/* Filters Section */
.filters-section {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e5e5e5;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    flex: 1;
}

.filter-group label {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
    font-weight: 600;
    text-transform: uppercase;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 3px rgba(0, 115, 170, 0.3);
}

/* No Forms Message */
.no-forms-message {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.no-forms-message p {
    font-size: 18px;
    color: #6c757d;
    margin-bottom: 25px;
}

/* Forms Table */
.forms-table-wrapper {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.forms-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 800px;
}

.forms-table th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 12px;
    text-align: right;
    border-bottom: 2px solid #dee2e6;
    color: #495057;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.forms-table td {
    padding: 15px 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.forms-table tbody tr {
    transition: background-color 0.3s ease;
}

.forms-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Special Table Columns */
.form-id strong {
    color: #0073aa;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.serial code {
    background: #f1f3f4;
    padding: 4px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #333;
    border: 1px solid #e5e5e5;
}

.buyer-info strong {
    display: block;
    margin-bottom: 3px;
    color: #333;
}

.buyer-info small {
    color: #6c757d;
    font-size: 12px;
}

/* Status Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    display: inline-block;
    min-width: 80px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.pending { 
    background: #fff3cd; 
    color: #856404; 
    border: 1px solid #ffeaa7;
}
.status-badge.success { 
    background: #d4edda; 
    color: #155724; 
    border: 1px solid #c3e6cb;
}
.status-badge.error { 
    background: #f8d7da; 
    color: #721c24; 
    border: 1px solid #f5c6cb;
}
.status-badge.warning { 
    background: #ffeeba; 
    color: #856404; 
    border: 1px solid #ffeaa7;
}
.status-badge.info { 
    background: #d1ecf1; 
    color: #0c5460; 
    border: 1px solid #bee5eb;
}

/* Reward Display */
.reward strong {
    color: #28a745;
    font-weight: 700;
}

.potential-reward {
    color: #ffc107;
    font-weight: 600;
}

.potential-reward small {
    display: block;
    font-size: 10px;
    color: #6c757d;
    margin-top: 2px;
}

.no-reward {
    color: #adb5bd;
    font-style: italic;
}

.no-check {
    color: #6c757d;
    font-style: italic;
    font-size: 12px;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    margin-left: -10px;
    border: 2px solid #ccc;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .sale-club-form-wrapper,
    .sale-club-user-forms-wrapper {
        margin: 10px;
        padding: 15px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        min-width: auto;
    }
    
    .serial-item .form-row {
        flex-direction: column;
    }
    
    .serial-item .remove-serial-btn {
        margin-top: 10px;
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-item {
        padding: 15px 10px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .filters-section {
        flex-direction: column;
        padding: 15px;
    }
    
    .filter-group {
        min-width: auto;
    }
    
    .forms-table {
        font-size: 12px;
    }
    
    .forms-table th,
    .forms-table td {
        padding: 10px 6px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .button {
        width: 100%;
        margin-bottom: 5px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .forms-table {
        font-size: 11px;
    }
    
    .forms-table th,
    .forms-table td {
        padding: 8px 4px;
    }
    
    .status-badge {
        font-size: 10px;
        padding: 4px 8px;
        min-width: 60px;
    }
}

/* Cascading Dropdown Styles */
.form-group select:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

.loading-cities {
    color: #666;
    font-size: 12px;
    font-style: italic;
    margin-top: 8px;
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-cities::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #666;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
}

.sale-club-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    padding: 8px 10px;
    background: #f8d7da;
    border: 1px solid #f1aeb5;
    border-radius: 4px;
    border-right: 4px solid #dc3545;
}

/* Enhanced select dropdown styling */
.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 45px;
}

.form-group select:disabled {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23999' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* Animation for loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* State and City validation styling */
#owner_state:invalid, 
#owner_city:invalid {
    border-color: #dc3545;
    box-shadow: 0 0 5px rgba(220, 53, 69, 0.3);
}

#owner_state:focus:valid,
#owner_city:focus:valid {
    border-color: #28a745;
    box-shadow: 0 0 5px rgba(40, 167, 69, 0.3);
}

/* Hover effects for dropdowns */
.form-group select:hover:not(:disabled) {
    border-color: #0073aa;
    cursor: pointer;
}

/* Loading state for city dropdown */
#owner_city:disabled + .loading-cities {
    display: block;
}

/* Success state indicators */
.form-group.has-success label::after {
    content: " ✓";
    color: #28a745;
    font-weight: bold;
}

/* Print Styles */
@media print {
    .filters-section,
    .form-actions,
    .remove-serial-btn {
        display: none;
    }
    
    .sale-club-form-wrapper,
    .sale-club-user-forms-wrapper {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .forms-table {
        font-size: 12px;
    }
    
    .forms-table th {
        background: #f0f0f0 !important;
    }
}
