/* Custom Order Form Styles - Compact Mobile First */

/* Rate limit message styles */
.cof-rate-limit-message {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
    line-height: 1.4;
}

.cof-info-message {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
    line-height: 1.4;
}
.cof-container {
    max-width: 500px;
    margin: 8px;
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    overflow: hidden;
    position: relative;
    /* Background image is added via inline CSS in PHP for proper URL handling */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Add overlay for better text readability */
.cof-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    z-index: 0;
}

/* Ensure content is above overlay */
.cof-header,
.cof-form-section {
    position: relative;
    z-index: 1;
}

/* Desktop styling */
@media (min-width: 768px) {
    .cof-container {
        max-width: 600px;
        margin: 20px auto;
        box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    }
}

/* Compact header design */
.cof-header {
    background: transparent;
    padding: 16px 20px;
    text-align: center;
    color: white;
    position: relative;
}

/* Desktop header */
@media (min-width: 768px) {
    .cof-header {
        padding: 24px 30px;
    }
}

/* Add subtle pattern overlay */
.cof-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23ffffff" fill-opacity="0.05"><circle cx="5" cy="5" r="2"/></g></g></svg>');
    pointer-events: none;
}

/* Compact logo design */
.cof-logo {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e2e8f0;
    backdrop-filter: blur(10px);
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2d3748;
    font-weight: 700;
    position: relative;
    z-index: 1;
    /* Dynamic sizing using CSS custom properties */
    width: var(--logo-size-mobile, 60px);
    height: var(--logo-size-mobile, 60px);
    font-size: var(--font-size-mobile, 18px);
}

/* Desktop: Use full size */
@media (min-width: 768px) {
    .cof-logo {
        width: var(--logo-size-desktop, 70px);
        height: var(--logo-size-desktop, 70px);
        font-size: var(--font-size-desktop, 22px);
        margin: 0 auto 16px;
    }
}

.cof-logo-image {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    overflow: hidden;
    padding: 6px;
    margin: 0 auto 12px;
    position: relative;
    z-index: 1;
    /* Dynamic sizing for image logos */
    width: var(--logo-size-mobile, 60px);
    height: var(--logo-size-mobile, 60px);
}

@media (min-width: 768px) {
    .cof-logo-image {
        padding: 8px;
        border-radius: 14px;
        margin: 0 auto 16px;
        width: var(--logo-size-desktop, 70px);
        height: var(--logo-size-desktop, 70px);
    }
}

.cof-logo-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

/* Compact header typography - Dark color for light background */
.cof-header h1 {
    font-size: 1.3em;
    color: #2d3748 !important;
    margin: 0 0 4px 0;
    font-weight: 700;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

/* More specific selector to override theme/Elementor */
.cof-container .cof-header h1,
#custom-order-form-container .cof-header h1 {
    color: #2d3748 !important;
}

/* Desktop typography */
@media (min-width: 768px) {
    .cof-header h1 {
        font-size: 1.5em;
        margin: 0 0 6px 0;
    }
}

.cof-header p {
    color: #4a5568 !important;
    font-size: 0.8em;
    margin: 0;
    line-height: 1.3;
    position: relative;
    z-index: 1;
}

/* More specific selector to override theme/Elementor for description */
.cof-container .cof-header p,
#custom-order-form-container .cof-header p {
    color: #4a5568 !important;
}

/* Ultimate override for all header text - dark colors for light background */
.cof-header * {
    color: #2d3748 !important;
}

.cof-header h1 * {
    color: #2d3748 !important;
}

.cof-header p * {
    color: #4a5568 !important;
}

/* Specific Elementor overrides */
.elementor-widget-container .cof-header h1 {
    color: #2d3748 !important;
}
.elementor-widget-container .cof-header p {
    color: #4a5568 !important;
}

@media (min-width: 768px) {
    .cof-header p {
        font-size: 0.85em;
    }
}

/* Compact form section */
.cof-form-section {
    padding: 16px 20px 20px 20px;
    background: transparent;
}

/* Desktop form section */
@media (min-width: 768px) {
    .cof-form-section {
        padding: 24px 30px 28px 30px;
        background: transparent;
    }
}

/* Compact form groups */
.cof-form-group {
    margin-bottom: 16px;
    position: relative;
}

@media (min-width: 768px) {
    .cof-form-group {
        margin-bottom: 20px;
    }
}

/* Form section steps */
.cof-form-steps {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.cof-step {
    flex: 1;
    height: 4px;
    background: #e1e5e9;
    margin: 0 4px;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.cof-step.active {
    background: #667eea;
}

.cof-step.completed {
    background: #28a745;
}

/* Mobile-first: single column */
.cof-form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

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

/* Desktop: multi-column layout */
@media (min-width: 768px) {
    .cof-form-row {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .cof-form-row-three {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 15px;
    }
}

/* Compact labels with icons */
.cof-form-group label {
    display: block;
    margin-bottom: 6px;
    color: #4a5568;
    font-weight: 600;
    font-size: 0.85em;
    line-height: 1.3;
    position: relative;
}

.cof-required {
    color: #e53e3e;
    font-weight: 700;
    margin-left: 2px;
}

/* Label icons for better UX */
.cof-form-group label::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: #667eea;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

/* Modern compact inputs */
.cof-form-group input, .cof-form-group select, .cof-form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 16px; /* Prevents zoom on iOS */
    transition: all 0.3s ease;
    font-family: inherit;
    background: white;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    color: #2d3748;
    font-weight: 500;
}

/* Desktop inputs */
@media (min-width: 768px) {
    .cof-form-group input, .cof-form-group select, .cof-form-group textarea {
        padding: 12px 16px;
        border-radius: 10px;
        font-size: 15px;
    }
}

/* Enhanced focus states */
.cof-form-group input:focus, .cof-form-group select:focus, .cof-form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
    transform: translateY(-1px);
}

/* Subtle hover effect */
.cof-form-group input:hover:not(:focus), .cof-form-group select:hover:not(:focus) {
    border-color: #cbd5e0;
}

/* Contact row styling */
.cof-contact-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.cof-country-code {
    flex: 0 0 140px; /* Fixed width for country code */
    min-width: 140px;
}

.cof-phone-input {
    flex: 1; /* Take remaining space */
    min-width: 0; /* Allow shrinking */
}

/* Mobile contact styling */
@media (max-width: 480px) {
    .cof-contact-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .cof-country-code {
        flex: none;
        width: 100%;
    }
    
    .cof-phone-input {
        width: 100%;
    }
}

/* Ensure consistent height for contact inputs */
.cof-country-code, .cof-phone-input {
    height: auto;
    min-height: 48px; /* Consistent touch-friendly height */
}

@media (min-width: 768px) {
    .cof-country-code, .cof-phone-input {
        min-height: 44px;
    }
}

/* Compact product selector */
.cof-product-selector {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    line-height: 1.4;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a5568;
    font-weight: 500;
    position: relative;
}

.cof-product-selector::after {
    content: '📦';
    position: absolute;
    right: 14px;
    font-size: 18px;
    opacity: 0.6;
}

.cof-product-selector:hover, .cof-product-selector:active {
    border-color: #667eea;
    background: #f7fafc;
    transform: translateY(-1px);
}

.cof-product-selector.selected {
    border-color: #667eea;
    background: #f0f2ff;
    color: #5a67d8;
}

.cof-product-selector.selected::after {
    content: '✅';
}

/* Compact product grid */
.cof-product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
    border-radius: 8px;
    background: #f8fafc;
}

/* Tablet and up - more columns */
@media (min-width: 480px) {
    .cof-product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-height: 220px;
    }
}

@media (min-width: 768px) {
    .cof-product-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
        max-height: 240px;
    }
}

/* Compact product items */
.cof-product-item {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    min-height: 85px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.cof-product-item:hover, .cof-product-item:active {
    border-color: #667eea;
    transform: translateY(-1px);
}

@media (min-width: 768px) {
    .cof-product-item:hover {
        transform: translateY(-2px);
    }
}

.cof-product-item.selected {
    border-color: #667eea;
    background: #f0f2ff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.cof-product-item.selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

/* Compact product images */
.cof-product-item img {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    margin: 0 auto 6px;
    object-fit: cover;
}

@media (min-width: 768px) {
    .cof-product-item img {
        width: 50px;
        height: 50px;
        margin-bottom: 8px;
    }
}

.cof-product-placeholder {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 6px;
    margin: 0 auto 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: bold;
}

@media (min-width: 768px) {
    .cof-product-placeholder {
        width: 50px;
        height: 50px;
        margin-bottom: 8px;
        font-size: 20px;
    }
}

.cof-product-name {
    font-weight: 600;
    font-size: 0.75em;
    margin-bottom: 3px;
    line-height: 1.1;
    color: #2d3748;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 768px) {
    .cof-product-name {
        font-size: 0.8em;
        margin-bottom: 4px;
    }
}

.cof-product-price {
    color: #e53e3e;
    font-weight: 700;
    font-size: 0.85em;
}

@media (min-width: 768px) {
    .cof-product-price {
        font-size: 0.95em;
    }
}

/* Compact modern submit button */
.cof-submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: none;
    letter-spacing: 0.5px;
    width: 100%;
    margin-top: 20px;
    min-height: 52px; /* Touch-friendly size */
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.cof-submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s;
}

.cof-submit-btn:hover::before {
    left: 100%;
}

/* Desktop button */
@media (min-width: 768px) {
    .cof-submit-btn {
        padding: 15px 40px;
        margin-top: 20px;
        min-height: auto;
    }
}

.cof-submit-btn:hover, .cof-submit-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4);
}

@media (min-width: 768px) {
    .cof-submit-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(233, 30, 99, 0.4);
    }
}

.cof-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(233, 30, 99, 0.2);
}

.cof-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff40;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: cof-spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Mobile messages */
.cof-success-message {
    background: #d4edda;
    color: #155724;
    padding: 16px;
    border-radius: 10px;
    margin: 20px 0;
    border: 1px solid #c3e6cb;
    font-size: 14px;
    line-height: 1.4;
}

.cof-error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 16px;
    border-radius: 10px;
    margin: 20px 0;
    border: 1px solid #f5c6cb;
    font-size: 14px;
    line-height: 1.4;
}

/* Desktop messages */
@media (min-width: 768px) {
    .cof-success-message, .cof-error-message {
        padding: 15px;
        border-radius: 8px;
        font-size: 15px;
    }
}

/* Compact footer */
.cof-footer {
    text-align: center;
    padding: 12px;
    color: #a0aec0;
    font-size: 0.7em;
    background: #f8fafc;
    line-height: 1.2;
    border-top: 1px solid #e2e8f0;
}

@media (min-width: 768px) {
    .cof-footer {
        padding: 16px;
        font-size: 0.75em;
    }
}

/* Compact scrollbar for product grid */
.cof-product-grid::-webkit-scrollbar {
    width: 4px;
}

.cof-product-grid::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

.cof-product-grid::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.cof-product-grid::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}