/* ============================================
   FORMS.CSS - Формы и элементы ввода
   Premium iOS Glass Design
   ============================================ */

/* ========== FORM GROUPS ========== */

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.form-label.required::after {
    content: '*';
    color: #FF3B30;
    margin-left: 4px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.form-error {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: #FF3B30;
}

/* ========== TEXT INPUTS - PREMIUM ========== */

.form-input,
.form-select,
textarea.form-input {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-system);
    font-size: 14px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(142, 142, 147, 0.2);
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.form-input:hover,
.form-select:hover {
    border-color: rgba(142, 142, 147, 0.3);
    background: rgba(255, 255, 255, 0.7);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #007AFF;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1), 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.form-input::placeholder {
    color: rgba(142, 142, 147, 0.6);
}

.form-input:disabled,
.form-select:disabled {
    background: rgba(142, 142, 147, 0.08);
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-input.error {
    border-color: #FF3B30;
}

.form-input.error:focus {
    box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.1), 0 2px 8px rgba(255, 59, 48, 0.08);
}

/* Input Sizes */
.form-input-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.form-input-lg {
    padding: 14px 18px;
    font-size: 16px;
}

/* ========== TEXTAREA ========== */

textarea.form-input {
    min-height: 120px;
    resize: vertical;
    line-height: 1.5;
}

/* ========== SELECT DROPDOWN ========== */

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23007AFF' d='M1.41 0L6 4.58L10.59 0L12 1.42l-6 6l-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

/* ========== CHECKBOX & RADIO ========== */

.form-checkbox,
.form-radio {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #007AFF;
}

.form-check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    padding: 8px 0;
}

.form-check-label input {
    flex-shrink: 0;
}

/* Custom Checkbox */
.custom-checkbox {
    position: relative;
    display: inline-block;
    width: 22px;
    height: 22px;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-mark {
    position: absolute;
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(142, 142, 147, 0.3);
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-checkbox input:checked ~ .checkbox-mark {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    border-color: #007AFF;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.checkbox-mark::after {
    content: '';
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-checkbox input:checked ~ .checkbox-mark::after {
    display: block;
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(142, 142, 147, 0.2);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
    border: 1px solid rgba(142, 142, 147, 0.15);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 28px;
    width: 28px;
    left: 2px;
    bottom: 1px;
    background: white;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #34C759 0%, #2AB04E 100%);
    border-color: #34C759;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

/* ========== SEARCH BOX ========== */

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 14px;
    color: rgba(142, 142, 147, 0.6);
    pointer-events: none;
    z-index: 1;
    font-size: 14px;
}

.search-input {
    width: 100%;
    padding: 11px 16px 11px 42px;
    font-family: var(--font-system);
    font-size: 14px;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(142, 142, 147, 0.2);
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
    outline: none;
    border-color: #007AFF;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

/* ========== SELECTION LISTS ========== */

.selection-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(142, 142, 147, 0.15);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin-top: 10px;
}

.selection-list.config-list {
    max-height: 400px;
}

.selection-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(142, 142, 147, 0.08);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
}

.selection-item:last-child {
    border-bottom: none;
}

.selection-item:hover {
    background: rgba(0, 122, 255, 0.06);
    transform: translateX(3px);
}

.selection-item.selected {
    background: rgba(0, 122, 255, 0.1);
    border-left: 3px solid #007AFF;
}

.item-checkbox {
    margin-right: 12px;
    font-size: 18px;
    color: #007AFF;
    min-width: 20px;
}

.item-content {
    flex: 1;
}

.item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.item-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.item-badges {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ========== FILTER BAR ========== */

.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(142, 142, 147, 0.2);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
}

.filter-btn:hover {
    background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
    color: white;
    border-color: #007AFF;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}

.filter-btn:active {
    transform: translateY(0);
}

.filter-btn i {
    font-size: 12px;
}

/* ========== FILTER PANEL ========== */

.filter-panel {
    background: rgba(142, 142, 147, 0.06);
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    border: 1px solid rgba(142, 142, 147, 0.1);
}

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

.filter-select,
.filter-input {
    padding: 9px 14px;
    border: 1px solid rgba(142, 142, 147, 0.2);
    border-radius: 8px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    transition: all 0.2s;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* ========== FILE UPLOAD ========== */

.file-upload {
    position: relative;
    display: inline-block;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px dashed rgba(142, 142, 147, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.file-upload-label:hover {
    border-color: #007AFF;
    background: rgba(0, 122, 255, 0.05);
}

.file-upload-label i {
    font-size: 18px;
    color: #007AFF;
}

/* ========== FORM VALIDATION ========== */

.form-input.is-valid {
    border-color: #34C759;
}

.form-input.is-valid:focus {
    box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.1);
}

.form-input.is-invalid {
    border-color: #FF3B30;
}

.form-input.is-invalid:focus {
    box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.1);
}

.valid-feedback {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: #34C759;
}

.invalid-feedback {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: #FF3B30;
}

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

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

.input-group .form-input {
    border-radius: 0;
}

.input-group .form-input:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.input-group .form-input:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

.input-group-prepend,
.input-group-append {
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: rgba(142, 142, 147, 0.08);
    border: 1px solid rgba(142, 142, 147, 0.2);
    color: var(--text-secondary);
    font-size: 13px;
}

.input-group-prepend {
    border-right: none;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.input-group-append {
    border-left: none;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

/* ========== FORM GRID ========== */

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

/* ========== READONLY INPUTS ========== */

.form-input[readonly] {
    background: rgba(142, 142, 147, 0.08) !important;
    color: var(--text-secondary);
    cursor: not-allowed;
    border-color: rgba(142, 142, 147, 0.15);
}

/* ========== DARK MODE ========== */

@media (prefers-color-scheme: dark) {
    .form-input,
    .form-select,
    .search-input {
        background: rgba(44, 44, 46, 0.6);
        border-color: rgba(255, 255, 255, 0.15);
        color: white;
    }
    
    .form-input:hover,
    .form-select:hover,
    .search-input:hover {
        background: rgba(44, 44, 46, 0.7);
    }
    
    .form-input:focus,
    .form-select:focus,
    .search-input:focus {
        background: rgba(44, 44, 46, 0.9);
    }
    
    .selection-list {
        background: rgba(28, 28, 30, 0.7);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .selection-item {
        background: transparent;
    }
    
    .selection-item:hover {
        background: rgba(0, 122, 255, 0.15);
    }
    
    .filter-panel {
        background: rgba(44, 44, 46, 0.4);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .filter-btn {
        background: rgba(44, 44, 46, 0.6);
        border-color: rgba(255, 255, 255, 0.15);
        color: white;
    }
    
    .form-input[readonly] {
        background: rgba(44, 44, 46, 0.5) !important;
    }
}

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

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-btn {
        width: 100%;
        justify-content: center;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
    }
}

/* ========== SCROLLBAR STYLING ========== */

.selection-list::-webkit-scrollbar {
    width: 8px;
}

.selection-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.selection-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.selection-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}
