/* Custom styles for shipping calculator */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f7fafc;
}
.main-container {
    min-height: 80vh;
    padding-bottom: 5rem;
}
.sqc-card {
    max-width: 900px;
    margin: 2rem auto;
    padding: 1.5rem;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.sqc-price {
    font-size: 1.75rem; /* Reduced from 2.25rem to fit 3 columns */
    font-weight: 800;
    margin-top: 0.5rem;
}
.sqc-tier-card {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-width: 2px;
    border-color: transparent;
    min-height: 140px; /* Added for consistent height */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.sqc-tier-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.sqc-tier-card.selected {
    border-color: #3182ce;
    background-color: #ebf8ff;
    box-shadow: 0 4px 10px rgba(49, 130, 206, 0.4);
}

/* Tier-specific border colors when selected */
.sqc-tier-card[data-tier=economy].selected {
    border-color: #10b981; /* Green for Economy */
    background-color: #f0fdf4;
}
.sqc-tier-card[data-tier=standard].selected {
    border-color: #3b82f6; /* Blue for Standard */
    background-color: #eff6ff;
}
.sqc-tier-card[data-tier=express].selected {
    border-color: #ef4444; /* Red for Express */
    background-color: #fef2f2;
}

.view-content {
    padding: 2rem 1rem;
    max-width: 1000px;
    margin: 0 auto;
}
.package-item {
    border: 1px solid #e2e8f0;
    padding: 1.5rem; /* Increased padding */
    border-radius: 8px;
    background-color: #ffffff; /* Changed from #f7fafc for better contrast */
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative; /* Added for active-package-indicator */
    transition: all 0.3s ease; /* Added for smooth transitions */
}
.address-section {
    transition: all 0.3s ease;
}
.identical-package {
    background-color: #f0fff4;
    border-color: #38a169;
}

/* NEW: Package-level recipient address styles */
.package-address-section {
    border-left: 4px solid #10b981;
    padding-left: 1rem;
    margin-top: 1.5rem;
    background-color: #f9fafb;
    border-radius: 0 8px 8px 0;
}

.address-select-dropdown {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: white;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: border-color 0.2s;
}

.address-select-dropdown:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.address-fields-hidden {
    display: none;
}

.address-fields-visible {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

/* Package header with number */
.package-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
}

.package-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.package-number-badge {
    background-color: #3b82f6;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Validation warnings */
.field-warning {
    border-color: #f59e0b !important;
    background-color: #fffbeb !important;
}

/* VALIDATION STYLES - ADDED */
.field-error {
    border-color: #dc2626 !important;
    background-color: #fef2f2 !important;
}

.field-valid {
    border-color: #10b981 !important;
    background-color: #f0fdf4 !important;
}

.validation-error {
    color: #dc2626;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: block;
}

.line-through {
    text-decoration: line-through;
}

.validation-warning {
    font-size: 0.75rem;
    color: #d97706;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
}

.validation-error {
    font-size: 0.75rem;
    color: #dc2626;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
}

/* Volume calculator */
.volume-calc-active {
    background-color: #e9d5ff !important;
}

/* Recipient sections - Updated */
.recipient-section {
    border-left: 4px solid #3b82f6;
    padding-left: 0.75rem;
}

.custom-recipient-section {
    border-left: 4px solid #10b981;
    padding-left: 0.75rem;
}

/* Transition effects */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sqc-card {
        padding: 1rem;
        margin: 1rem auto;
    }
    
    .view-content {
        padding: 1rem 0.5rem;
    }
    
    .sqc-price {
        font-size: 1.5rem;
    }
    
    /* Stack tiers on mobile */
    #tier_options {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .sqc-tier-card {
        min-height: auto;
        padding: 1rem;
    }
    
    /* Package form adjustments for mobile */
    .package-item {
        padding: 1rem;
    }
    
    .package-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 640px) {
    .package-title {
        font-size: 1.125rem;
    }
    
    .package-number-badge {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modal backdrop */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

/* =========================================== */
/* CANADA POST SPECIFIC STYLES (NEW ADDITIONS) */
/* =========================================== */

/* Custom styling for Canada Post dropdown */
.pcaautocomplete {
    font-family: inherit !important;
    font-size: 14px !important;
    z-index: 9999 !important; /* Ensure it appears above everything */
}

.pcaautocomplete ul {
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    max-height: 300px !important;
    overflow-y: auto !important;
}

.pcaautocomplete li {
    padding: 10px 16px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    font-size: 14px !important;
}

.pcaautocomplete li:last-child {
    border-bottom: none !important;
}

.pcaautocomplete li:hover,
.pcaautocomplete li.pcahighlight {
    background-color: #f0f7ff !important;
    color: #3182ce !important;
}

/* Canada Post input field styling */
input.address {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%233182ce" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path><circle cx="12" cy="10" r="3"></circle></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 20px 20px !important;
    padding-right: 40px !important;
}

/* Canada Post loading indicator */
.pcaautocomplete li.pcaloading {
    text-align: center !important;
    color: #666 !important;
    font-style: italic !important;
}

/* Canada Post error message */
.pcaautocomplete .pcaerrormessage {
    color: #dc2626 !important;
    padding: 10px !important;
    font-size: 13px !important;
}

/* Ensure Canada Post doesn't conflict with Tailwind */
.pcaautocomplete * {
    box-sizing: border-box !important;
}

/* Canada Post container positioning */
div[data-pcacontainer] {
    position: relative !important;
}

/* Make sure Canada Post matches your form styling */
input.address::placeholder {
    color: #9ca3af !important;
}

/* Canada Post active/focus state */
input.address:focus {
    border-color: #3182ce !important;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1) !important;
}

/* Visual indicator for Canada Post fields */
.address-hint {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
    display: block;
}

/* Fix for mobile devices - Canada Post */
@media (max-width: 640px) {
    .pcaautocomplete ul {
        max-height: 250px !important;
        font-size: 13px !important;
    }
    
    .pcaautocomplete li {
        padding: 8px 12px !important;
    }
    
    input.address {
        background-size: 16px 16px !important;
        padding-right: 36px !important;
    }
}

/* NEW: Three-tier specific styles */
.tier-icon {
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.tier-description {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* Tier color coding */
.tier-economy .sqc-price {
    color: #10b981; /* Green */
}

.tier-standard .sqc-price {
    color: #3b82f6; /* Blue */
}

.tier-express .sqc-price {
    color: #ef4444; /* Red */
}

/* Package address selection styles */
.address-option-same {
    font-style: italic;
    color: #6b7280;
}

.address-option-new {
    font-weight: 600;
    color: #1f2937;
}

/* Package form grid improvements */
.package-details-grid {
    display: grid;
    gap: 1rem;
}

@media (min-width: 768px) {
    .package-details-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Required field indicators */
.required-field::after {
    content: " *";
    color: #dc2626;
}

/* Field grouping for better spacing */
.field-group {
    margin-bottom: 1.5rem;
}

.field-group:last-child {
    margin-bottom: 0;
}

/* Address selection dropdown container */
.address-selection-container {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* NEW STYLES FOR UPDATES */

/* Required field indicator */
.required-field::after {
    content: " *";
    color: #dc2626;
}

/* Package type dropdown styling */
.package-type {
    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 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Quantity selector */
#package_quantity {
    width: 70px;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background-color: white;
}

/* Collapsible package sections */
.package-content {
    transition: all 0.3s ease;
}

.package-content.hidden {
    display: none;
}

.collapse-package svg {
    transition: transform 0.3s ease;
}

/* Three-tier price display in quick quote */
#quick_quote_result .grid {
    margin-top: 0.5rem;
}

#quick_quote_result .bg-white {
    transition: transform 0.2s ease;
}

#quick_quote_result .bg-white:hover {
    transform: translateY(-2px);
}

/* Edit buttons in summary */
button[onclick*="edit"]:hover {
    text-decoration: underline;
}

/* Volume display warning */
.volume-display .text-yellow-600 {
    background-color: #fef3c7;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-top: 0.25rem;
}

/* Package type colors */
.package-type option[value="document"] {
    background-color: #f3f4f6;
}

.package-type option[value="small_box"] {
    background-color: #dbeafe;
}

.package-type option[value="medium_box"] {
    background-color: #fef3c7;
}

.package-type option[value="large_box"] {
    background-color: #fce7f3;
}

.package-type option[value="pallet"] {
    background-color: #dcfce7;
}

.package-type option[value="tube"] {
    background-color: #f0e7ff;
}

/* =========================================== */
/* VISUAL ENHANCEMENTS (NEW ADDITIONS) */
/* =========================================== */

/* Discount badges */
.discount-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    margin-left: 8px;
}

.package-group-discounted {
    border-left: 4px solid #10b981;
    background-color: #f0fdf4;
}

.discount-bubble {
    width: 24px;
    height: 24px;
    background: #f59e0b;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* Address selection badges */
.address-badge {
    background: #e0f2fe;
    border: 1px solid #7dd3fc;
    border-radius: 6px;
    padding: 6px 10px;
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.badge-text {
    color: #0369a1;
    font-weight: 500;
}

.badge-edit {
    background: #38bdf8;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
}

.badge-edit:hover {
    background: #0ea5e9;
}

/* Shared address highlighting */
.shared-address-highlight {
    background: linear-gradient(90deg, transparent 95%, #60a5fa 95%);
}

.shared-address .receiver-address-fields {
    opacity: 0.6;
}

/* Volume discount indicators */
.volume-discount-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #f59e0b;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Enhanced quick quote styling */
#quick_quote_result .discount-breakdown {
    background: #fef3c7;
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
    font-size: 12px;
}

.discount-item {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
}

.discount-value {
    color: #059669;
    font-weight: 600;
}

/* Package type icons */
.package-type-option {
    display: flex;
    align-items: center;
    padding: 8px;
}

.package-type-icon {
    margin-right: 8px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive enhancements */
@media (max-width: 768px) {
    .address-badge {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .badge-edit {
        align-self: flex-end;
    }
    
    .discount-badge {
        font-size: 10px;
        padding: 1px 6px;
    }
}

/* Animation for price updates */
@keyframes priceUpdate {
    0% { background-color: transparent; }
    50% { background-color: #fef3c7; }
    100% { background-color: transparent; }
}

.price-updated {
    animation: priceUpdate 1s ease;
}

/* Tier-specific enhancements */
.tier-economy .tier-savings {
    color: #10b981;
    font-size: 0.875rem;
    margin-top: 4px;
}

.tier-standard .tier-savings {
    color: #3b82f6;
    font-size: 0.875rem;
    margin-top: 4px;
}

.tier-express .tier-savings {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 4px;
}

/* Enhanced button styles */
.btn-enhanced {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

.btn-enhanced:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3);
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.btn-enhanced:active {
    transform: translateY(0);
}

/* Enhanced card hover effects */
.sqc-tier-card:hover .sqc-price {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Package selection effects */
.package-item.selected-for-bulk {
    border-color: #8b5cf6;
    background-color: #f5f3ff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

/* Address matching visualization */
.address-match-indicator {
    height: 4px;
    background: linear-gradient(90deg, #10b981, #3b82f6);
    border-radius: 2px;
    margin: 8px 0;
    position: relative;
    overflow: hidden;
}

.address-match-indicator::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Enhanced form field focus */
input:focus, select:focus, textarea:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-color: transparent !important;
}

/* Success animation */
@keyframes successPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
}

.success-pulse {
    animation: successPulse 2s infinite;
}

/* =========================================== */
/* FIX 3: ADD CSS FOR BETTER VISUAL FEEDBACK */
/* =========================================== */

/* Active package styling */
.package-item.active-package {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background-color: #f8fafc;
}

/* Collapsed package styling */
.package-item.collapsed-package {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.package-item.collapsed-package .package-content {
    display: none;
}

/* Collapse button styling */
.collapse-package {
    transition: transform 0.3s ease;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #64748b;
    font-size: 0.875rem;
}

.collapse-package:hover {
    color: #3b82f6;
}

.collapse-package svg {
    transition: transform 0.3s ease;
    width: 20px;
    height: 20px;
}

.collapse-package.collapsed svg {
    transform: rotate(-90deg);
}

/* Loading spinner for quote calculation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Visual indicator for active package */
.active-package-indicator {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 10px;
    height: 10px;
    background-color: #3b82f6;
    border-radius: 50%;
    box-shadow: 0 0 0 2px white;
}

/* Add pulse animation for newly added packages */
.package-item.new-package {
    animation: highlightPulse 2s ease;
}

@keyframes highlightPulse {
    0%, 100% { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); }
    50% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); }
}

/* Better visual feedback for form validation */
.form-group {
    position: relative;
    margin-bottom: 1.25rem;
}

.form-group .validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
}

.form-group.valid .validation-icon.valid {
    display: block;
    color: #10b981;
}

.form-group.invalid .validation-icon.invalid {
    display: block;
    color: #ef4444;
}

/* Smooth transition for showing/hiding content */
.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus states for better accessibility */
.package-item:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Visual feedback for interactive elements */
.interactive-element {
    transition: all 0.2s ease;
}

.interactive-element:hover {
    transform: translateY(-1px);
}

.interactive-element:active {
    transform: translateY(0);
}

/* Loading overlay for quote calculation */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

/* Error state styling */
.error-state {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.error-state .error-message {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Success state styling */
.success-state {
    border-color: #10b981;
    background-color: #f0fdf4;
}

.success-state .success-message {
    color: #059669;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Updated spin animation to avoid conflicts */
@keyframes enhanced-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.enhanced-spinner {
    animation: enhanced-spin 1s linear infinite;
}

/* =========================================== */
/* NEW VISUAL FEEDBACK STYLES (Step 2 Update) */
/* =========================================== */

.active-package {
    border: 2px solid #3b82f6 !important;
    background-color: #f0f9ff !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15) !important;
}

.collapsed-package {
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

.collapsed-package .package-content {
    display: none !important;
}

.collapse-package svg {
    transition: transform 0.3s ease;
}

.collapse-package.collapsed svg {
    transform: rotate(-90deg);
}

.package-item {
    position: relative;
    transition: all 0.3s ease;
}

/* Active package indicator */
.active-package::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 3px 3px 0 0;
}

/* Collapsed state styling */
.collapsed-package .package-header {
    padding: 12px;
    background: #f8fafc;
    border-radius: 6px;
}

.collapsed-package h4 {
    color: #64748b;
    font-weight: 500;
}