/**
 * Product Fields Styles - Modern Green Theme (استعد)
 *
 * Custom fields on product page with beautiful modern design
 *
 * @package Malazem_Center_Smart
 */

/* CSS Variables for easy customization */
:root {
    --malazem-primary: #00875A;
    --malazem-primary-light: #00A86B;
    --malazem-primary-dark: #006644;
    --malazem-secondary: #e8f5e9;
    --malazem-accent: #b9f6ca;
    --malazem-text: #1a1a1a;
    --malazem-text-light: #666666;
    --malazem-border: #c8e6c9;
    --malazem-white: #ffffff;
    --malazem-shadow: rgba(0, 135, 90, 0.1);
    --malazem-shadow-hover: rgba(0, 135, 90, 0.2);
}

/* RTL Support */
html[dir="rtl"] .malazem-product-fields,
body.rtl .malazem-product-fields {
    direction: rtl;
    text-align: right;
}

/* Main Container */
.malazem-product-fields {
    margin: 25px 0;
    padding: 0;
    background: linear-gradient(135deg, var(--malazem-white) 0%, var(--malazem-secondary) 100%);
    border: 2px solid var(--malazem-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px var(--malazem-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.malazem-product-fields:hover {
    box-shadow: 0 8px 30px var(--malazem-shadow-hover);
    transform: translateY(-2px);
}

.malazem-product-fields.hidden {
    display: none;
}

.malazem-product-fields.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Header Section */
.malazem-fields-header {
    background: linear-gradient(135deg, var(--malazem-primary) 0%, var(--malazem-primary-light) 100%);
    padding: 20px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.malazem-fields-header-icon {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.malazem-fields-header-icon svg {
    width: 28px;
    height: 28px;
    fill: var(--malazem-white);
}

.malazem-fields-header-content {
    flex: 1;
}

.malazem-fields-header-title {
    margin: 0 0 4px 0;
    color: var(--malazem-white);
    font-size: 18px;
    font-weight: 700;
}

.malazem-fields-header-subtitle {
    margin: 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-weight: 400;
}

/* Notice (Legacy Support) */
.malazem-fields-notice {
    background: linear-gradient(135deg, var(--malazem-primary) 0%, var(--malazem-primary-light) 100%);
    border: none;
    border-radius: 0;
    padding: 20px 25px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.malazem-fields-notice::before {
    content: "";
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 28px;
}

.malazem-fields-notice p {
    margin: 0;
    color: var(--malazem-white);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
}

/* Fields Container */
.malazem-fields-body {
    padding: 25px;
}

/* Fields Row Layout - Display 3 fields in one row */
.malazem-fields-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.malazem-fields-row .malazem-field-group {
    margin-bottom: 0;
}

/* 2 columns layout option */
.malazem-fields-row.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Single column layout option */
.malazem-fields-row.columns-1 {
    grid-template-columns: 1fr;
}

/* Custom Notes */
.malazem-pf-note {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border-right: 4px solid;
    animation: fadeInUp 0.4s ease;
}

.malazem-pf-note-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.malazem-pf-note-content {
    flex: 1;
}

.malazem-pf-note-title {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--malazem-text);
}

.malazem-pf-note-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--malazem-text);
}

.malazem-pf-note-text a {
    color: var(--malazem-primary);
    text-decoration: underline;
}

/* Field Groups */
.malazem-field-group {
    margin-bottom: 22px;
    position: relative;
}

.malazem-field-group:last-child {
    margin-bottom: 0;
}

.malazem-field-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--malazem-text);
    font-size: 15px;
}

.malazem-field-group .required {
    color: #dc3545;
    font-weight: 700;
    font-size: 16px;
}

.malazem-field-group .optional {
    font-weight: 400;
    color: var(--malazem-text-light);
    font-size: 13px;
    background: var(--malazem-secondary);
    padding: 3px 10px;
    border-radius: 20px;
}

/* Field Icons */
.malazem-field-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--malazem-secondary);
    border-radius: 6px;
    color: var(--malazem-primary);
}

.malazem-field-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Inputs */
.malazem-field-group input[type="text"] {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--malazem-border);
    border-radius: 12px;
    font-size: 15px;
    color: var(--malazem-text);
    background: var(--malazem-white);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.malazem-field-group input[type="text"]:hover {
    border-color: var(--malazem-primary-light);
}

.malazem-field-group input[type="text"]:focus {
    border-color: var(--malazem-primary);
    outline: none;
    box-shadow: 0 0 0 4px var(--malazem-shadow);
    background: var(--malazem-white);
}

.malazem-field-group input[type="text"]::placeholder {
    color: #adb5bd;
    font-weight: 400;
}

/* Validation States */
.malazem-field-group input[type="text"]:valid:not(:placeholder-shown) {
    border-color: var(--malazem-primary);
    background: linear-gradient(to left, var(--malazem-white), rgba(232, 245, 233, 0.3));
}

.malazem-field-group input[type="text"]:valid:not(:placeholder-shown) + .malazem-field-check {
    opacity: 1;
}

.malazem-field-check {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--malazem-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

html[dir="rtl"] .malazem-field-check,
body.rtl .malazem-field-check {
    left: auto;
    right: 15px;
}

.malazem-field-check svg {
    width: 12px;
    height: 12px;
    fill: var(--malazem-white);
}

/* Error State */
.malazem-field-group.error input[type="text"] {
    border-color: #dc3545;
    background: #fff5f5;
    animation: shake 0.5s ease;
}

.malazem-field-group .error-message {
    display: none;
    margin-top: 8px;
    padding: 10px 14px;
    background: #fff5f5;
    border-radius: 8px;
    color: #dc3545;
    font-size: 13px;
    border-right: 3px solid #dc3545;
}

html[dir="ltr"] .malazem-field-group .error-message {
    border-right: none;
    border-left: 3px solid #dc3545;
}

.malazem-field-group.error .error-message {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* Field Error Message (Name Fraud Detection) */
.malazem-field-error {
    display: block;
    margin-top: 8px;
    padding: 10px 14px;
    background: linear-gradient(to right, #fff5f5, #ffebee);
    border-radius: 8px;
    color: #c62828;
    font-size: 13px;
    font-weight: 500;
    border-right: 3px solid #dc3545;
    animation: fadeInUp 0.3s ease;
}

html[dir="ltr"] .malazem-field-error {
    border-right: none;
    border-left: 3px solid #dc3545;
}

.malazem-field-error::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23dc3545'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

html[dir="ltr"] .malazem-field-error::before {
    margin-left: 0;
    margin-right: 8px;
}

/* Help Text */
.malazem-field-group .help-text {
    margin-top: 8px;
    color: var(--malazem-text-light);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.malazem-field-group .help-text::before {
    content: "";
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2300875A'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
    background-size: contain;
    flex-shrink: 0;
}

/* Footer Actions */
.malazem-fields-footer {
    padding: 20px 25px;
    background: var(--malazem-secondary);
    border-top: 1px solid var(--malazem-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.malazem-fields-footer-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--malazem-text-light);
    font-size: 13px;
}

.malazem-fields-footer-info svg {
    width: 18px;
    height: 18px;
    fill: var(--malazem-primary);
}

/* Loading State */
.malazem-product-fields.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid var(--malazem-border);
    border-top-color: var(--malazem-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Animations */
@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Responsive */
@media (max-width: 992px) {
    /* Tablet: 2 columns */
    .malazem-fields-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .malazem-product-fields {
        margin: 20px 0;
        border-radius: 12px;
    }

    .malazem-fields-notice,
    .malazem-fields-header {
        padding: 18px 20px;
        flex-direction: column;
        text-align: center;
    }

    .malazem-fields-notice::before,
    .malazem-fields-header-icon {
        margin-bottom: 10px;
    }

    .malazem-fields-body {
        padding: 20px;
    }

    .malazem-field-group input[type="text"] {
        padding: 12px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .malazem-pf-note {
        padding: 14px 16px;
        flex-direction: column;
        text-align: center;
    }

    .malazem-fields-footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    /* Mobile: Single column */
    .malazem-fields-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .malazem-fields-notice,
    .malazem-fields-header {
        padding: 15px;
    }

    .malazem-fields-body {
        padding: 15px;
    }

    .malazem-field-group label {
        flex-wrap: wrap;
    }
}

/* WooCommerce Integration */
.woocommerce-cart .malazem-cart-item-meta {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--malazem-border);
}

.woocommerce-cart .malazem-cart-item-meta dt {
    font-weight: 600;
    color: var(--malazem-primary);
    font-size: 13px;
}

.woocommerce-cart .malazem-cart-item-meta dd {
    color: var(--malazem-text);
    margin: 0 0 8px;
    padding-right: 15px;
}

/* Dark Mode Support (if theme supports) */
@media (prefers-color-scheme: dark) {
    .malazem-product-fields {
        /* Add dark mode styles if needed */
    }
}
