/* =========================================================================
  新建预约抽屉 - 专属样式
  作用域限制在 #newAppointmentDrawer 下，避免污染父框架页面
  ========================================================================= */

/* ---------- 自定义抽屉宽度：672px ---------- */
#newAppointmentDrawer.offcanvas {
    width: 672px !important;
    max-width: 94vw;
    /* 写病历弹层 .pc-overlay z-index=9999，抽屉需在其最外层 */
    z-index: 10001 !important;
}
/* 抽屉遮罩（Bootstrap 插入的兄弟元素）同步抬升，盖住写病历弹层 */
#newAppointmentDrawer.offcanvas ~ .offcanvas-backdrop {
    z-index: 10000 !important;
}

/* ---------- 已约患者列表 Modal（在抽屉最外层之上） ---------- */
#bookedListModal.modal {
    z-index: 10010;
}
#bookedListModal ~ .modal-backdrop {
    z-index: 10005;
}

/* ---------- 时间选择器气泡弹出 ---------- */
.dt-picker-dropdown-wrapper {
    position: relative;
}

/* #dtPickerContainer 是 shadow DOM 的宿主，气泡定位样式直接作用其上 */
#dtPickerContainer {
    display: none;
    position: fixed;
    z-index: 99999;
    margin: 0;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    min-width: 480px;
}
@media (max-width: 768px) {
    #newAppointmentDrawer.offcanvas {
        width: 100% !important;
        max-width: 100vw;
    }
}

/* ---------- 固定底部操作栏 ---------- */
#newAppointmentDrawer .offcanvas-body {
    padding-bottom: 80px;
}
#newAppointmentDrawer .appointment-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    background: #fff;
    border-top: 1px solid #e9edf4;
    z-index: 10;
}

/* ---------- 表单样式 ---------- */
#newAppointmentDrawer .form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: #2c3a4b;
    margin-bottom: 3px;
}
#newAppointmentDrawer .form-control,
#newAppointmentDrawer .form-select {
    border-radius: 6px;
    border: 1px solid #d8dfe9;
    font-size: 0.85rem;
    padding: 5px 10px;
    background: #fafcff;
}
#newAppointmentDrawer .form-control:focus,
#newAppointmentDrawer .form-select:focus {
    border-color: #4a7cf7;
    box-shadow: 0 0 0 3px rgba(74, 124, 247, 0.15);
    background: #ffffff;
}
#newAppointmentDrawer .input-group-text {
    background: #fafcff;
    border: 1px solid #d8dfe9;
    color: #6c757d;
    border-radius: 6px 0 0 6px;
    padding: 5px 10px;
    font-size: 0.85rem;
}
#newAppointmentDrawer .input-group .form-control {
    border-left: none;
    border-radius: 0;
}
#newAppointmentDrawer .input-group .form-control:focus {
    border-left: none;
}

/* ---------- 查询按钮 - 边框与搜索框一致 ---------- */
#newAppointmentDrawer .input-group .btn-search {
    border-radius: 0 6px 6px 0;
    border: 1px solid #d8dfe9;
    border-left: none;
    color: #4a7cf7;
    background: #ffffff;
    font-size: 0.85rem;
    padding: 5px 16px;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
#newAppointmentDrawer .input-group .btn-search:hover {
    background: #f0f4fe;
    border-color: #d8dfe9;
    border-left: none;
    color: #4a7cf7;
}
#newAppointmentDrawer .input-group:focus-within .btn-search {
    border-color: #4a7cf7;
    border-left: none;
    box-shadow: 0 0 0 3px rgba(74, 124, 247, 0.15);
}
#newAppointmentDrawer .input-group:focus-within .btn-search:hover {
    border-color: #4a7cf7;
    border-left: none;
}
#newAppointmentDrawer .input-group .btn-search:active {
    background: #dce6fd;
    border-color: #4a7cf7;
    border-left: none;
}

#newAppointmentDrawer .readonly-info {
    font-size: 0.9rem;
    color: #1a2332;
    padding: 5px 0;
    font-weight: 500;
    display: inline-block;
}
#newAppointmentDrawer .readonly-label {
    color: #6b7a8f;
    font-weight: 400;
    margin-right: 4px;
    font-size: 0.85rem;
}

/* 就诊类型：系统自动判断，只读展示（新诊/复诊），不可修改 */
#newAppointmentDrawer input.visit-type-readonly {
    background: #f4f6fa;
    color: #1a2332;
    font-weight: 600;
    border: 1px dashed #d3dae6;
    cursor: not-allowed;
    box-shadow: none;
}
#newAppointmentDrawer input.visit-type-readonly:focus {
    border-color: #d3dae6;
    box-shadow: none;
}

#newAppointmentDrawer .required-star {
    color: #dc3545;
    margin-right: 2px;
}

/* ---------- 预约时间 datetimepicker 样式增强 ---------- */
#newAppointmentDrawer .form_datetime {
    cursor: pointer;
    background: #fff;
}

/* ---------- 消息通知（drawer 内 Toast） ---------- */
#newAppointmentDrawer .drawer-toast {
    position: absolute;
    top: 16px;
    right: 16px;
    left: 16px;
    z-index: 99999;
    padding: 12px 40px 12px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    animation: drawerToastIn 0.25s ease-out;
    pointer-events: auto;
}
#newAppointmentDrawer .drawer-toast-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}
#newAppointmentDrawer .drawer-toast-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
#newAppointmentDrawer .drawer-toast-warning {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}
#newAppointmentDrawer .drawer-toast .drawer-toast-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    color: inherit;
    opacity: 0.6;
    user-select: none;
}
#newAppointmentDrawer .drawer-toast .drawer-toast-close:hover {
    opacity: 1;
}
@keyframes drawerToastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 患者搜索结果下拉 ---------- */
#newAppointmentDrawer .search-results-wrapper {
    position: relative;
    width: 100%;
}
#newAppointmentDrawer .search-results-wrapper .search-results-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d8dfe9;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    padding: 4px 0;
}
#newAppointmentDrawer .search-results-wrapper .search-results-list .result-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.82rem;
    color: #2c3a4b;
    border-bottom: 1px solid #f1f3f7;
    transition: background 0.1s;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}
#newAppointmentDrawer .search-results-wrapper .search-results-list .result-item:last-child {
    border-bottom: none;
}
#newAppointmentDrawer .search-results-wrapper .search-results-list .result-item:hover {
    background: #f5f7fb;
}
#newAppointmentDrawer .search-results-wrapper .search-results-list .result-item .result-name {
    font-weight: 600;
}
#newAppointmentDrawer .search-results-wrapper .search-results-list .result-item .result-detail {
    color: #6b7a8f;
}
#newAppointmentDrawer .search-results-wrapper .search-results-list .no-result {
    padding: 12px;
    text-align: center;
    color: #a8b5c9;
    font-size: 0.85rem;
}

/* ---------- 左栏标签紧凑 ---------- */
#newAppointmentDrawer .left-panel .form-label {
    font-size: 0.78rem;
}
#newAppointmentDrawer .left-panel .form-control,
#newAppointmentDrawer .left-panel .form-select {
    font-size: 0.82rem;
    padding: 4px 10px;
}
#newAppointmentDrawer .left-panel .row.g-3 {
    --bs-gutter-y: 0.6rem;
    --bs-gutter-x: 0.8rem;
}
#newAppointmentDrawer .patient-section .row.g-3 {
    --bs-gutter-y: 0.4rem;
}

/* ---------- 右侧预约项目列表 - 自适应高度 ---------- */
#newAppointmentDrawer .right-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-left: 1px solid #e9edf4;
    padding-left: 16px;
}
#newAppointmentDrawer .right-panel .panel-title {
    flex-shrink: 0;
}
#newAppointmentDrawer .right-panel .search-box {
    flex-shrink: 0;
}
#newAppointmentDrawer .right-panel .item-list-wrap {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-right: 4px;
}

/* 动态渲染的预约项目列表样式 */
#newAppointmentDrawer .item-group-title {
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7a8f;
    padding: 6px 6px 2px 6px;
    border-bottom: 1px dashed #e9edf4;
    margin-bottom: 2px;
    margin-top: 4px;
    letter-spacing: 0.3px;
}
#newAppointmentDrawer .item-check {
    display: flex;
    align-items: flex-start;         /* 顶部对齐，换行时勾选框保持在第一行 */
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.12s;
    cursor: pointer;
    gap: 6px;
}
#newAppointmentDrawer .item-check:hover {
    background: #f4f6fb;
}
#newAppointmentDrawer .item-check .form-check-input {
    flex-shrink: 0;
    margin: 3px 0 0 0;               /* 与第一行文字对齐 */
    cursor: pointer;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1.5px solid #cbd2df;
}
#newAppointmentDrawer .item-check .item-label {
    display: block;                   /* 覆盖 Bootstrap label { display: inline-block }，防止宽度计算异常 */
    font-size: 0.82rem;
    color: #2c3a4b;
    cursor: pointer;
    flex: 1;
    min-width: 0;                    /* 允许文本收缩自动换行 */
    overflow-wrap: break-word;       /* 长单词/URL 断行 */
    word-break: break-word;          /* 兼容旧浏览器 */
    line-height: 1.5;                /* 换行后行间距舒适 */
}

/* 修复抽屉内滚动 */
#newAppointmentDrawer .offcanvas-body::-webkit-scrollbar {
    width: 4px;
}
#newAppointmentDrawer .offcanvas-body::-webkit-scrollbar-track {
    background: #f1f3f7;
}
#newAppointmentDrawer .offcanvas-body::-webkit-scrollbar-thumb {
    background: #cbd2df;
    border-radius: 10px;
}
#newAppointmentDrawer .offcanvas-body::-webkit-scrollbar-thumb:hover {
    background: #a8b2c4;
}

/* 响应式调整 */
@media (max-width: 768px) {
    #newAppointmentDrawer .right-panel {
        border-left: none;
        padding-left: 0;
        padding-top: 16px;
        border-top: 1px solid #e9edf4;
    }
    #newAppointmentDrawer .input-group .btn-search {
        font-size: 0.8rem;
        padding: 4px 12px;
    }
}
