/* =========================================
   诊所接诊系统 - 完整样式
   扁平 · 干净 · 专业 · 响应式
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
}

/* =========================================
   登录页
   ========================================= */
.login-wrapper {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    text-align: center;
}
.login-icon { font-size: 48px; margin-bottom: 10px; }
.login-box h1 { font-size: 24px; color: var(--gray-800); margin-bottom: 4px; font-weight: 700; }
.subtitle { color: var(--gray-400); font-size: 13px; margin-bottom: 28px; }
.form-group { text-align: left; margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 6px; }
.form-group input {
    width: 100%; padding: 11px 14px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
    font-size: 14px; transition: border-color .15s, box-shadow .15s; background: white;
}
.form-group input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
    outline: none;
}
.btn-login {
    width: 100%; padding: 12px; background: linear-gradient(135deg, #667eea, #764ba2);
    border: none; border-radius: var(--radius-sm); color: white; font-size: 15px;
    font-weight: 500; cursor: pointer; transition: opacity .15s;
}
.btn-login:hover { opacity: 0.9; }
.alert { padding: 12px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.footer-text { margin-top: 24px; font-size: 12px; color: var(--gray-300); }

/* =========================================
   侧边栏 (系统内)
   ========================================= */
.sidebar {
    position: fixed; left: 0; top: 0; width: 220px; height: 100vh;
    background: var(--gray-900); display: flex; flex-direction: column; z-index: 100;
}
.sidebar-brand {
    padding: 20px; color: white; font-size: 15px; font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.sidebar-brand-icon { font-size: 22px; }
.sidebar-brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: rgba(255,255,255,0.6);
    text-decoration: none; font-size: 14px; transition: all .15s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: white; background: rgba(255,255,255,0.05); }
.sidebar-nav a.active {
    color: white; background: rgba(79,70,229,0.2);
    border-left-color: var(--primary-light); font-weight: 500;
}
.sidebar-footer {
    padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
    display: flex; gap: 12px;
}
.sidebar-footer a {
    color: rgba(255,255,255,0.4); text-decoration: none; font-size: 12px;
}
.sidebar-footer a:hover { color: rgba(255,255,255,0.7); }

/* =========================================
   主区域
   ========================================= */
.main-wrap { margin-left: 220px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    background: white; border-bottom: 1px solid var(--gray-200);
    padding: 0 28px; height: 56px; display: flex; align-items: center;
    justify-content: flex-end; gap: 16px; flex-shrink: 0;
}
.topbar-user { font-size: 13px; color: var(--gray-500); display: flex; align-items: center; gap: 6px; }
.main-content { flex: 1; padding: 28px; }

/* =========================================
   共用组件
   ========================================= */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 600; color: var(--gray-900); }
.page-header p { font-size: 13px; color: var(--gray-400); margin-top: 2px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: white; border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); border: 1px solid var(--gray-100);
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon { font-size: 28px; margin-bottom: 10px; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.qa-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 20px; background: var(--primary); color: white;
    border-radius: var(--radius-sm); text-decoration: none; font-size: 13px;
    font-weight: 500; transition: background .15s; border: none; cursor: pointer;
}
.qa-btn:hover { background: #4338ca; }
.qa-btn-outline { background: white; color: var(--primary); border: 1px solid var(--primary); }
.qa-btn-outline:hover { background: var(--primary-bg); }

.table-card {
    background: white; border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--gray-100); overflow: hidden;
}
.table-card h3 {
    font-size: 14px; font-weight: 600; color: var(--gray-700);
    padding: 16px 20px; border-bottom: 1px solid var(--gray-100); margin: 0;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--gray-400);
    text-transform: uppercase; letter-spacing: 0.05em;
    background: var(--gray-50); border-bottom: 1px solid var(--gray-100);
    text-align: left; white-space: nowrap;
}
tbody td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--gray-50); color: var(--gray-600); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }
.action-link { color: var(--primary); text-decoration: none; font-size: 13px; font-weight: 500; margin-right: 8px; }
.action-link:hover { color: #4338ca; }

.form-card {
    background: white; border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow); border: 1px solid var(--gray-100);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-group-ctl { margin-bottom: 0; }
.form-group-ctl label {
    display: block; font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 6px;
}
.form-group-ctl input, .form-group-ctl textarea, .form-group-ctl select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm); font-size: 14px; color: var(--gray-700);
    background: white; transition: border-color .15s, box-shadow .15s;
}
.form-group-ctl input:focus, .form-group-ctl textarea:focus, .form-group-ctl select:focus {
    border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); outline: none;
}
.form-group-ctl textarea { min-height: 72px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--gray-100); }

.btn-submit {
    padding: 9px 24px; background: var(--primary); color: white;
    border: none; border-radius: var(--radius-sm); font-size: 14px;
    font-weight: 500; cursor: pointer; transition: background .15s;
}
.btn-submit:hover { background: #4338ca; }
.btn-cancel {
    padding: 9px 24px; background: white; color: var(--gray-500);
    border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
    font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn-cancel:hover { border-color: var(--gray-300); }

.settings-card {
    background: white; border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow); border: 1px solid var(--gray-100); max-width: 500px;
}
.settings-card .info-row {
    padding: 10px 0; border-bottom: 1px solid var(--gray-50);
    display: flex; justify-content: space-between; font-size: 14px;
}
.settings-card .info-row:last-child { border-bottom: none; }
.settings-card .info-label { color: var(--gray-400); }
.settings-card .info-value { color: var(--gray-700); font-weight: 500; }

/* =========================================
   响应式
   ========================================= */
@media (max-width: 768px) {
    .sidebar { position: static; width: 100%; height: auto; }
    .sidebar-nav { display: flex; padding: 4px 0; overflow-x: auto; width: 100%; }
    .sidebar-nav a { border-left: none; white-space: nowrap; padding: 10px 14px; font-size: 13px; }
    .sidebar-nav a.active { border-left-color: transparent; border-bottom: 3px solid var(--primary-light); }
    .sidebar-footer { border-top: none; }
    .main-wrap { margin-left: 0; }
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-num { font-size: 20px; }
    .form-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
    .login-box { padding: 30px 20px; }
    .login-box h1 { font-size: 20px; }
    .form-group input { font-size: 16px; }
}

@media (max-width: 480px) {
    .sidebar-nav a { padding: 8px 10px; font-size: 12px; gap: 4px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .quick-actions { flex-direction: column; }
    .quick-actions .qa-btn { justify-content: center; }
    .login-box { padding: 24px 16px; }
}
/* 滑动验证码 */
.captcha-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.captcha-box { background: white; border-radius: 12px; padding: 24px; text-align: center; max-width: 360px; width: 90%; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.captcha-box h3 { font-size: 16px; margin-bottom: 16px; color: #333; }
.captcha-slider-wrap { position: relative; width: 100%; height: 44px; background: #f0f0f0; border-radius: 22px; overflow: hidden; user-select: none; touch-action: none; }
.captcha-slider-track { position: absolute; left: 0; top: 0; height: 100%; width: 0; background: linear-gradient(90deg, #667eea, #764ba2); border-radius: 22px; transition: none; }
.captcha-slider-btn { position: absolute; left: 0; top: -2px; width: 48px; height: 48px; background: white; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,0.2); cursor: grab; display: flex; align-items: center; justify-content: center; font-size: 18px; z-index: 2; }
.captcha-slider-btn:active { cursor: grabbing; }
.captcha-hint { font-size: 14px; line-height: 44px; color: #999; pointer-events: none; }
.captcha-success { color: #27ae60; font-weight: bold; padding: 12px; }
.captcha-fail { color: #e74c3c; font-size: 14px; margin-top: 10px; }
.captcha-close { margin-top: 12px; padding: 8px 20px; background: none; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; font-size: 13px; color: #666; }
.captcha-hidden { display: none; }
/* 滑动验证码 */
.captcha-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.captcha-box { background: white; border-radius: 12px; padding: 24px; text-align: center; max-width: 360px; width: 90%; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.captcha-box h3 { font-size: 16px; margin-bottom: 16px; color: #333; }
.captcha-slider-wrap { position: relative; width: 100%; height: 44px; background: #f0f0f0; border-radius: 22px; overflow: hidden; user-select: none; touch-action: none; }
.captcha-slider-track { position: absolute; left: 0; top: 0; height: 100%; width: 0; background: linear-gradient(90deg, #667eea, #764ba2); border-radius: 22px; transition: none; }
.captcha-slider-btn { position: absolute; left: 0; top: -2px; width: 48px; height: 48px; background: white; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,0.2); cursor: grab; display: flex; align-items: center; justify-content: center; font-size: 18px; z-index: 2; }
.captcha-slider-btn:active { cursor: grabbing; }
.captcha-hint { font-size: 14px; line-height: 44px; color: #999; pointer-events: none; }
.captcha-success { color: #27ae60; font-weight: bold; padding: 12px; }
.captcha-fail { color: #e74c3c; font-size: 14px; margin-top: 10px; }
.captcha-close { margin-top: 12px; padding: 8px 20px; background: none; border: 1px solid #ddd; border-radius: 6px; cursor: pointer; font-size: 13px; color: #666; }
.captcha-hidden { display: none; }
