/* ============================================================
 * Dialog 对话框组件
 * 统一弹框：居中对话框、底部抽屉、顶部下拉、Toast提示
 * 配色：黔好记主题色 --main: #B8860B (金色)
 * ============================================================ */

/* ========== 基础变量 ========== */
:root {
    --dialog-primary: var(--main, #B8860B);
    --dialog-primary-deep: var(--main-deep, #8B6914);
    --dialog-success: #27AE60;
    --dialog-danger: #E74C3C;
    --dialog-warning: #F39C12;
    --dialog-text: #2C3E50;
    --dialog-text-sub: #718096;
    --dialog-border: #EAECEE;
    --dialog-radius: 16px;
}

/* ========== 遮罩层 ========== */
.dialog-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 24px;
    backdrop-filter: blur(4px);
}
.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========== 居中对话框卡片 ========== */
.dialog-card {
    background: #fff;
    border-radius: var(--dialog-radius);
    width: 100%;
    max-width: 380px;
    overflow: hidden;
    transform: scale(0.92) translateY(16px);
    transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
}
.dialog-overlay.active .dialog-card {
    transform: scale(1) translateY(0);
}

/* 表单对话框头部 */
.dialog-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--dialog-border);
    flex-shrink: 0;
}
.dialog-card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dialog-text);
}
.dialog-card-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
}
.dialog-card-close:hover {
    color: var(--dialog-primary);
    background: rgba(184, 134, 11, 0.05);
}

/* 表单对话框body（可滚动） */
.dialog-card-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

/* 图标区 */
.dialog-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 28px;
}
.dialog-icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
}
.dialog-icon-success .dialog-icon-circle { background: rgba(39,174,96,.08); color: var(--dialog-success); }
.dialog-icon-danger .dialog-icon-circle { background: rgba(231,76,60,.08); color: var(--dialog-danger); }
.dialog-icon-warning .dialog-icon-circle { background: rgba(243,156,18,.08); color: var(--dialog-warning); }
.dialog-icon-info .dialog-icon-circle { background: rgba(0,97,108,.06); color: var(--dialog-primary); }

/* 内容区 */
.dialog-body {
    padding: 16px 28px 0;
    text-align: center;
}
.dialog-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dialog-text);
    line-height: 1.4;
    margin: 0 0 8px;
}
.dialog-message {
    font-size: 14px;
    color: var(--dialog-text-sub);
    line-height: 1.6;
    margin: 0;
}

/* 按钮区 */
.dialog-footer {
    display: flex;
    gap: 10px;
    padding: 20px 28px 24px;
}
.dialog-btn {
    flex: 1;
    height: 44px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dialog-btn:active { transform: scale(0.97); }

.dialog-btn-cancel {
    background: #F2F3F5;
    color: var(--dialog-text-sub);
}
.dialog-btn-cancel:active { background: #E8E9EB; }

.dialog-btn-primary {
    background: var(--dialog-primary);
    color: #fff;
}
.dialog-btn-primary:active { background: var(--dialog-primary-deep); }

.dialog-btn-danger {
    background: var(--dialog-danger);
    color: #fff;
}
.dialog-btn-danger:active { background: #C0392B; }

.dialog-btn-success {
    background: var(--dialog-success);
    color: #fff;
}
.dialog-btn-success:active { background: #1E8449; }

/* ========== 底部抽屉 Modal（设置/账本/资产用） ========== */
.modal-sheet-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(6px);
}
.modal-sheet-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-sheet {
    background: #fff;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.1);
}
.modal-sheet-overlay.active .modal-sheet {
    transform: translateY(0);
}

.modal-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--dialog-border);
    flex-shrink: 0;
}
.modal-sheet-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dialog-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-sheet-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
}
.modal-sheet-close:hover {
    color: var(--dialog-primary);
    background: rgba(184, 134, 11, 0.05);
}

.modal-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

.modal-sheet-footer {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--dialog-border);
    flex-shrink: 0;
    display: flex;
    gap: 10px;
}

/* ========== 顶部下拉筛选面板 ========== */
.filter-panel-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.filter-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

.filter-panel {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 600px;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    z-index: 9001;
    transition: transform 0.3s ease;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.filter-panel.active {
    transform: translateX(-50%) translateY(0);
}

.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}
.filter-panel-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--dialog-primary);
}
.filter-panel-close {
    font-size: 22px;
    color: #999;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    background: transparent;
    transition: all 0.2s;
}
.filter-panel-close:hover {
    color: var(--dialog-primary);
    background: rgba(184, 134, 11, 0.05);
}

.filter-panel-body {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-panel-footer {
    display: flex;
    gap: 10px;
    padding: 12px 20px calc(20px + env(safe-area-inset-bottom));
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* ========== 统一表单输入框 ========== */
.dialog-form-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.dialog-form-label {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    min-width: 70px;
    margin-bottom: 0;
}
.dialog-form-input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    font-size: 15px;
    color: var(--dialog-text);
    background: #fff;
    border: 1.5px solid var(--dialog-border);
    border-radius: 12px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.dialog-form-input::placeholder { color: #aaa; }
.dialog-form-input:hover { border-color: #ccc; }
.dialog-form-input:focus {
    border-color: var(--dialog-primary);
    box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.08);
}
.dialog-form-input:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.dialog-form-select {
    flex: 1;
    height: 40px;
    padding: 0 36px 0 16px;
    font-size: 15px;
    color: var(--dialog-text);
    background: #fff;
    border: 1.5px solid var(--dialog-border);
    border-radius: 12px;
    outline: none;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-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 d='M2 4l4 4 4-4' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.dialog-form-select:hover { border-color: #ccc; }
.dialog-form-select:focus {
    border-color: var(--dialog-primary);
    box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.08);
}

/* 权限单选按钮组 */
.perm-btn-group {
    display: flex;
    gap: 6px;
    flex: 1;
}
.perm-btn {
    flex: 1;
    height: 36px;
    border: 1.5px solid var(--dialog-border);
    border-radius: 8px;
    background: #fff;
    color: var(--dialog-text);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.perm-btn:hover {
    border-color: var(--dialog-primary);
    color: var(--dialog-primary);
}
.perm-btn.active {
    background: var(--dialog-primary);
    border-color: var(--dialog-primary);
    color: #fff;
}

.dialog-form-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--dialog-text);
    background: #fff;
    border: 1.5px solid var(--dialog-border);
    border-radius: 12px;
    outline: none;
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.dialog-form-textarea::placeholder { color: #aaa; }
.dialog-form-textarea:focus {
    border-color: var(--dialog-primary);
    box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.08);
}

/* ========== 统一按钮 ========== */
.dialog-btn-action {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dialog-primary), var(--dialog-primary-deep));
    color: #fff;
}
.dialog-btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(184, 134, 11, 0.25);
}
.dialog-btn-action:active {
    transform: scale(0.98);
}
.dialog-btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.dialog-btn-outline {
    width: 100%;
    height: 48px;
    border: 1.5px solid var(--dialog-border);
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: var(--dialog-text-sub);
}
.dialog-btn-outline:hover {
    border-color: var(--dialog-primary);
    color: var(--dialog-primary);
}
.dialog-btn-outline:active { transform: scale(0.98); }

/* ========== Alert 提示框 ========== */
.dialog-alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
    display: none;
    animation: dialogAlertIn 0.25s ease;
}
@keyframes dialogAlertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.dialog-alert-error {
    background: #FFF5F5;
    color: #E53E3E;
    border: 1px solid #FED7D7;
}
.dialog-alert-success {
    background: #F0FFF4;
    color: #38A169;
    border: 1px solid #C6F6D5;
}
.dialog-alert-warning {
    background: #FFFBEB;
    color: #D69E2E;
    border: 1px solid #FEFCBF;
}
.dialog-alert-info {
    background: #EBF8FF;
    color: #3182CE;
    border: 1px solid #BEE3F8;
}

/* ========== Toast 轻提示 ========== */
.dialog-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 14px;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    max-width: 80%;
    text-align: center;
    backdrop-filter: blur(8px);
}
.dialog-toast.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* ========== 搜索框 ========== */
.dialog-search-wrap {
    position: relative;
    margin-bottom: 16px;
}
.dialog-search-input {
    width: 100%;
    height: 44px;
    padding: 0 16px 0 42px;
    font-size: 15px;
    color: var(--dialog-text);
    background: #f8f9fa;
    border: 1.5px solid transparent;
    border-radius: 12px;
    outline: none;
    font-family: inherit;
    transition: all 0.2s;
    box-sizing: border-box;
}
.dialog-search-input::placeholder { color: #aaa; }
.dialog-search-input:focus {
    background: #fff;
    border-color: var(--dialog-primary);
    box-shadow: 0 0 0 4px rgba(184, 134, 11, 0.06);
}
.dialog-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
    pointer-events: none;
}

/* ========== 筛选行（保留兼容） ========== */
.dialog-filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* ========== 筛选面板 - 按钮选择组 ========== */
.filter-section {
    margin-bottom: 16px;
}
.filter-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    margin-bottom: 8px;
}
.filter-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.filter-btn-group.scrollable {
    max-height: 120px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.filter-btn-group.scrollable::-webkit-scrollbar {
    width: 3px;
}
.filter-btn-group.scrollable::-webkit-scrollbar-thumb {
    background: rgba(184, 134, 11, 0.2);
    border-radius: 2px;
}

/* ========== 日期范围选择 ========== */
.date-range-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-direction: column;
}
.date-range-header .filter-label {
    margin-bottom: 8px;
}
.filter-btn-sm {
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #888;
    background: #f5f5f5;
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.filter-btn-sm.active {
    color: #fff;
    background: var(--dialog-primary, #B8860B);
    font-weight: 600;
}
.date-range-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.date-range-item {
    flex: 1;
    min-width: 0;
    position: relative;
}
.date-range-item .date-picker-trigger {
    padding-right: 0px;
}
.date-range-label {
    display: block;
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}
.date-range-sep {
    color: #ccc;
    font-size: 16px;
    padding-bottom: 10px;
    flex-shrink: 0;
}
.filter-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    background: #f5f5f5;
    border: 1.5px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
    line-height: 1.4;
}
.filter-btn:active {
    transform: scale(0.95);
}
.filter-btn.active {
    color: #fff;
    background: var(--dialog-primary, #B8860B);
    border-color: var(--dialog-primary, #B8860B);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(184, 134, 11, 0.25);
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    .dialog-card { max-width: 90%; }
    .dialog-btn { height: 46px; }
    .modal-sheet { max-width: 100%; }
    .filter-panel { max-width: 100%; }
}

@media (max-width: 480px) {
    .dialog-body { padding: 12px 20px 0; }
    .dialog-footer { padding: 16px 20px 20px; }
    .dialog-filter-row { grid-template-columns: 1fr; }
}
