/* =========================================================
   AluminiumGlass - Forms
   File:
   /public_html/assets/css/forms.css

   Purpose:
   Global form controls for public website
   ========================================================= */


/* =========================================================
   1. FORM ROOT
   ========================================================= */

form {
    width: 100%;
    margin: 0;
    padding: 0;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    margin: 0;
    padding: 0;
}


/* =========================================================
   2. FORM GROUP
   ========================================================= */

.form-group {
    width: 100%;
    margin-bottom: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    width: 100%;
}

.form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    width: 100%;
}

.form-row-full {
    grid-column: 1 / -1;
}


/* =========================================================
   3. LABEL
   ========================================================= */

.form-label,
label {
    display: inline-block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary, #1f2937);
}

.form-label.required::after,
label.required::after {
    content: " *";
    color: var(--danger, #dc2626);
}


/* =========================================================
   4. INPUT BASE
   ========================================================= */

input,
select,
textarea {
    font-family: inherit;
    font-size: 15px;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
select,
textarea {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;

    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;

    background: var(--surface, #ffffff);
    color: var(--text-primary, #111827);

    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}


/* =========================================================
   5. PLACEHOLDER
   ========================================================= */

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-muted, #9ca3af);
    opacity: 1;
}


/* =========================================================
   6. FOCUS
   ========================================================= */

.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary, #2563eb);

    box-shadow:
        0 0 0 3px
        var(--primary-focus, rgba(37, 99, 235, 0.12));
}


/* =========================================================
   7. TEXTAREA
   ========================================================= */

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.55;
}

textarea.resize-none {
    resize: none;
}

textarea.resize-horizontal {
    resize: horizontal;

}

textarea.resize-both {
    resize: both;
}


/* =========================================================
   8. SELECT
   ========================================================= */

select {
    cursor: pointer;
    appearance: auto;
}

select:disabled {
    cursor: not-allowed;
}


/* =========================================================
   9. DISABLED
   ========================================================= */

.form-control:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    background: var(--surface-muted, #f3f4f6);
}


/* =========================================================
   10. READONLY
   ========================================================= */

.form-control[readonly],
input[readonly],
textarea[readonly] {
    background: var(--surface-muted, #f9fafb);
    cursor: default;
}


/* =========================================================
   11. FILE INPUT
   ========================================================= */

input[type="file"] {
    display: block;
    width: 100%;
    padding: 10px 12px;

    border: 1px dashed var(--border-color, #d1d5db);
    border-radius: 8px;

    background: var(--surface-muted, #f9fafb);
    color: var(--text-primary, #374151);

    cursor: pointer;
}

input[type="file"]:focus {
    outline: none;
    border-color: var(--primary, #2563eb);
}


/* =========================================================
   12. CHECKBOX
   ========================================================= */

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 12px;
}

.form-check input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin-top: 2px;

    accent-color: var(--primary, #2563eb);

    cursor: pointer;
}

.form-check label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}


/* =========================================================
   13. RADIO
   ========================================================= */

.form-radio {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 10px;
}

.form-radio input[type="radio"] {
    width: 17px;
    height: 17px;

    accent-color: var(--primary, #2563eb);

    cursor: pointer;
}

.form-radio label {
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}


/* =========================================================
   14. INLINE OPTIONS
   ========================================================= */

.form-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.form-options .form-check,
.form-options .form-radio {
    margin-bottom: 0;
}


/* =========================================================
   15. HELP TEXT
   ========================================================= */

.form-help,
.form-text {
    display: block;
    margin-top: 6px;

    font-size: 12px;
    line-height: 1.5;

    color: var(--text-muted, #6b7280);
}


/* =========================================================
   16. CHARACTER COUNTER
   ========================================================= */

.form-counter {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;

    font-size: 12px;
    color: var(--text-muted, #6b7280);
}


/* =========================================================
   17. VALIDATION - ERROR
   ========================================================= */

.form-group.has-error .form-control,
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea,
.form-control.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--danger, #dc2626);
}

.form-group.has-error .form-control:focus,
.form-control.is-invalid:focus,
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    border-color: var(--danger, #dc2626);

    box-shadow:
        0 0 0 3px
        rgba(220, 38, 38, 0.12);
}

.form-error,
.invalid-feedback {
    display: block;
    margin-top: 6px;

    font-size: 12px;
    line-height: 1.45;

    color: var(--danger, #dc2626);
}


/* =========================================================
   18. VALIDATION - SUCCESS
   ========================================================= */

.form-group.has-success .form-control,
.form-control.is-valid,
input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: var(--success, #16a34a);
}

.form-success,
.valid-feedback {
    display: block;
    margin-top: 6px;

    font-size: 12px;
    line-height: 1.45;

    color: var(--success, #16a34a);
}


/* =========================================================
   19. WARNING
   ========================================================= */

.form-group.has-warning .form-control,
.form-control.is-warning,
input.is-warning,
select.is-warning,
textarea.is-warning {
    border-color: var(--warning, #d97706);
}

.form-warning {
    display: block;
    margin-top: 6px;

    font-size: 12px;
    line-height: 1.45;

    color: var(--warning, #d97706);
}


/* =========================================================
   20. INPUT WITH ICON
   ========================================================= */

.input-wrapper {
    position: relative;
    width: 100%;
}

.input-wrapper .form-control {
    padding-right: 44px;
}

.input-icon {
    position: absolute;
    top: 50%;
    right: 14px;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 20px;
    height: 20px;

    transform: translateY(-50%);

    color: var(--text-muted, #6b7280);

    pointer-events: none;
}


/* =========================================================
   21. INPUT GROUP
   ========================================================= */

.input-group {
    display: flex;
    width: 100%;
}

.input-group > .form-control {
    flex: 1 1 auto;
}

.input-group .input-prefix,
.input-group .input-suffix {
    display: flex;
    align-items: center;

    padding: 0 13px;

    border: 1px solid var(--border-color, #d1d5db);

    background: var(--surface-muted, #f3f4f6);
    color: var(--text-secondary, #4b5563);

    white-space: nowrap;
}

.input-group .input-prefix {
    border-right: 0;
    border-radius: 8px 0 0 8px;
}

.input-group .input-suffix {
    border-left: 0;
    border-radius: 0 8px 8px 0;
}

.input-group .input-prefix + .form-control {
    border-radius: 0 8px 8px 0;
}

.input-group .form-control + .input-suffix {
    border-radius: 8px 0 0 8px;
}


/* =========================================================
   22. SEARCH FORM
   ========================================================= */

.form-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.form-search .form-control {
    flex: 1;
}

.form-search .btn {
    flex: 0 0 auto;
}


/* =========================================================
   23. SEARCH WITH LOCATION
   ========================================================= */

.search-form {
    display: grid;
    grid-template-columns:
        minmax(0, 1.5fr)
        minmax(180px, 0.8fr)
        auto;

    gap: 10px;
    width: 100%;
}

.search-form .search-keyword,
.search-form .search-location {
    position: relative;
}


/* =========================================================
   24. PASSWORD FIELD
   ========================================================= */

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;

    width: 36px;
    height: 36px;

    transform: translateY(-50%);

    border: 0;
    background: transparent;

    color: var(--text-muted, #6b7280);

    cursor: pointer;
}

.password-toggle:hover {
    color: var(--text-primary, #111827);
}


/* =========================================================
   25. PHONE FIELD
   ========================================================= */

.phone-group {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 8px;
}

.phone-code {
    text-align: center;
}


/* =========================================================
   26. FORM ACTIONS
   ========================================================= */

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;

    gap: 10px;

    margin-top: 24px;
}

.form-actions-left {
    justify-content: flex-start;
}

.form-actions-center {
    justify-content: center;
}

.form-actions-between {
    justify-content: space-between;
}


/* =========================================================
   27. FORM HEADER
   ========================================================= */

.form-header {
    margin-bottom: 22px;
}

.form-title {
    margin: 0 0 6px;

    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;

    color: var(--text-primary, #111827);
}

.form-description {
    margin: 0;

    font-size: 14px;
    line-height: 1.6;

    color: var(--text-secondary, #6b7280);
}


/* =========================================================
   28. FORM SECTION
   ========================================================= */

.form-section {
    padding: 22px 0;

    border-bottom: 1px solid
        var(--border-color, #e5e7eb);
}

.form-section:first-child {
    padding-top: 0;
}

.form-section:last-child {
    border-bottom: 0;
}

.form-section-title {
    margin: 0 0 16px;

    font-size: 17px;
    font-weight: 700;

    color: var(--text-primary, #111827);
}


/* =========================================================
   29. FORM CARD
   ========================================================= */

.form-card {
    width: 100%;
    padding: 24px;

    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;

    background: var(--surface, #ffffff);
}


/* =========================================================
   30. LOGIN / REGISTER FORM
   ========================================================= */

.auth-form {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.auth-form .form-group {
    margin-bottom: 16px;
}

.auth-form .form-actions {
    margin-top: 20px;
}


/* =========================================================
   31. ENQUIRY FORM
   ========================================================= */

.enquiry-form {
    width: 100%;
}

.enquiry-form .form-row {
    margin-bottom: 0;
}


/* =========================================================
   32. BUSINESS FORM
   ========================================================= */

.business-form {
    width: 100%;
}

.business-form .form-section {
    margin-bottom: 10px;
}


/* =========================================================
   33. FILTER FORM
   ========================================================= */

.filter-form {
    width: 100%;
}

.filter-form .form-row {
    grid-template-columns:
        repeat(auto-fit, minmax(180px, 1fr));
}

.filter-form .form-actions {
    margin-top: 15px;
}


/* =========================================================
   34. INLINE FORM
   ========================================================= */

.inline-form {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.inline-form .form-group {
    flex: 1 1 180px;
    margin-bottom: 0;
}

.inline-form .form-actions {
    margin-top: 0;
}


/* =========================================================
   35. AUTO COMPLETE
   ========================================================= */

.autocomplete {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    z-index: 1000;

    top: calc(100% + 4px);
    left: 0;
    right: 0;

    max-height: 280px;
    overflow-y: auto;

    margin: 0;
    padding: 5px 0;

    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 8px;

    background: var(--surface, #ffffff);

    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.10);

    list-style: none;
}

.autocomplete-item {
    padding: 10px 14px;

    font-size: 14px;

    cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--surface-hover, #f3f4f6);
}


/* =========================================================
   36. SELECTED TAGS
   ========================================================= */

.form-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;

    margin-top: 8px;
}

.form-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    padding: 5px 9px;

    border-radius: 999px;

    background: var(--primary-light, #eff6ff);
    color: var(--primary, #2563eb);

    font-size: 12px;
    font-weight: 600;
}

.form-tag-remove {
    border: 0;
    padding: 0;

    background: transparent;

    color: inherit;

    cursor: pointer;
}


/* =========================================================
   37. RANGE
   ========================================================= */

input[type="range"] {
    width: 100%;
    height: 6px;

    border-radius: 999px;

    accent-color: var(--primary, #2563eb);

    cursor: pointer;
}


/* =========================================================
   38. SWITCH
   ========================================================= */

.form-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.form-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.form-switch .switch {
    position: relative;

    width: 42px;
    height: 24px;

    border-radius: 999px;

    background: #d1d5db;

    cursor: pointer;

    transition: background-color 0.2s ease;
}

.form-switch .switch::after {
    content: "";

    position: absolute;

    top: 3px;
    left: 3px;

    width: 18px;
    height: 18px;

    border-radius: 50%;

    background: #ffffff;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);

    transition: transform 0.2s ease;
}

.form-switch input:checked + .switch {
    background: var(--primary, #2563eb);
}

.form-switch input:checked + .switch::after {
    transform: translateX(18px);
}


/* =========================================================
   39. REQUIRED / OPTIONAL
   ========================================================= */

.required-mark {
    color: var(--danger, #dc2626);
}

.optional-mark {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted, #6b7280);
}


/* =========================================================
   40. LOADING STATE
   ========================================================= */

.form-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.form-loading::after {
    content: "";

    position: absolute;

    top: 50%;
    left: 50%;

    width: 24px;
    height: 24px;

    margin: -12px;

    border: 3px solid
        var(--border-color, #d1d5db);

    border-top-color:
        var(--primary, #2563eb);

    border-radius: 50%;

    animation: formSpinner 0.7s linear infinite;
}

@keyframes formSpinner {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   41. CAPTCHA / VERIFICATION
   ========================================================= */

.form-verification {
    display: flex;
    align-items: center;
    gap: 12px;

    margin: 16px 0;
}

.form-verification input {
    flex: 1;
}


/* =========================================================
   42. FORM NOTICE
   ========================================================= */

.form-notice {
    padding: 12px 14px;

    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;

    background: var(--surface-muted, #f9fafb);

    font-size: 13px;
    line-height: 1.55;

    color: var(--text-secondary, #4b5563);
}


/* =========================================================
   43. TERMS CHECKBOX
   ========================================================= */

.terms-check {
    display: flex;
    align-items: flex-start;
    gap: 9px;

    margin: 16px 0;

    font-size: 13px;
    line-height: 1.5;
}

.terms-check input {
    flex: 0 0 auto;
    margin-top: 3px;
}

.terms-check a {
    color: var(--primary, #2563eb);
    text-decoration: none;
}

.terms-check a:hover {
    text-decoration: underline;
}


/* =========================================================
   44. MOBILE
   ========================================================= */

@media (max-width: 768px) {

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-row-full {
        grid-column: auto;
    }

    .search-form {
        grid-template-columns: 1fr;
    }

    .phone-group {
        grid-template-columns: 85px minmax(0, 1fr);
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .btn {
        flex: 1 1 auto;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form .form-group {
        width: 100%;
    }

    .form-card {
        padding: 18px;
    }
}


/* =========================================================
   45. SMALL MOBILE
   ========================================================= */

@media (max-width: 480px) {

    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    select,
    textarea {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 14px;
    }

    .form-title {
        font-size: 20px;
    }

    .form-card {
        padding: 15px;
        border-radius: 10px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}


/* =========================================================
   END OF FORMS.CSS
   ========================================================= */