/**
 * Form Component Styles
 * Styles for all form-related elements across the application
 */

/* Base Form Styles */
.form-group, .form-floating, .mb-3 {
    margin-bottom: 1rem;
}

.form-label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #444;
}

.form-text {
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #6c757d;
}

/* Form Controls */
.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    appearance: none;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: #212529;
    background-color: #fff;
    border-color: #3D7A67;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(61, 122, 103, 0.25);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: #e9ecef;
    opacity: 1;
}

.form-control::placeholder {
    color: #6c757d;
    opacity: 1;
}

/* Form Select */
.form-select {
    display: block;
    width: 100%;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    appearance: none;
}

.form-select:focus {
    border-color: #3D7A67;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(61, 122, 103, 0.25);
}

.form-select:disabled {
    background-color: #e9ecef;
}

/* Form Check */
.form-check {
    display: block;
    min-height: 1.5rem;
    padding-left: 1.5em;
    margin-bottom: 0.125rem;
}

.form-check-input {
    width: 1em;
    height: 1em;
    margin-top: 0.25em;
    vertical-align: top;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border: 1px solid rgba(0, 0, 0, 0.25);
    appearance: none;
}

.form-check-input[type="checkbox"] {
    border-radius: 0.25em;
}

.form-check-input[type="radio"] {
    border-radius: 50%;
}

.form-check-input:checked {
    background-color: #3D7A67;
    border-color: #3D7A67;
}

.form-check-input:checked[type="checkbox"] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}

.form-check-input:checked[type="radio"] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
}

.form-check-input:focus {
    border-color: #3D7A67;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(61, 122, 103, 0.25);
}

.form-check-label {
    color: #212529;
}

/* Form Switch */
.form-switch {
    padding-left: 2.5em;
}

.form-switch .form-check-input {
    width: 2em;
    margin-left: -2.5em;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");
    background-position: left center;
    border-radius: 2em;
    transition: background-position 0.15s ease-in-out;
}

.form-switch .form-check-input:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%233D7A67'/%3e%3c/svg%3e");
}

.form-switch .form-check-input:checked {
    background-position: right center;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* Form Range */
.form-range {
    width: 100%;
    height: 1.5rem;
    padding: 0;
    background-color: transparent;
    appearance: none;
}

.form-range:focus {
    outline: 0;
}

.form-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 1px #fff, 0 0 0 0.25rem rgba(61, 122, 103, 0.25);
}

.form-range::-webkit-slider-thumb {
    width: 1rem;
    height: 1rem;
    margin-top: -0.25rem;
    background-color: #3D7A67;
    border: 0;
    border-radius: 1rem;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    appearance: none;
}

.form-range::-webkit-slider-runnable-track {
    width: 100%;
    height: 0.5rem;
    color: transparent;
    cursor: pointer;
    background-color: #dee2e6;
    border-color: transparent;
    border-radius: 1rem;
}

/* Form Floating */
.form-floating {
    position: relative;
}

.form-floating > .form-control,
.form-floating > .form-select {
    height: calc(3.5rem + 2px);
    line-height: 1.25;
    padding: 1rem 0.75rem;
}

.form-floating > label {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1rem 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid transparent;
    transform-origin: 0 0;
    transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
}

.form-floating > .form-control:focus,
.form-floating > .form-control:not(:placeholder-shown),
.form-floating > .form-select {
    padding-top: 1.625rem;
    padding-bottom: 0.625rem;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label {
    opacity: 0.65;
    transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Form Validation */
.was-validated .form-control:valid, .form-control.is-valid {
    border-color: #198754;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:invalid, .form-control.is-invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
}

.was-validated :invalid ~ .invalid-feedback,
.is-invalid ~ .invalid-feedback {
    display: block;
}

.valid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #198754;
}

.was-validated :valid ~ .valid-feedback,
.is-valid ~ .valid-feedback {
    display: block;
}

/* Input Group */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group > .form-control,
.input-group > .form-select {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-align: center;
    white-space: nowrap;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

.input-group > :not(:first-child):not(:last-child):not(.dropdown-toggle) {
    border-radius: 0;
}

.input-group > :first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > :last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Custom File Input */
.form-file {
    position: relative;
}

.form-file-input {
    position: relative;
    z-index: 2;
    width: 100%;
    height: calc(1.5em + 0.75rem + 2px);
    margin: 0;
    opacity: 0;
}

.form-file-label {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1;
    display: flex;
    height: calc(1.5em + 0.75rem + 2px);
    border-color: #ced4da;
    border-radius: 0.375rem;
}

.form-file-text {
    display: flex;
    align-items: center;
    flex-grow: 1;
    padding: 0.375rem 0.75rem;
    overflow: hidden;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-overflow: ellipsis;
    white-space: nowrap;
    background-color: #fff;
    border-left: inherit;
}

.form-file-button {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    margin-left: -1px;
    line-height: 1.5;
    color: #212529;
    background-color: #e9ecef;
    border-left: inherit;
    border-radius: 0 0.375rem 0.375rem 0;
}

/* Quantity Controls */
.quantity-control {
    display: flex;
    align-items: center;
    background-color: #fff;
    border-radius: 6px;
    border: 1px solid #ddd;
    overflow: hidden;
    width: fit-content;
}

.quantity-btn {
    background: none;
    border: none;
    color: #555;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    padding: 0;
}

.quantity-btn:hover {
    background-color: #f1f1f1;
}

.quantity-input {
    width: 40px;
    height: 32px;
    text-align: center;
    border: none;
    -moz-appearance: textfield;
    appearance: textfield;
    margin: 0;
    padding: 0 5px;
    font-size: 0.9rem;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quantity-form {
    display: inline-flex;
    margin: 0;
}

/* Category Checkboxes */
.category-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.category-checkboxes label {
    display: flex;
    align-items: center;
    padding: 8px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.category-checkboxes label:hover {
    background-color: #f0f0f0;
}

.category-checkboxes input[type="checkbox"] {
    margin-right: 8px;
}

/* Payment Option Forms */
.payment-option {
    margin-top: 0.3rem;
}

.form-check.border {
    padding: 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.form-check.border:hover {
    background-color: #f8f9fa;
    cursor: pointer;
}

.form-check.border.selected {
    border-color: #3D7A67 !important;
    background-color: rgba(61, 122, 103, 0.05);
}

/* Search Form */
.search-box {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

.search-input {
    padding-left: 40px;
    height: 50px;
    border-radius: 25px;
}

/* Price Range Form */
.price-range-form {
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.price-slider {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.price-inputs {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.price-inputs .form-control {
    text-align: center;
}

.price-inputs .separator {
    color: #6c757d;
}

.price-error {
    color: #dc3545;
    font-size: 0.875em;
    margin-top: 0.25rem;
    display: block;
}

/* Filter Form */
.filter-form {
    margin-bottom: 1.5rem;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}

.filter-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.filter-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.filter-section-title {
    font-weight: 600;
    margin-bottom: 1rem;
    color: #343a40;
}

/* Sort Form */
.sort-form {
    display: flex;
    align-items: center;
}

.sort-form label {
    margin-right: 0.5rem;
    margin-bottom: 0;
    white-space: nowrap;
}

.sort-form .form-select {
    width: auto;
    min-width: 200px;
}

/* Login & Registration Forms */
.auth-form {
    max-width: 450px;
    margin: 0 auto;
    padding: 2rem;
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

.auth-form .form-control {
    padding: 0.75rem 1rem;
}

.auth-form .btn-primary {
    padding: 0.75rem 1rem;
    font-weight: 500;
}

.auth-form-title {
    text-align: center;
    margin-bottom: 2rem;
    color: #343a40;
}

.auth-form-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: #6c757d;
}

.auth-form-footer a {
    color: #3D7A67;
    text-decoration: none;
}

.auth-form-footer a:hover {
    text-decoration: underline;
}

/* Profile Form Styles */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.save-btn {
    min-width: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Contact Form Styles */
.contact-form .form-control {
    border-radius: 0;
    background-color: rgba(255, 255, 255, 0.1);
    color: black;
    border-color: rgba(255, 255, 255, 0.5);
}

.contact-form .form-control:focus {
    box-shadow: 0 0 0 0.25rem rgba(61, 122, 103, 0.25);
    background-color: rgba(255, 255, 255, 0.2);
}

.contact-form label {
    color: #495057;
}

.contact-form textarea {
    min-height: 150px;
}

.contact-form .btn-submit {
    background-color: #3D7A67;
    border-color: #3D7A67;
    color: white;
    padding: 0.625rem 2.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.contact-form .btn-submit:hover {
    background-color: #2c5a4c;
    border-color: #2c5a4c;
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Checkout Form */
.checkout-form {
    background-color: #fff;
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.checkout-form .section-title {
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e9ecef;
    color: #343a40;
}

.checkout-form .form-check {
    margin-bottom: 1rem;
}

.checkout-form .form-check-label {
    cursor: pointer;
}

.checkout-form .same-address-check {
    margin-top: 1rem;
    margin-bottom: 2rem;
}

.checkout-form .btn-place-order {
    background-color: #3D7A67;
    border-color: #3D7A67;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.checkout-form .btn-place-order:hover {
    background-color: #2c5a4c;
    border-color: #2c5a4c;
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Admin Form Styles */
.admin-form {
    background-color: #fff;
    border-radius: 0.5rem;
    padding: 2rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.admin-form .form-group {
    margin-bottom: 1.5rem;
}

.admin-form .btn-submit {
    background-color: #4e73df;
    border-color: #4e73df;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.admin-form .btn-submit:hover {
    background-color: #2e59d9;
    border-color: #2653d4;
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(78, 115, 223, 0.15);
}

.admin-form .btn-cancel {
    color: #858796;
    border-color: #858796;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.admin-form .btn-cancel:hover {
    background-color: #858796;
    color: #fff;
}

/* Image Upload Preview */
.image-preview-container {
    background-color: #f8f9fc;
    border-radius: 5px;
    padding: 10px;
    border: 1px dashed #d1d3e2;
    position: relative;
    margin-bottom: 1rem;
    text-align: center;
}

.image-preview {
    max-height: 200px;
    max-width: 100%;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.current-image-container {
    margin-bottom: 1rem;
}

.current-image-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #444;
}

.current-image {
    max-height: 100px;
    border: 1px solid #e3e6f0;
    border-radius: 0.25rem;
}

/* Responsive Form Adjustments */
@media (max-width: 576px) {
    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-control, .form-select, .input-group-text {
        font-size: 0.95rem;
        padding: 0.3rem 0.6rem;
    }

    .form-label {
        font-size: 0.95rem;
    }

    .form-text {
        font-size: 0.825em;
    }

    .auth-form {
        padding: 1.5rem;
    }

    .checkout-form {
        padding: 1.5rem;
    }

    .admin-form {
        padding: 1.5rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .save-btn {
        width: 100%;
        min-width: auto;
    }

    .quantity-control {
        width: 100%;
    }

    .price-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }

    .price-inputs .separator {
        display: none;
    }

    .sort-form {
        flex-direction: column;
        align-items: flex-start;
    }

    .sort-form label {
        margin-bottom: 0.5rem;
    }

    .sort-form .form-select {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .checkout-form .btn-place-order {
        width: 100%;
    }

    .admin-form .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }

    .admin-form .btn-submit,
    .admin-form .btn-cancel {
        width: 100%;
    }

    .category-checkboxes {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}