/**
 * Custom Form Styles - Single Page Form
 */

/* Hide duplicate page title if present */
.page-title-wrapper .page-title .base:last-of-type {
    display: none;
}

.customform-wrapper {
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
    background: #fff;
}

.customform-wrapper .page-title-wrapper {
    margin-bottom: 25px;
}

.customform-wrapper .page-title {
    font-size: 32px;
    font-weight: 600;
    color: #000;
    margin-bottom: 10px;
}

.form-description {
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.6;
}

/* Fieldsets */
.fieldset {
    margin-bottom: 40px;
    padding: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.fieldset .legend {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 25px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f6bf1c;
    width: 100%;
    color: #000;
}

.field {
    margin-bottom: 25px;
}

/* Address group - make address fields closer together */
.address-group {
    margin-bottom: 25px;
}

.address-group .field {
    margin-bottom: 10px;
}

.address-group .field:last-child {
    margin-bottom: 25px;
}

.field .label {
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
    font-size: 15px;
    color: #333;
    line-height: 1.4;
}

.field .label span {
    display: inline-block;
}

.field.required .label::after {
    content: ' *';
    color: #e02b27;
}

.field .control {
    width: 100%;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="url"],
.field textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    box-sizing: border-box;
    line-height: 1.5;
    transition: border-color 0.3s ease;
}

.field select {
    width: 100%;
    padding: 12px 15px;
    padding-right: 40px; /* Extra padding for dropdown arrow */
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    box-sizing: border-box;
    line-height: 1.5;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.3s ease;
    min-height: 45px; /* Ensure consistent height */
}

.field select option {
    padding: 12px 15px;
    font-size: 15px;
    line-height: 1.6;
    white-space: normal;
    word-wrap: break-word;
    min-height: 40px;
}

.field input[type="text"]:focus,
.field input[type="email"]:focus,
.field input[type="tel"]:focus,
.field input[type="url"]:focus,
.field select:focus,
.field textarea:focus {
    border-color: #1979c3;
    outline: none;
    box-shadow: 0 0 5px rgba(25, 121, 195, 0.3);
}

.field select:hover {
    border-color: #999;
}

.field select:active,
.field select:focus {
    border-color: #1979c3;
    box-shadow: 0 0 5px rgba(25, 121, 195, 0.3);
}

.field textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

/* Better spacing for form rows */
.field + .field {
    margin-top: 0;
}

/* Ensure select dropdowns are wide enough */
.field select.select {
    width: 100% !important;
    max-width: 100%;
}

/* Fix for Magento's select wrapper if present */
.field .control select {
    width: 100% !important;
    max-width: 100%;
}

/* Checkbox Groups */
.checkbox-group {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-group label {
    font-weight: normal;
    cursor: pointer;
    margin: 0;
}

/* Form Actions */
.form-actions {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
    text-align: center;
}

.form-actions button {
    padding: 18px 60px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 250px;
    letter-spacing: 0.5px;
}

.form-actions .action.primary {
    background: #c1272d;
    color: #fff;
    border: none;
    box-shadow: 0 2px 4px rgba(193, 39, 45, 0.3);
}

.form-actions .action.primary:hover {
    background: #a01f24;
    box-shadow: 0 4px 8px rgba(193, 39, 45, 0.4);
}

.form-actions .action.primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(193, 39, 45, 0.3);
}

.form-actions .action.primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

/* Messages */
.form-messages {
    margin: 20px 0;
}

.form-messages .message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* Removed duplicate - see below for consolidated version */

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

/* Validation Messages */
.field._error input,
.field._error select,
.field._error textarea {
    border-color: #e02b27;
}

.field .mage-error,
.field .mage-error-text {
    color: #e02b27;
    font-size: 12px;
    margin-top: 5px;
    display: block;
    padding-left: 0 !important; /* Remove any left padding that might show duplicate icons */
    position: relative;
}

/* Hide Magento's default error icons */
.field .mage-error::before,
.field .mage-error::after,
.field .mage-error-text::before,
.field .mage-error-text::after {
    display: none !important;
    content: none !important;
}

/* Highlight fields with errors */
.field._error input,
.field._error select,
.field._error textarea {
    border-color: #e02b27 !important;
    box-shadow: 0 0 3px rgba(224, 43, 39, 0.3);
    color: #333 !important; /* Keep text color normal, not red */
}

.field._error {
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Form Description */
.form-description {
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.7;
    color: #666;
    padding: 15px;
    background: #f8f9fa;
    border-left: 4px solid #f6bf1c;
    border-radius: 4px;
}

/* Better message styling */
.form-messages {
    margin: 20px 0 30px 0;
}

.form-messages .message {
    padding: 18px 20px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 15px;
    line-height: 1.6;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-messages .message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 18px 20px 18px 50px; /* Consistent padding with icon space */
    position: relative;
}

.form-messages .message-success::before {
    content: "✓";
    font-size: 20px;
    font-weight: bold;
    color: #28a745;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    line-height: 1;
    z-index: 1;
}

/* Hide any duplicate checkmarks, icons, or pseudo-elements from nested elements */
.form-messages .message-success *::before,
.form-messages .message-success *::after {
    display: none !important;
    content: none !important;
}

/* Ensure nested divs don't create their own icons */
.form-messages .message-success .success::before,
.form-messages .message-success .success::after,
.form-messages .message-success .message::before,
.form-messages .message-success .message::after,
.form-messages .message-success div::before,
.form-messages .message-success div::after {
    display: none !important;
    content: none !important;
}

.form-messages .message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    position: relative;
    padding: 18px 20px 18px 50px; /* Consistent padding with icon space */
}

.form-messages .message-error::before {
    content: "✗";
    font-size: 20px;
    font-weight: bold;
    color: #dc3545;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    line-height: 1;
}

/* Hide Magento's default error icons and duplicate content */
.form-messages .message-error .mage-error,
.form-messages .message-error .error {
    display: none !important;
}

/* Remove any pseudo-elements that might create duplicate icons */
.form-messages .message-error *::before,
.form-messages .message-error *::after {
    display: none !important;
    content: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .customform-wrapper {
        padding: 15px 10px;
    }

    .customform-wrapper .page-title {
        font-size: 26px;
    }

    .fieldset {
        padding: 20px 15px;
    }

    .fieldset .legend {
        font-size: 18px;
    }

    .field input[type="text"],
    .field input[type="email"],
    .field input[type="tel"],
    .field input[type="url"],
    .field select,
    .field textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
    }

    .form-actions button {
        width: 100%;
        min-width: auto;
        padding: 15px 30px;
    }
}

/* Print styles */
@media print {
    .form-actions,
    .form-messages {
        display: none;
    }
}
