/* ========================================
   FORM-SPECIFIC RESPONSIVE ENHANCEMENTS
   For Mware.Stocka Application
   ======================================== */

/* ===== FORM CONTAINER BASE ===== */
.form-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.06);
}

/* ===== FORM GRID LAYOUTS ===== */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.form-row-thirds {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

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

/* ===== FORM ACTIONS ===== */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* ===== PASSWORD WRAPPER ===== */
.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    user-select: none;
    z-index: 10;
}

/* ===== FILE INPUT ENHANCEMENTS ===== */
.file-input-wrapper {
    position: relative;
}

.file-input-label {
    display: inline-block;
    padding: 10px 16px;
    background: linear-gradient(135deg, #00A884, #0F766E);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 600;
}

.file-input-label:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.3);
}

input[type="file"] {
    position: absolute;
    left: -9999px;
}

/* ===== SELECT ENHANCEMENTS ===== */
select.form-input,
.material-select {
    appearance: none;
    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='%23374151' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ===== TEXTAREA ENHANCEMENTS ===== */
textarea.form-input {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

/* ===== CHECKBOX & RADIO ENHANCEMENTS ===== */
.checkbox-wrapper,
.radio-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-wrapper input[type="checkbox"],
.radio-wrapper input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-wrapper label,
.radio-wrapper label {
    margin: 0;
    cursor: pointer;
    font-weight: 400;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Large Tablets & Small Desktops (< 992px) */
@media (max-width: 992px) {
    .form-container {
        max-width: 100%;
    }

    .form-row-thirds {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablets (< 768px) */
@media (max-width: 768px) {
    .form-container {
        padding: 20px 16px;
        border-radius: 8px;
    }

    .form-row,
    .form-row-thirds {
        grid-template-columns: 1fr;
        gap: 14px;
    }

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

    .form-group label {
        font-size: 14px;
        margin-bottom: 6px;
        font-weight: 600;
    }

    .form-input,
    .material-select {
        padding: 14px 16px;
        font-size: 15px;
        border-radius: 8px;
    }

    textarea.form-input {
        min-height: 120px;
        font-size: 15px;
        line-height: 1.5;
    }

    select.form-input,
    .material-select {
        padding-right: 40px;
        background-size: 14px;
        background-position: right 14px center;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .form-actions .btn {
        width: 100%;
        padding: 14px;
        font-size: 15px;
    }

    .password-wrapper .toggle-password {
        right: 14px;
        font-size: 20px;
    }

    .file-input-label {
        width: 100%;
        text-align: center;
        padding: 14px 16px;
        font-size: 15px;
    }

    .checkbox-wrapper,
    .radio-wrapper {
        padding: 10px 0;
    }

    .checkbox-wrapper input[type="checkbox"],
    .radio-wrapper input[type="radio"] {
        width: 20px;
        height: 20px;
    }

    .checkbox-wrapper label,
    .radio-wrapper label {
        font-size: 14px;
    }
}

/* Mobile (< 480px) */
@media (max-width: 480px) {
    .form-container {
        padding: 16px 12px;
        border-radius: 8px;
    }

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

    .form-group label {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .form-input,
    .material-select {
        padding: 16px 18px;
        font-size: 16px;
        /* Prevents iOS zoom on input focus */
    }

    textarea.form-input {
        min-height: 140px;
        font-size: 16px;
    }

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

    .form-actions .btn {
        padding: 16px;
        font-size: 16px;
        font-weight: 600;
    }

    .error-message,
    .field-validation-error {
        font-size: 13px;
        margin-top: 4px;
    }
}

/* ===== FORM VALIDATION STYLING ===== */
.form-input.is-invalid,
.input-validation-error {
    border-color: #dc2626;
    background-color: #fef2f2;
}

.form-input.is-valid {
    border-color: #10b981;
    background-color: #f0fdf4;
}

/* ===== LOADING STATE ===== */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

/* ===== RESPONSIVE HELPERS FOR FORMS ===== */
@media (max-width: 768px) {
    .mobile-stack {
        flex-direction: column;
    }

    .mobile-full-width {
        width: 100% !important;
    }

    .mobile-text-center {
        text-align: center;
    }
}

/* ===== BETTER TOUCH TARGETS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .form-input,
    .material-select,
    .btn {
        min-height: 44px;
    }

    .checkbox-wrapper input[type="checkbox"],
    .radio-wrapper input[type="radio"] {
        min-width: 22px;
        min-height: 22px;
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .form-container {
        padding: 16px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    textarea.form-input {
        min-height: 80px;
    }
}

/* ===== ACCESSIBILITY ===== */
.form-input:focus,
.material-select:focus {
    outline: none;
    border-color: #00A884;
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.1);
}

@media (prefers-reduced-motion: reduce) {
    .form-input,
    .btn,
    .toggle-password {
        transition: none;
    }
}

/* ===== DARK MODE SUPPORT (Optional) ===== */
@media (prefers-color-scheme: dark) {
    /* Can be implemented if needed */
}

/* ===== MULTI-COLUMN FORMS ON DESKTOP ===== */
@media (min-width: 1200px) {
    .form-container.wide {
        max-width: 1000px;
    }

    .form-row-auto {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 16px;
    }
}

/* ===== INLINE FORMS ===== */
.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

@media (max-width: 768px) {
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline .form-group {
        margin-bottom: 0;
    }

    .form-inline .btn {
        margin-top: 12px;
    }
}

/* ===== STEP FORMS / WIZARDS ===== */
.form-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    counter-reset: step;
}

.form-step {
    flex: 1;
    text-align: center;
    position: relative;
    counter-increment: step;
}

.form-step::before {
    content: counter(step);
    display: block;
    width: 36px;
    height: 36px;
    line-height: 36px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    margin: 0 auto 8px;
    font-weight: 600;
}

.form-step.active::before {
    background: linear-gradient(135deg, #00A884, #0F766E);
    color: white;
}

.form-step.completed::before {
    background: #10b981;
    color: white;
    content: '✓';
}

@media (max-width: 768px) {
    .form-steps {
        font-size: 12px;
    }

    .form-step::before {
        width: 32px;
        height: 32px;
        line-height: 32px;
        font-size: 14px;
    }
}
