/* ========================================
   承颐济世堂 - 内部管理系统
   设计主题：中医药暖色调（琥珀金 + 墨绿）
   与 ChengYiCode（蓝灰冷色）明显区分
   ======================================== */

/* 全局样式 */
:root {
    --primary: #b8860b;          /* 暗金色 - 主色 */
    --primary-dark: #8b6914;     /* 深金色 */
    --primary-light: #daa520;    /* 亮金色 */
    --accent: #2d5016;           /* 墨绿色 - 强调色 */
    --accent-light: #3d6b1e;     /* 亮墨绿 */
    --sidebar-bg: #1a2e1a;       /* 深墨绿 - 侧边栏 */
    --sidebar-hover: rgba(184, 134, 11, 0.15);
    --sidebar-active: rgba(184, 134, 11, 0.25);
    --text-dark: #2c2c2c;
    --text-muted: #6b7280;
    --bg-body: #f5f0e8;          /* 暖米色背景 */
    --bg-card: #ffffff;
    --border-color: #e8e0d4;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 14px;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-dark);
}

/* 应用布局 */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ========== 侧边栏 - 深墨绿 + 金色点缀 ========== */
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #1a2e1a 0%, #0f1f0f 100%);
    color: #e8e0d4;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    /* 隐藏滚动条 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar-header {
    padding: 0.75rem 1rem 0.6rem;
    text-align: center;
    border-bottom: 1px solid rgba(184, 134, 11, 0.3);
    background: linear-gradient(135deg, rgba(184, 134, 11, 0.1) 0%, transparent 100%);
}

.sidebar-header h5 {
    color: var(--primary-light);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 2px;
    margin-bottom: 0;
    line-height: 1.3;
}

.sidebar-header small {
    color: rgba(218, 165, 32, 0.6);
    font-size: 0.7rem;
    letter-spacing: 1px;
}

.sidebar-nav {
    list-style: none;
    padding: 0.4rem 0 0.5rem;
    margin: 0;
}

.sidebar-nav .nav-section {
    padding: 0.5rem 1.25rem 0.2rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    color: rgba(184, 134, 11, 0.6);
    letter-spacing: 1.5px;
    font-weight: 600;
}

.sidebar-nav .nav-item .nav-link {
    display: flex;
    align-items: center;
    padding: 0.45rem 1.25rem;
    color: rgba(232, 224, 212, 0.75);
    text-decoration: none;
    transition: all 0.25s ease;
    font-size: 0.84rem;
    border-left: 3px solid transparent;
    margin: 0;
    line-height: 1.4;
}

.sidebar-nav .nav-item .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--primary-light);
    border-left-color: rgba(184, 134, 11, 0.4);
}

.sidebar-nav .nav-item .nav-link.active {
    background: var(--sidebar-active);
    color: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 500;
}

.sidebar-nav .nav-item .nav-link i {
    width: 20px;
    margin-right: 0.75rem;
    text-align: center;
    font-size: 1rem;
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部导航 - 暖白色 */
.top-navbar {
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    color: var(--text-dark);
    font-size: 1.25rem;
}

/* 内容区 */
.content-area {
    padding: 1.75rem;
    flex: 1;
}

/* ========== 登录页 - 独特设计 ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, #1a2e1a 0%, #2d5016 40%, #3d6b1e 70%, #b8860b 100%);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 70%, rgba(184, 134, 11, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 70% 30%, rgba(218, 165, 32, 0.1) 0%, transparent 50%);
    animation: loginBgShift 20s ease-in-out infinite alternate;
}

@keyframes loginBgShift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-5%, 5%) rotate(3deg); }
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(184, 134, 11, 0.2);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 50%, var(--accent) 100%);
    border-radius: 16px 16px 0 0;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .login-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: #fff;
    box-shadow: 0 4px 15px rgba(184, 134, 11, 0.3);
}

.login-header h3 {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    letter-spacing: 3px;
}

.login-header p {
    color: var(--primary);
    font-size: 0.85rem;
    letter-spacing: 2px;
}

/* ========== 统计卡片 ========== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(184, 134, 11, 0.3);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ========== 卡片样式 ========== */
.card {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.card-header {
    background: linear-gradient(135deg, rgba(184, 134, 11, 0.05) 0%, rgba(45, 80, 22, 0.03) 100%);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--accent);
    padding: 0.85rem 1.25rem;
}

/* ========== 表格样式 ========== */
.table th {
    font-weight: 600;
    color: var(--accent);
    background: linear-gradient(180deg, rgba(184, 134, 11, 0.06) 0%, rgba(45, 80, 22, 0.04) 100%);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table-hover tbody tr:hover {
    background-color: rgba(184, 134, 11, 0.04);
}

/* ========== 按钮样式 - 金色主题 ========== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-color: var(--primary);
    color: #fff;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(184, 134, 11, 0.25);
    transition: all 0.25s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #6b4f10 100%);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ========== 分页样式 ========== */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.page-link {
    color: var(--primary);
    border-color: var(--border-color);
}

.page-link:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ========== 表单样式 ========== */
.form-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.875rem;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.15);
}

/* ========== 状态标签 ========== */
.badge-status {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 20px;
}

.badge-success {
    background: var(--accent);
    color: #fff;
}

.badge-warning {
    background: var(--primary);
    color: #fff;
}

.badge-danger {
    background: #c0392b;
    color: #fff;
}

.badge-info {
    background: var(--primary-dark);
    color: #fff;
}

/* 库存预警 */
.stock-warning {
    color: #c0392b;
    font-weight: 600;
}

.stock-safe {
    color: var(--accent);
}

/* 打印区域 */
.print-area {
    display: none;
}

/* 快捷操作按钮 */
.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
}

.quick-action-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
    color: var(--primary);
}

.quick-action-btn i {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.quick-action-btn span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* 响应式 */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

/* 打印样式 */
@media print {
    .sidebar,
    .top-navbar,
    .no-print,
    footer {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 0;
    }

    .print-area {
        display: block;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    /* 去除打印内容下方的空白 */
    html, body {
        height: auto !important;
        min-height: auto !important;
    }

    .wrapper {
        min-height: auto !important;
    }
}

/* 热敏药品列表 - 页面隐藏，仅 58mm 打印时显示 */
.thermal-list {
    display: none;
}

/* ========== 热敏打印机 - 58mm ========== */
@media print {
    /* 默认隐藏热敏列表 */
    .thermal-list { display: none; }

    body.print-58mm #printArea .card {
        border: none;
        margin: 0;
        padding: 0;
    }
    body.print-58mm #printArea .card-body {
        padding: 2mm;
    }
    body.print-58mm #printArea {
        font-size: 9pt;
        max-width: 48mm;
        margin: 0;
        padding: 0;
    }
    body.print-58mm #printArea h4 {
        font-size: 13pt;
        margin-bottom: 2px;
    }
    body.print-58mm #printArea h5 {
        font-size: 11pt;
        margin-bottom: 2px;
    }
    body.print-58mm #printArea .text-center.mb-3 {
        margin-bottom: 3px !important;
    }
    body.print-58mm #printArea hr {
        margin: 3px 0;
    }
    /* 患者信息堆叠显示 */
    body.print-58mm #printArea .row.mb-3 > div {
        display: block;
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        margin-bottom: 1px;
        font-size: 9pt;
    }
    /* 隐藏表格，显示热敏列表 */
    body.print-58mm #printArea table {
        display: none !important;
    }
    body.print-58mm #printArea .thermal-list {
        display: block;
    }
    /* 热敏列表样式 */
    body.print-58mm .thermal-item {
        margin-bottom: 3px;
        padding-bottom: 2px;
        border-bottom: 1px dashed #ccc;
    }
    body.print-58mm .thermal-item-main {
        font-size: 9pt;
    }
    body.print-58mm .thermal-drug-name {
        font-weight: 700;
    }
    body.print-58mm .thermal-item-weight {
        margin-left: 4px;
    }
    body.print-58mm .thermal-item-amount {
        float: right;
        font-weight: 700;
    }
    body.print-58mm .thermal-item-detail {
        font-size: 7.5pt;
        color: #555;
        margin-left: 8px;
    }
    body.print-58mm .thermal-item-note {
        font-size: 7.5pt;
        color: #888;
        margin-left: 8px;
    }
    body.print-58mm .thermal-total {
        margin-top: 4px;
        padding-top: 3px;
        border-top: 1px solid #333;
        font-weight: 700;
        font-size: 10pt;
    }
    body.print-58mm .thermal-total-amount {
        float: right;
        color: #c0392b;
    }
    /* 收费信息堆叠 */
    body.print-58mm #printArea .row > div {
        display: block;
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
        margin-bottom: 1px;
    }
}

/* ========== 热敏打印机 - 80mm ========== */
@media print {
    /* 80mm 也使用热敏列表格式 */
    body.print-80mm #printArea .thermal-list {
        display: block;
    }
    body.print-80mm #printArea .table {
        display: none !important;
    }

    body.print-80mm #printArea .card {
        border: none;
        margin: 0;
        padding: 0;
    }
    body.print-80mm #printArea .card-body {
        padding: 3mm;
    }
    body.print-80mm #printArea {
        font-size: 10pt;
        max-width: 68mm;
        margin: 0;
        padding: 0;
    }
    body.print-80mm #printArea h4 {
        font-size: 14pt;
        margin-bottom: 3px;
    }
    body.print-80mm #printArea h5 {
        font-size: 12pt;
        margin-bottom: 3px;
    }
    body.print-80mm #printArea .text-center.mb-3 {
        margin-bottom: 4px !important;
    }
    body.print-80mm #printArea hr {
        margin: 4px 0;
    }
    /* 患者信息两列布局 */
    body.print-80mm #printArea .row.mb-3 > div {
        font-size: 9pt;
        margin-bottom: 1px;
    }
    /* 收费信息 */
    body.print-80mm #printArea .row > div {
        font-size: 9pt;
    }
}

/* ========== 药品搜索自动完成 ========== */
.drug-search-wrapper {
    position: relative;
}

.drug-search-input {
    cursor: pointer;
    background-color: #fff !important;
}

.drug-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    max-height: 240px;
    overflow-y: auto;
    margin-top: 2px;
}

.drug-dropdown-item {
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}

.drug-dropdown-item:last-child {
    border-bottom: none;
}

.drug-dropdown-item:hover,
.drug-dropdown-item.active {
    background: rgba(184, 134, 11, 0.08);
}

.drug-dropdown-item .drug-code {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.72rem;
    margin-right: 0.35rem;
    background: rgba(184, 134, 11, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

.drug-dropdown-item .drug-price {
    float: right;
    color: #c0392b;
    font-weight: 600;
    font-size: 0.78rem;
}

.drug-dropdown-empty {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}
