/* Forms - Modern Professional Accessible Design */

/* ========================================
   FORM LAYOUTS
   ======================================== */

/* Fieldset Reset */
fieldset {
    margin: 0;
    padding: 0;
    border: none;
    min-width: 0;
}

/* Horizontal Form */
.form-horizontal {
    margin: 0;
}

.form-horizontal .control-group {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}

.form-horizontal .control-label {
    flex: 0 0 200px;
    padding-top: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.form-horizontal .controls {
    flex: 1;
}

/* Stacked Form */
.form-stacked .control-group {
    margin-bottom: 20px;
}

.form-stacked .control-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.form-stacked .controls {
    display: block;
}

/* Inline Form */
.form-inline {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.form-inline .control-group {
    margin-bottom: 0;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.form-inline .control-label {
    margin-bottom: 0;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

/* ========================================
   FORM ELEMENTS BASE
   ======================================== */

/* Base input, select, textarea styles */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: metropolisregular, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    box-sizing: border-box;
}

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,
select:focus,
textarea:focus {
    outline: none;
    border-color: #67a552;
    box-shadow: 0 0 0 3px rgba(103, 165, 82, 0.1);
}

input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled,
input[type="number"]:disabled,
input[type="tel"]:disabled,
input[type="url"]:disabled,
input[type="search"]:disabled,
input[type="date"]:disabled,
select:disabled,
textarea:disabled,
input.disabled,
select.disabled,
textarea.disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

/* Textarea */
textarea {
    resize: vertical;
    min-height: 100px;
}

/* Select */
select {
    cursor: pointer;
    padding-right: 36px;
    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='%236b7280' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    appearance: none;
}

/* ========================================
   INPUT SIZES
   ======================================== */

.input-mini {
    width: 100px;
    max-width: 100%;
}

.input-small {
    width: 150px;
    max-width: 100%;
}

.input-medium {
    width: 250px;
    max-width: 100%;
}

.input-xlarge {
    width: 400px;
    max-width: 100%;
}

.btn-large.input-xlarge {
    width: 400px;
    max-width: 100%;
    padding: 14px;
    font-size: 16px;
}

/* ========================================
   INPUT GROUPS / APPEND
   ======================================== */

.input-append {
    display: flex;
    gap: 0;
}

.input-append input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.input-append .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.appendedInputButton {
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

/* ========================================
   CHECKBOXES & RADIOS
   ======================================== */

/* Base checkbox and radio */
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    position: relative;
    vertical-align: middle;
}

/* Checkbox container */
.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    cursor: pointer;
}

.checkbox input[type="checkbox"] {
    margin-right: 0;
}

.checkbox label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* Radio button */
.radio {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    cursor: pointer;
}

.radio.inline {
    display: inline-flex;
    margin-right: 16px;
}

.radio input[type="radio"] {
    margin-right: 0;
}

.radio label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* Radio container */
.radiocontainer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Inputs list (for multiple checkboxes/radios) */
.inputs-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.inputs-list li {
    margin-bottom: 10px;
}

.inputs-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Full width label (for radio/checkbox with label) */
.full.control-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    font-weight: normal;
}

.full.control-label input[type="radio"],
.full.control-label input[type="checkbox"] {
    margin: 0;
}

/* ========================================
   CONTROL GROUPS
   ======================================== */

.control-group {
    margin-bottom: 20px;
}

.control-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.control-label.bold {
    font-weight: 600;
}

.controls {
    position: relative;
    font-size: 14px;
    line-height: 1.5;
}

/* Align checkboxes/radios with adjacent text */
.controls input[type="checkbox"],
.controls input[type="radio"] {
    vertical-align: middle;
    margin-right: 6px;
}

/* When checkbox/radio has text directly after it */
.controls input[type="checkbox"] + text,
.controls input[type="radio"] + text {
    vertical-align: middle;
}

/* Help text */
.help-block,
.help-inline {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}

.help-inline {
    display: inline-block;
    margin-left: 8px;
}

/* ========================================
   FORM ACTIONS
   ======================================== */

.form-actions {
    padding: 20px 0;
    margin-top: 30px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 12px;
    align-items: center;
}

.form-actions .btn {
    margin: 0;
}

/* ========================================
   VALIDATION STATES
   ======================================== */

/* Error state */
.control-group.error .control-label {
    color: #dc2626;
}

.control-group.error input,
.control-group.error select,
.control-group.error textarea {
    border-color: #ef4444;
}

.control-group.error input:focus,
.control-group.error select:focus,
.control-group.error textarea:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.control-group.error .help-block,
.control-group.error .help-inline {
    color: #dc2626;
}

/* Success state */
.control-group.success .control-label {
    color: #10b981;
}

.control-group.success input,
.control-group.success select,
.control-group.success textarea {
    border-color: #10b981;
}

.control-group.success input:focus,
.control-group.success select:focus,
.control-group.success textarea:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Warning state */
.control-group.warning .control-label {
    color: #d97706;
}

.control-group.warning input,
.control-group.warning select,
.control-group.warning textarea {
    border-color: #f59e0b;
}

.control-group.warning input:focus,
.control-group.warning select:focus,
.control-group.warning textarea:focus {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Reduce label width on smaller desktops */
@media (max-width: 1400px) {
    .form-horizontal .control-label {
        flex: 0 0 160px;
    }
}

/* Tablets and below - stack forms vertically */
@media (max-width: 1200px) {
    .form-horizontal .control-group {
        display: block;
    }

    .form-horizontal .control-label {
        display: block;
        text-align: left;
        padding-top: 0;
        margin-bottom: 6px;
        flex: none;
    }

    .form-horizontal .controls {
        display: block;
    }

    .input-append {
        flex-direction: column;
        gap: 8px;
    }

    .input-append input {
        border-radius: 6px;
        border-right: 1px solid #d1d5db;
    }

    .input-append .btn {
        border-radius: 6px;
        width: 100%;
    }

    .radio.inline {
        display: flex;
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* Mobile - additional adjustments */
@media (max-width: 767px) {
    .input-xlarge,
    .input-medium,
    .input-small,
    .input-mini,
    .btn-large.input-xlarge {
        width: 100%;
        max-width: 100%;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

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

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

    .form-inline .control-group {
        display: block;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus visible for keyboard navigation */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 2px solid #67a552;
    outline-offset: 2px;
}

/* Required field indicator */
.control-label.required:after {
    content: ' *';
    color: #ef4444;
}

/* Disabled state cursor */
input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    cursor: not-allowed;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .form-actions {
        display: none;
    }

    input,
    select,
    textarea {
        border: 1px solid #000;
    }
}
