/* ==========================================
   WangHIS 专业医疗系统主题 v2.0
   HIS 风格 + 移动端优先响应式设计
   ========================================== */

:root {
    /* 主色调 - 专业医疗蓝 */
    --his-primary: #0066CC;
    --his-primary-dark: #004A99;
    --his-primary-light: #3399FF;
    --his-primary-gradient: linear-gradient(135deg, #0066CC 0%, #004A99 100%);

    /* 状态色系统 */
    --his-success: #28A745;
    /* 正常/已完成 */
    --his-warning: #FD7E14;
    /* 提醒/待处理 */
    --his-danger: #DC3545;
    /* 危险/急诊 */
    --his-info: #17A2B8;
    /* 信息提示 */

    /* 中性色 */
    --his-bg: #F0F4F8;
    --his-bg-card: #FFFFFF;
    --his-border: #D1D9E0;
    --his-border-light: #E8EEF3;
    --his-text: #2C3E50;
    --his-text-secondary: #6C7A89;
    --his-text-muted: #95A5A6;

    /* 阴影系统 */
    --his-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --his-shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --his-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

    /* 字体 */
    --his-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --his-font-mono: "SF Mono", "Monaco", "Consolas", monospace;

    /* 圆角 */
    --his-radius-sm: 4px;
    --his-radius-md: 8px;
    --his-radius-lg: 12px;
}

/* ========== 基础样式 ========== */
* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    background-color: var(--his-bg) !important;
    font-family: var(--his-font);
    color: var(--his-text);
    min-height: 100%;
    padding-bottom: 90px;
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    overscroll-behavior-y: none;
    /* 防止微信下拉露出背景 */
}

/* ========== 响应式布局 - 大屏幕适配 ========== */
/* 平板和PC上限制最大宽度，保持移动端样式不被拉长 */
@media (min-width: 768px) {
    body {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .his-header,
    #searchCard,
    .container-fluid,
    .total-bar,
    .copyright-bar,
    .his-footer,
    .footer-combined,
    .search-container,
    .stats-bar {
        width: 100%;
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .his-header {
        border-radius: 0 0 var(--his-radius-md) var(--his-radius-md);
        margin-top: 0;
    }

    .copyright-bar,
    .his-footer,
    .footer-combined {
        border-radius: var(--his-radius-md) var(--his-radius-md) 0 0;
    }

    /* 固定定位的版权栏在 PC 上也需要居中 */
    .copyright-bar-fixed {
        border-radius: var(--his-radius-md) var(--his-radius-md) 0 0;
    }

    /* 固定定位元素用 left: 50% + transform 居中 */
    .his-footer,
    .copyright-bar-fixed {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: 100% !important;
        max-width: 600px !important;
    }

    .his-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* PC大屏幕 - 增大宽度，更宽敞的布局 */
@media (min-width: 1200px) {

    .his-header,
    #searchCard,
    .container-fluid,
    .total-bar,
    .copyright-bar,
    .his-footer,
    .footer-combined,
    .search-container,
    .stats-bar {
        max-width: 800px;
    }

    /* 固定定位元素也需要同步更新 max-width */
    .his-footer,
    .copyright-bar-fixed {
        max-width: 800px !important;
    }

    /* PC端患者表单三列布局 */
    #patientForm .row {
        display: flex;
        flex-wrap: wrap;
    }

    /* PC端搜索输入框加大 */
    #searchApp {
        font-size: 15px !important;
        padding: 10px 16px !important;
    }

    /* PC端合计金额加大 */
    .total-bar .total-price {
        font-size: 26px;
    }
}

/* ========== 顶部导航栏 - HIS 专业风格 ========== */
.his-header {
    background: var(--his-primary-gradient);
    color: white;
    padding: 0 12px;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--his-shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.his-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--his-success), var(--his-primary-light), var(--his-info));
}

.his-header h5 {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.his-header small {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.his-header small::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--his-success);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

.his-header .btn-light {
    color: var(--his-primary);
    font-weight: 600;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: var(--his-radius-sm);
    border: none;
    transition: all 0.2s;
}

.his-header .btn-light:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
}

/* ========== 系统时钟 ========== */
.his-clock {
    font-family: var(--his-font-mono);
    font-size: 12px;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 10px;
    border-radius: var(--his-radius-sm);
    margin-left: 10px;
}

/* ========== 卡片标题栏按钮 ========== */
.his-header-btn {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--his-primary);
    background: white;
    border: 1px solid var(--his-primary);
    border-radius: var(--his-radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--his-font);
}

.his-header-btn:hover {
    background: var(--his-primary);
    color: white;
}

.his-header-btn.active {
    background: var(--his-primary-gradient);
    color: white;
    border-color: var(--his-primary-dark);
}

/* ========== 手动录入折叠面板 ========== */
.his-manual-panel {
    display: none;
    border-top: 1px solid var(--his-border);
    background: linear-gradient(180deg, #F0F7FF 0%, #F8FAFC 100%);
}

.his-manual-panel.show {
    display: block;
    animation: fadeSlideDown 0.2s ease-out;
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.his-manual-inner {
    padding: 10px 12px;
}

.his-manual-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--his-primary-dark);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--his-border);
}

/* 手动录入字段 - 移动端竖排，平板/PC横排 */
.his-manual-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.his-inline-field {
    flex: 1;
    min-width: 100px;
}

.his-inline-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--his-text-secondary);
    margin-bottom: 3px;
}

.his-inline-field-btn {
    display: flex;
    align-items: flex-end;
    flex: 0 0 auto;
}

/* ========== 搜索结果下拉 ========== */
.his-dropdown-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid var(--his-border);
    border-top: 2px solid var(--his-primary);
    border-radius: 0 0 var(--his-radius-md) var(--his-radius-md);
    box-shadow: var(--his-shadow-lg);
    max-height: 50vh;
    overflow-y: auto;
    z-index: 1050;
    display: none;
}

/* 搜索结果项 */
.his-dropdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--his-border-light);
    cursor: pointer;
    transition: background-color 0.12s;
}

.his-dropdown-item:last-child {
    border-bottom: none;
}

.his-dropdown-item:nth-child(even) {
    background: #F8FAFC;
}

.his-dropdown-item:hover {
    background: rgba(0, 102, 204, 0.06) !important;
}

.his-dropdown-item:active {
    background: rgba(0, 102, 204, 0.12) !important;
}

.his-dropdown-item .drug-name {
    font-weight: 600;
    color: var(--his-text);
    font-size: 14px;
}

.his-dropdown-item .drug-info {
    font-size: 12px;
    color: var(--his-text-muted);
    margin-top: 1px;
}

.his-dropdown-item .drug-price {
    text-align: right;
    white-space: nowrap;
}

.his-dropdown-item .drug-price .val {
    font-size: 15px;
    font-weight: 700;
    color: var(--his-danger);
    font-family: var(--his-font-mono);
}

.his-dropdown-item .drug-price .unit {
    font-size: 11px;
    color: var(--his-text-muted);
}

/* 移动端：手动录入字段竖排 */
@media (max-width: 500px) {
    .his-manual-fields {
        flex-direction: column;
    }

    .his-inline-field {
        min-width: 100%;
    }

    .his-inline-field-btn {
        width: 100%;
    }

    .his-inline-field-btn .btn {
        width: 100%;
    }
}

/* ========== HIS 卡片组件 ========== */
.his-card {
    background: var(--his-bg-card);
    border: 1px solid var(--his-border);
    border-radius: var(--his-radius-md);
    box-shadow: var(--his-shadow-sm);
    overflow: hidden;
    margin-bottom: 10px;
}

.his-card-header {
    background: linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 100%);
    padding: 10px 14px;
    font-weight: 600;
    font-size: 14px;
    color: var(--his-text);
    border-bottom: 1px solid var(--his-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.his-card-header span:first-child {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ========== 表单样式 - 医疗系统专业风格 ========== */
.form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--his-text-secondary);
    margin-bottom: 4px;
}

.form-label .text-danger {
    color: var(--his-danger) !important;
    font-weight: 700;
}

.form-control,
.form-control-sm {
    border: 1px solid var(--his-border);
    border-radius: var(--his-radius-sm);
    padding: 8px 10px;
    font-size: 14px;
    transition: all 0.2s;
    background: #FAFBFC;
}

.form-control:focus,
.form-control-sm:focus {
    border-color: var(--his-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-control::placeholder {
    color: var(--his-text-muted);
    font-size: 13px;
}

/* 只读字段 */
.form-control[readonly],
.form-control:disabled {
    background: #E9ECEF;
    color: var(--his-text-secondary);
}

/* ========== 医嘱表格 - HIS 专业样式 ========== */
.order-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.order-table thead {
    background: linear-gradient(180deg, #EDF2F7 0%, #E2E8F0 100%);
    position: sticky;
    top: 0;
}

.order-table th {
    color: var(--his-text-secondary);
    font-weight: 600;
    font-size: 12px;
    padding: 10px 8px;
    border-bottom: 2px solid var(--his-border);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.order-table tbody tr {
    transition: background-color 0.15s;
}

/* 斑马纹 */
.order-table tbody tr:nth-child(even) {
    background-color: #F8FAFC;
}

.order-table tbody tr:hover {
    background-color: rgba(0, 102, 204, 0.05);
}

.order-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--his-border-light);
    vertical-align: middle;
}

.item-name {
    font-weight: 600;
    color: var(--his-text);
    display: block;
    line-height: 1.3;
}

.item-spec {
    font-size: 11px;
    color: var(--his-text-muted);
    margin-top: 2px;
}

/* ========== 数量控制器 ========== */
.qty-control {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--his-border);
    border-radius: var(--his-radius-sm);
    overflow: hidden;
    background: white;
}

.qty-btn {
    border: none;
    background: linear-gradient(180deg, #F8FAFC 0%, #EDF2F7 100%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--his-text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.qty-btn:hover {
    background: var(--his-primary);
    color: white;
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-val {
    width: 40px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-left: 1px solid var(--his-border-light);
    border-right: 1px solid var(--his-border-light);
    background: white;
    line-height: 32px;
}

/* ========== 底部操作栏 ========== */
.his-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--his-bg-card);
    border-top: 1px solid var(--his-border);
    padding: 12px 16px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.total-label {
    font-size: 12px;
    color: var(--his-text-secondary);
    font-weight: 500;
}

.total-price {
    font-size: 24px;
    color: var(--his-danger);
    font-weight: 700;
    font-family: var(--his-font-mono);
}

.his-footer .btn-primary {
    background: var(--his-primary-gradient);
    border: none;
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--his-radius-md);
    box-shadow: var(--his-shadow-sm);
    transition: all 0.2s;
}

.his-footer .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--his-shadow-md);
}

.his-footer .btn-primary:active {
    transform: translateY(0);
}

/* ========== 版权信息条 - 渐变毛玻璃效果 ========== */
.copyright-bar {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.06) 0%, rgba(0, 180, 220, 0.1) 50%, rgba(0, 102, 204, 0.06) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0, 102, 204, 0.12);
    border-bottom: 1px solid rgba(0, 102, 204, 0.08);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 -1px 3px rgba(0, 102, 204, 0.05);
}

.copyright-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        left: -60%;
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        left: 100%;
        opacity: 0;
    }
}

.copyright-bar .icon {
    font-size: 18px;
    filter: drop-shadow(0 2px 3px rgba(0, 102, 204, 0.15));
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.copyright-bar .text {
    font-size: 12px;
    color: #4a7a9a;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
    position: relative;
    z-index: 1;
}

.copyright-bar .highlight {
    color: var(--his-primary);
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 102, 204, 0.1);
}

.copyright-bar .divider {
    width: 1px;
    height: 14px;
    background: linear-gradient(180deg, transparent, rgba(0, 102, 204, 0.25), transparent);
    margin: 0 6px;
}

.copyright-bar .contact {
    font-size: 11px;
    color: var(--his-primary);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(240, 248, 255, 0.9));
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 102, 204, 0.15);
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.08);
    transition: all 0.2s ease;
    position: relative;
    z-index: 1;
}

.copyright-bar .contact:hover {
    background: var(--his-primary-gradient);
    color: white;
    border-color: var(--his-primary);
    box-shadow: 0 3px 8px rgba(0, 102, 204, 0.25);
    transform: translateY(-1px);
}

.copyright-bar .contact:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 102, 204, 0.2);
}

/* ========== 固定定位版权栏 (用于药品维护等页面) ========== */
.copyright-bar-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
}

/* ========== 搜索容器 (用于药品维护等页面) ========== */
.search-container {
    background: var(--his-bg-card);
    padding: 10px 12px;
    border-bottom: 1px solid var(--his-border);
    box-shadow: var(--his-shadow-sm);
}

/* ========== 合计金额栏 (非固定，在医嘱明细下方) ========== */
.total-bar {
    background: linear-gradient(135deg, #FFF9E6 0%, #FFF3CD 100%);
    border: 1px solid #FFE69C;
    border-radius: var(--his-radius-md);
    padding: 12px 16px;
    box-shadow: var(--his-shadow-sm);
}

.total-bar .total-label {
    font-size: 13px;
    color: #856404;
    font-weight: 500;
}

.total-bar .total-price {
    font-size: 22px;
    color: var(--his-danger);
    font-weight: 700;
    font-family: var(--his-font-mono);
}

/* ========== 状态徽章 ========== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.badge-status.online::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--his-success);
    border-radius: 50%;
}

/* ========== 空状态 ========== */
#emptyMsg {
    padding: 40px 20px;
}

#emptyMsg div:first-child {
    font-size: 48px;
    opacity: 0.15;
}

#emptyMsg p {
    color: var(--his-text-muted);
    font-size: 14px;
}

/* ========== 旧搜索结果样式已迁移至 .his-dropdown-results ========== */

/* ========== 历史记录页相关 ========== */
details summary {
    outline: none;
    user-select: none;
}

details[open] summary {
    color: var(--his-primary);
}

/* ========== 响应式适配 - 小屏手机 ========== */
@media (max-width: 375px) {
    .his-header {
        padding: 0 10px;
    }

    .his-header h5 {
        font-size: 14px;
    }

    .his-card-header {
        padding: 8px 10px;
        font-size: 13px;
    }

    .copyright-bar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 15px;
    }

    .copyright-bar .divider {
        display: none;
    }

    /* 小屏搜索结果项紧凑 */
    .his-dropdown-item {
        padding: 8px 10px;
    }

    .his-dropdown-item .drug-name {
        font-size: 13px;
    }

    .his-dropdown-item .drug-price .val {
        font-size: 14px;
    }
}

/* ========== 响应式适配 - 平板 ========== */
@media (min-width: 768px) {
    .his-header {
        padding: 0 20px;
        height: 56px;
    }

    .his-header h5 {
        font-size: 18px;
    }

    .his-card {
        border-radius: var(--his-radius-lg);
    }

    .his-card-header {
        padding: 12px 16px;
        font-size: 15px;
    }

    /* 平板端搜索输入框加大 */
    #searchApp {
        font-size: 15px !important;
        padding: 10px 14px !important;
    }

    /* 平板端手动录入横排 */
    .his-manual-fields {
        flex-wrap: nowrap;
        align-items: flex-end;
    }

    .his-inline-field {
        min-width: auto;
    }

    /* 平板端表单标签加大 */
    .form-label {
        font-size: 13px;
    }

    .form-control-sm {
        font-size: 14px;
        padding: 6px 10px;
    }

    /* 平板端表格加宽 */
    .order-table {
        font-size: 14px;
    }

    .order-table th,
    .order-table td {
        padding: 14px 12px;
    }

    /* 平板端搜索结果加宽 */
    .his-dropdown-item {
        padding: 12px 16px;
    }

    .his-dropdown-item .drug-name {
        font-size: 15px;
    }

    .his-dropdown-item .drug-price .val {
        font-size: 17px;
    }

    /* 平板端合计金额 */
    .total-bar {
        padding: 14px 20px;
    }

    .total-bar .total-label {
        font-size: 14px;
    }

    .total-bar .total-price {
        font-size: 24px;
    }

    /* 平板端底部按钮加大 */
    .his-footer .btn {
        font-size: 16px;
        padding: 12px !important;
    }
}

/* ========== 响应式适配 - PC大屏 ========== */
@media (min-width: 1200px) {
    .his-header h5 {
        font-size: 20px;
    }

    .his-card-header {
        padding: 14px 18px;
        font-size: 16px;
    }

    .form-control-sm {
        font-size: 15px;
        padding: 8px 12px;
    }

    /* PC端表格宽松 */
    .order-table th,
    .order-table td {
        padding: 16px 14px;
    }

    .order-table {
        font-size: 15px;
    }

    /* PC端搜索结果 */
    .his-dropdown-item {
        padding: 14px 18px;
    }

    .his-dropdown-item .drug-name {
        font-size: 16px;
    }

    .his-dropdown-item .drug-info {
        font-size: 13px;
    }

    .his-dropdown-item .drug-price .val {
        font-size: 18px;
    }
}