/* 响应式表单布局样式 */

/* 表单容器基础样式 */
.form-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    padding: 0;
}

/* 响应式表单包装器 */
.responsive-form {
    min-width: 800px; /* 最小宽度确保表单不会过度压缩 */
    width: 100%;
}

/* 表单卡片样式 */
.form-card {
    margin: 0 auto;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.375rem;
}

/* 表单行布局 */
.form-row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.form-row > .col,
.form-row > [class*="col-"] {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

/* 响应式表单组 */
.responsive-form-group {
    margin-bottom: 1rem;
    width: 100%;
}

/* 表单标签样式 */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* 表单控件样式 */
.form-control,
.form-select {
    width: 100%;
    min-width: 0;
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* 输入组样式 */
.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;
}

/* 按钮组样式 */
.btn-group-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
}

/* 表单操作按钮区域 */
.form-actions {
    padding: 1rem 0;
    border-top: 1px solid #dee2e6;
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* 搜索表单样式 */
.search-form {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.search-form .row {
    align-items: end;
}

/* 横向滚动容器 */
.horizontal-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #6c757d #f8f9fa;
}

.horizontal-scroll::-webkit-scrollbar {
    height: 8px;
}

.horizontal-scroll::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.horizontal-scroll::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 4px;
}

.horizontal-scroll::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

/* 表格响应式包装 */
.table-responsive-custom {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive-custom > .table {
    margin-bottom: 0;
    min-width: 800px;
}

/* 移动端优化 */
@media (max-width: 767.98px) {
    .form-container {
        padding: 0.5rem;
    }
    
    .responsive-form {
        min-width: 100%;
    }
    
    .form-row {
        margin-right: -0.5rem;
        margin-left: -0.5rem;
    }
    
    .form-row > .col,
    .form-row > [class*="col-"] {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }
    
    /* 移动端表单列布局调整 */
    .col-md-6,
    .col-md-4,
    .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* 移动端按钮组 */
    .btn-group-responsive {
        flex-direction: column;
    }
    
    .btn-group-responsive .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* 移动端表单操作 */
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* 移动端搜索表单 */
    .search-form .col-md-3,
    .search-form .col-md-2,
    .search-form .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.75rem;
    }
}

/* 平板端优化 */
@media (min-width: 768px) and (max-width: 991.98px) {
    .responsive-form {
        min-width: 700px;
    }
    
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .col-md-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* 大屏幕优化 */
@media (min-width: 1200px) {
    .form-container {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .responsive-form {
        min-width: 1000px;
    }
}

/* 表单验证样式 */
.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.94-.94 1.44 1.44L7.4 4.5l.94.94L4.66 9.17z'/%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 d='m5.8 4.6 2.4 2.4M8.2 4.6l-2.4 2.4'/%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);
}

/* 加载状态样式 */
.form-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1000;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 表单分组样式 */
.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.form-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

/* 响应式工具类 */
.d-mobile-block {
    display: none;
}

.d-mobile-none {
    display: block;
}

@media (max-width: 767.98px) {
    .d-mobile-block {
        display: block;
    }
    
    .d-mobile-none {
        display: none;
    }
}

/* 表单提示样式 */
.form-hint {
    font-size: 0.875rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.form-hint.error {
    color: #dc3545;
}

.form-hint.success {
    color: #198754;
}

/* 必填字段标识 */
.required::after {
    content: ' *';
    color: #dc3545;
    font-weight: bold;
}

/* 表单步骤样式 */
.form-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding: 0;
    list-style: none;
}

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

.form-step::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #dee2e6;
    z-index: 1;
}

.form-step:first-child::before {
    left: 50%;
}

.form-step:last-child::before {
    right: 50%;
}

.form-step.active::before {
    background: #007bff;
}

.form-step-indicator {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 28px;
    border-radius: 50%;
    background: #dee2e6;
    color: #6c757d;
    font-weight: bold;
    position: relative;
    z-index: 2;
}

.form-step.active .form-step-indicator {
    background: #007bff;
    color: white;
}

.form-step.completed .form-step-indicator {
    background: #198754;
    color: white;
}

/* 自适应文本区域 */
.auto-resize {
    resize: vertical;
    min-height: 100px;
}

/* 文件上传区域 */
.file-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    padding: 2rem;
    text-align: center;
    transition: border-color 0.15s ease-in-out;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #007bff;
    background-color: #f8f9fa;
}

.file-upload-area.dragover {
    border-color: #007bff;
    background-color: #e7f3ff;
}

/* 响应式图片 */
.responsive-img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
}

/* 表单内联编辑 */
.inline-edit {
    border: none;
    background: transparent;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease-in-out;
}

.inline-edit:hover {
    background-color: #f8f9fa;
}

.inline-edit:focus {
    background-color: #ffffff;
    border: 1px solid #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}