/**
 * Frontend styles for ShortcutForm plugin
 */

/* CSS Custom Properties (Variables) */
:root {
    --payment-image-max-width: 64px;
    --payment-image-max-height: 40px;
    --payment-image-border-radius: 4px;
    --payment-image-padding: 0px;
    --payment-image-background: white;
    --payment-image-transition: all 0.2s ease;
    --order-container-background-color: #ffffff;
}

/* Container */
.shortcutform-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
}

/* Typography */
.shortcutform-title {
    text-align: center;
    margin-bottom: 10px;
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.shortcutform-description {
    text-align: center;
    margin-bottom: 30px;
    color: #666;
    font-size: 16px;
}

.shortcutform-description p {
    margin-bottom: 10px;
}

/* Sections */
.shortcutform-section {
    margin-bottom: 30px;
    padding: 25px;
    background: #f9f9f9;
    border-radius: 0.5rem;
    border: 1px solid #e1e1e1;
}

.shortcutform-section h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 3px solid #0073aa;
    padding-bottom: 12px;
    font-size: 20px;
    font-weight: 600;
}

/* Form Fields */
.shortcutform-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.shortcutform-field {
    flex: 1;
}

.shortcutform-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.shortcutform-field input,
.shortcutform-field textarea,
.shortcutform-field select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 0.5rem;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: #fff;
}

.shortcutform-field input:focus,
.shortcutform-field textarea:focus,
.shortcutform-field select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.shortcutform-field textarea {
    resize: vertical;
    min-height: 80px;
}

.required {
    color: #dc3232;
    font-weight: bold;
}

/* Product Grid */
.shortcutform-products {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

/* Product Items */
.shortcutform-product-item {
    display: flex;
    align-items: center;
    padding: 20px;
    margin-bottom: 15px;
    background: #fff;
    border: 2px solid #e1e1e1;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Paket Terlaris Highlight */
.shortcutform-product-item.featured {
    background: linear-gradient(135deg, #d4f8d4 0%, #b8f0b8 100%);
    border: 2px solid #4caf50;
    position: relative;
}

.shortcutform-product-item.featured::before {
    content: "PAKEJ TERLARIS!";
    position: absolute;
    top: 10px;
    right: -30px;
    background: #ff4444;
    color: white;
    padding: 5px 40px;
    font-size: 12px;
    font-weight: bold;
    transform: rotate(45deg);
    z-index: 2;
}

/* Paket Jimat Styling */
.shortcutform-product-item.jimat {
    background: linear-gradient(135deg, #fff9c4 0%, #fff3a0 100%);
    border: 2px solid #ffc107;
}

/* Free Shipping Badge */
.free-shipping-badge {
    background: #17a2b8;
    color: white;
    padding: 3px 8px;
    border-radius: 0.5rem;
    font-size: 10px;
    font-weight: bold;
    margin-right: 8px;
    display: inline-block;
}

/* ShortcutForm Product Badges */
.shortcutform-product-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.shortcutform-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 0.5rem;
    font-size: 12px;
    font-weight: bold;
    margin-right: 5px;
    margin-bottom: 5px;
    transition: all 0.3s ease;
}

.shortcutform-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.shortcutform-free-shipping {
    background-color: #00a32a;
    color: white;
}

.shortcutform-pakej-terlaris {
    background-color: #ff6900;
    color: white;
}

.shortcutform-custom-badge {
    /* Custom badges use inline styles for colors */
    border: none;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* Badge animations */
@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.shortcutform-badge.pulse {
    animation: badgePulse 2s infinite;
}

/* Responsive badge styles */
@media (max-width: 768px) {
    .shortcutform-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* Jimat Badge */
.jimat-badge {
    background: #dc3545;
    color: white;
    padding: 3px 8px;
    border-radius: 0.5rem;
    font-size: 10px;
    font-weight: bold;
    margin-left: 8px;
    display: inline-block;
}

/* Product Selection Control */
.product-selection-control {
    margin-right: 15px;
    display: flex;
    align-items: center;
}

.product-selector {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: #2563EB;
}

/* Product Image Small */
.product-image-small {
    width: 60px;
    height: 60px;
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    border-radius: 0.5rem;
    overflow: hidden;
    flex-shrink: 0;
}

.product-image-small img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 0.5rem;
}

.no-image-small {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
}

.product-selector:checked + .product-image-small + .product-details {
    opacity: 1;
}

.shortcutform-product-item:has(.product-selector:checked) {
    border-color: #2563EB;
    border-width: 3px;
    background: #eff6ff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    font-weight: bold !important;
}

.shortcutform-product-item:has(.product-selector:checked) .product-name,
.shortcutform-product-item:has(.product-selector:checked) .product-price,
.shortcutform-product-item:has(.product-selector:checked) .product-description {
    font-weight: bold !important;
}

/* Single selection mode - hide quantity controls */
.shortcutform-products-list[data-selection-type="single"] .product-quantity {
    display: none !important;
}

/* Multiple selection mode - show quantity controls */
.shortcutform-products-list[data-selection-type="multiple"] .product-quantity {
    display: block;
}

/* Product selection styling */
.shortcutform-product-item label {
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100%;
}

.shortcutform-product-item:hover {
    border-color: #2563EB;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.shortcutform-product {
    background: white;
    border: 2px solid #e1e1e1;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.shortcutform-product.selected {
    border: 4px solid #2563EB;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
    font-weight: bold !important;
}

.shortcutform-product.selected .product-name,
.shortcutform-product.selected .product-price,
.shortcutform-product.selected .product-description {
    font-weight: bold !important;
}

.shortcutform-product:hover {
    border-color: #2563EB;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
    transform: translateY(-2px);
}

.shortcutform-product.has-quantity {
    border: 4px solid #2563EB;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
    font-weight: bold !important;
}

.shortcutform-product.has-quantity .product-name,
.shortcutform-product.has-quantity .product-price,
.shortcutform-product.has-quantity .product-description {
    font-weight: bold !important;
}

/* Product Image */
.product-image {
    text-align: center;
    margin-bottom: 15px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    border-radius: 8px;
    overflow: hidden;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.3s;
}

.shortcutform-product:hover .product-image img {
    transform: scale(1.05);
}

.no-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    font-weight: 500;
}

/* Product Info */
.product-name {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.product-description {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    line-height: 1.4;
}

.product-price {
    font-size: 20px;
    font-weight: bold;
    color: #2563EB;
    margin-bottom: 15px;
}

/* Product Details Layout */
.product-details {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-info-left {
    flex: 1;
}

.product-price-qty {
    text-align: right;
    min-width: 120px;
}

/* Price Styling */
.product-price {
    margin-bottom: 5px;
}

.original-price {
    color: #999;
    text-decoration: line-through;
    font-size: 14px;
    margin-right: 5px;
}

.current-price {
    color: #dc3545;
    font-size: 20px;
    font-weight: bold;
}

/* Product Title with Badges */
.product-title-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.product-title-row .product-name {
    margin: 0;
    flex: 1;
    min-width: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .shortcutform-product-item {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }
    
    .product-selection-control {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .product-image-small {
        margin-right: 0;
        margin-bottom: 10px;
        width: 80px;
        height: 80px;
    }
    
    .product-details {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .product-price-qty {
        text-align: center;
        min-width: auto;
    }
    
    .product-title-row {
        justify-content: center;
        text-align: center;
    }
    
    .shortcutform-product-item.featured::before {
        right: -20px;
        padding: 3px 30px;
        font-size: 10px;
    }
}

/* Quantity Controls - Arrow Style */
.product-quantity {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 15px;
}

.product-quantity label {
    font-weight: 600;
    color: #333;
    margin-bottom: 0;
    font-size: 14px;
}

/* TikTok Shop Style Quantity Controls */
.flex.items-center.space-x-2 {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 4px;
    width: fit-content;
}

.flex.items-center.space-x-2 button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
}

.flex.items-center.space-x-2 button:hover {
    background: #f0f2f5;
    border-color: #d1d5db;
    color: #333;
}

.flex.items-center.space-x-2 button:active {
    transform: scale(0.95);
    background: #e5e7eb;
}

.flex.items-center.space-x-2 input[type="number"] {
    width: 50px;
    height: 32px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 8px;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
}

.flex.items-center.space-x-2 input[type="number"]::-webkit-outer-spin-button,
.flex.items-center.space-x-2 input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.flex.items-center.space-x-2 input[type="number"]:focus {
    outline: none;
    background: rgba(37, 99, 235, 0.05);
    border-radius: 4px;
}

/* Disabled state */
.flex.items-center.space-x-2 button:disabled {
    background: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
    border-color: #e5e5e5;
}

.flex.items-center.space-x-2 button:disabled:hover {
    background: #f5f5f5;
    transform: none;
}

.quantity-controls {
    display: flex;
    align-items: center;
    border: 2px solid #ddd;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #fff;
}

.qty-btn {
    background: #f8f9fa;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s;
    color: #333;
    min-width: 40px;
}

.qty-btn:hover {
    background: #e9ecef;
    color: #2563EB;
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-input {
    border: none;
    width: 70px;
    text-align: center;
    padding: 10px 8px;
    font-size: 16px;
    font-weight: 600;
    background: #fff;
}

.qty-input:focus {
    outline: none;
    background: #f8f9fa;
}

/* Order Summary */
#order-summary {
    background: white;
    border: 2px solid #e1e1e1;
    border-radius: 0.5rem;
    padding: 20px;
    margin-bottom: 20px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item .item-name {
    color: #333;
    font-weight: 500;
}

.summary-item .item-price {
    color: #2563EB;
    font-weight: 600;
}

.summary-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
    font-size: 16px;
}

.order-total {
    text-align: right;
    font-size: 22px;
    color: #333;
    padding: 15px 0;
    border-top: 2px solid #2563EB;
    margin-top: 10px;
}

#order-total-amount {
    color: #0073aa;
    font-weight: bold;
}

/* Submit Section */
.shortcutform-submit {
    text-align: center;
    margin-top: 30px;
}

.shortcutform-btn-submit {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: white;
    border: none;
    padding: 18px 40px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    width: 100%;
    max-width: 400px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.shortcutform-btn-submit:hover {
    background: linear-gradient(135deg, #005a87 0%, #004a73 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 115, 170, 0.4);
}

.shortcutform-btn-submit:active {
    transform: translateY(0);
}

.shortcutform-btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.shortcutform-loading {
    text-align: center;
    color: #666;
    margin-top: 15px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.shortcutform-loading::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Messages */
#shortcutform-messages {
    margin-top: 20px;
}

.shortcutform-message {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shortcutform-message.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 2px solid #b8dabd;
}

.shortcutform-message.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px solid #f1b0b7;
}

.shortcutform-message.warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border: 2px solid #ffeaa7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .shortcutform-container {
        padding: 15px;
    }
    
    .shortcutform-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .shortcutform-products {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .shortcutform-product {
        padding: 15px;
    }
    
    .product-image {
        height: 150px;
    }
    
    .product-quantity {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .quantity-controls {
        align-self: stretch;
    }
    
    .shortcutform-title {
        font-size: 24px;
    }
    
    .shortcutform-section {
        padding: 20px 15px;
    }
    
    .shortcutform-btn-submit {
        padding: 15px 30px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .shortcutform-container {
        padding: 10px;
    }
    
    .shortcutform-section {
        padding: 15px 10px;
    }
    
    .shortcutform-product {
        padding: 12px;
    }
    
    .product-image {
        height: 120px;
    }
    
    .product-name {
        font-size: 16px;
    }
    
    .product-price {
        font-size: 18px;
    }
    
    .summary-item {
        font-size: 13px;
    }
    
    .order-total {
        font-size: 20px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .shortcutform-container {
        color: #e1e1e1;
    }
    
    .shortcutform-section {
        background: #2a2a2a;
        border-color: #404040;
    }
    
    .shortcutform-product {
        background: #333;
        border-color: #404040;
    }
    
    .shortcutform-field input,
    .shortcutform-field textarea {
        background: #333;
        border-color: #404040;
        color: #e1e1e1;
    }
    
    #order-summary {
        background: #333;
        border-color: #404040;
    }
    
    .product-image {
        background: #404040;
    }
    
    .no-image {
        background: linear-gradient(135deg, #404040 0%, #333 100%);
        color: #999;
    }
}

/* Print Styles */
@media print {
    .shortcutform-container {
        max-width: none;
        padding: 0;
    }
    
    .shortcutform-btn-submit,
    .quantity-controls {
        display: none;
    }
    
    .shortcutform-product {
        break-inside: avoid;
    }
}

/* Accessibility */
.shortcutform-container *:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.shortcutform-container button:focus,
.shortcutform-container input:focus,
.shortcutform-container textarea:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .shortcutform-product {
        border-width: 3px;
    }
    
    .shortcutform-btn-submit {
        border: 3px solid #000;
    }
    
    .quantity-controls {
        border-width: 3px;
    }
}

/* Payment Method Styling */
.payment-method-container {
    transition: all 0.2s ease;
}

.payment-method-container label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 60px; /* Ensure consistent height */
}

.payment-method-container .flex-1 {
    width: 70%;
    min-width: 0; /* Allow text to wrap properly */
}

.payment-method-image {
    width: 30%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.payment-method-container:hover {
    border-color: #3b82f6 !important;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.payment-method-container input[type="radio"]:checked + div {
    color: #1e40af;
}

.payment-method-container input[type="radio"]:checked ~ .payment-method-image img {
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.payment-method-image img {
    transition: var(--payment-image-transition);
    max-width: var(--payment-image-max-width);
    max-height: var(--payment-image-max-height);
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: var(--payment-image-border-radius);
    padding: var(--payment-image-padding);
    background: var(--payment-image-background);
}



/* Responsive adjustments for payment methods */
@media (max-width: 1024px) {
    .payment-method-container label {
        min-height: 56px;
    }
    
    .payment-method-container .flex-1 {
        width: 70%;
    }
    
    .payment-method-image {
        width: 30%;
        margin-left: 12px !important;
    }
}

@media (max-width: 640px) {
    .payment-method-container label {
        min-height: 52px;
    }
    
    .payment-method-container .flex-1 {
        width: 70%;
    }
    
    .payment-method-image {
        width: 30%;
        margin-left: 8px !important;
    }
}

@media (max-width: 480px) {
    .payment-method-container label {
        min-height: 48px;
    }
    
    .payment-method-container .flex-1 {
        width: 70%;
    }
    
    .payment-method-image {
        width: 30%;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .shortcutform-product,
    .shortcutform-btn-submit,
    .product-image img,
    .shortcutform-message,
    .payment-method-container,
    .payment-method-image img {
        transition: none;
        animation: none;
    }
    
    .shortcutform-product:hover {
        transform: none;
    }
    
    .shortcutform-btn-submit:hover {
        transform: none;
    }
    
    .payment-method-container:hover {
        transform: none;
    }
}

/* Utility Classes */
.rounded-lg {
    border-radius: 8px;
}