/*
 * 访客预约管理系统 - 公共样式
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
                 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.5;
}

a {
    color: #1a73e8;
    text-decoration: none;
}

/* ==================== 布局 ==================== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ==================== 侧边栏 ==================== */
html:not(.mobile-layout) .sidebar {
    width: 240px;
    min-width: 240px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

html:not(.mobile-layout) .sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

html:not(.mobile-layout) .sidebar-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

html:not(.mobile-layout) .sidebar-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

html:not(.mobile-layout) .sidebar-nav {
    flex: 1;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 15px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.nav-item.active {
    background: rgba(102,126,234,0.15);
    color: #667eea;
    border-left-color: #667eea;
}

.nav-icon {
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 20px;
}

html:not(.mobile-layout) .sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

.user-role {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.logout-btn {
    width: 100%;
    padding: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(255,99,99,0.2);
    border-color: rgba(255,99,99,0.3);
}

/* ==================== 主内容 ==================== */
html:not(.mobile-layout) .main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    color: #1a1a1a;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.current-time {
    color: #888;
    font-size: 14px;
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #1a73e8;
    color: #fff;
}

.btn-primary:hover {
    background: #1557b0;
}

.btn-primary:disabled {
    background: #93b8f0;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-danger {
    background: #e53935;
    color: #fff;
}

.btn-danger:hover {
    background: #c62828;
}

/* ==================== 加载动画 ==================== */
.loading-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

.loading-spinner.show {
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        min-width: 60px;
    }
    .sidebar-title,
    .sidebar-nav .nav-item span:not(.nav-icon),
    .user-info > div,
    .logout-btn {
        display: none;
    }
    .sidebar-header {
        justify-content: center;
        padding: 16px 10px;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    .sidebar-nav .nav-icon {
        margin: 0;
    }
    .main-content {
        margin-left: 60px;
        padding: 16px;
    }
    .user-avatar {
        margin: 0 auto;
    }
}

/* ==================== 工具类 ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-12 { gap: 12px; }

/* ==================== 移动端侧边栏遮罩 ==================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}
.sidebar-overlay.show {
    display: block;
}

/* ==================== 移动端底部导航 ==================== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #eee;
    z-index: 200;
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
.mobile-bottom-nav .nav-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
}
.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    color: #999;
    text-decoration: none;
    font-size: 11px;
    transition: color 0.2s;
    border: none;
    background: none;
    cursor: pointer;
}
.mobile-bottom-nav .nav-item .nav-icon {
    font-size: 20px;
    line-height: 1;
}
.mobile-bottom-nav .nav-item.active {
    color: #1a73e8;
}
.mobile-bottom-nav .nav-item.hidden {
    display: none;
}

/* ==================== 移动端专用 ==================== */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 50;
    background: #1a1a2e;
    color: #fff;
    padding: 12px 16px;
    align-items: center;
    gap: 12px;
}
.mobile-header .menu-btn {
    font-size: 22px;
    cursor: pointer;
    background: none;
    border: none;
    color: #fff;
    padding: 4px;
}
.mobile-header .header-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}
.mobile-header .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== 移动端适配 (html.mobile-layout body 控制, 兼容所有浏览器) ==================== */
html.mobile-layout body {
    overflow-x: hidden;
    width: 100%;
    padding-bottom: 56px;
    -webkit-text-size-adjust: 100%;
}
html.mobile-layout body,
html.mobile-layout body *,
html.mobile-layout body *::before,
html.mobile-layout body *::after {
    box-sizing: border-box;
}

/* 布局容器撑满（移动端改为竖排） */
html.mobile-layout body .layout {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    flex-direction: column;
    display: flex;
}

/* 隐藏桌面侧边栏 */
html.mobile-layout body .sidebar {
    display: none !important;
}

/* 显示移动端顶部栏 */
html.mobile-layout body .mobile-header {
    display: flex;
}

/* 显示底部导航 */
html.mobile-layout body .mobile-bottom-nav {
    display: block;
}

/* 主内容区域 */
html.mobile-layout body .main-content {
    margin-left: 0 !important;
    padding: 12px 14px;
    min-height: auto;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* 移动端弹出侧边栏 */
html.mobile-layout body .sidebar.mobile-show {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100%;
    z-index: 210;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

/* 页面标题 */
html.mobile-layout body .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 14px;
}
html.mobile-layout body .page-header h1 {
    font-size: 18px;
}
html.mobile-layout body .page-header .current-time {
    display: none;
}
html.mobile-layout body .header-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
}
html.mobile-layout body .header-actions .btn {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    font-size: 13px;
    white-space: nowrap;
}

/* 统计卡片网格 2x2 */
html.mobile-layout body .dashboard-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
}
html.mobile-layout body .stat-card {
    padding: 14px;
    border-radius: 12px;
    -webkit-tap-highlight-color: rgba(26,115,232,0.1);
}
html.mobile-layout body .stat-card .stat-value {
    font-size: 22px;
}
html.mobile-layout body .stat-card .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    margin-bottom: 8px;
}

/* 快捷操作卡片堆叠 */
html.mobile-layout body .action-cards {
    grid-template-columns: 1fr !important;
    gap: 10px;
}
html.mobile-layout body .action-card {
    padding: 16px;
    border-radius: 12px;
}

/* 筛选栏 */
html.mobile-layout body .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    width: 100%;
}
html.mobile-layout body .filter-bar .search-input {
    min-width: auto;
    width: 100%;
}
html.mobile-layout body .filter-bar input[type="date"] {
    flex: 1;
    min-width: 0;
    width: 100%;
}
html.mobile-layout body .filter-bar .btn {
    padding: 10px 16px;
}

/* 表格 */
html.mobile-layout body .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    width: 100%;
}
html.mobile-layout body .table-wrap table {
    min-width: 650px;
    font-size: 13px;
}
html.mobile-layout body .table-wrap table th,
html.mobile-layout body .table-wrap table td {
    padding: 10px 8px;
}
html.mobile-layout body .table-wrap .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}
html.mobile-layout body .text-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
html.mobile-layout body .text-actions button {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
}

/* 核验页面 - 桌面端使用固定的双列布局
   移动端使用 @media 响应式控制 */
.verify-layout {
    grid-template-columns: 1fr 1fr !important;
}
html.mobile-layout body .verify-layout {
    grid-template-columns: 1fr !important;
}
html.mobile-layout body .verify-card {
    padding: 16px;
    border-radius: 12px;
    width: 100%;
}
html.mobile-layout body .verify-card h2 {
    font-size: 16px;
    margin-bottom: 14px;
}
html.mobile-layout body .input-group input {
    font-size: 22px;
    padding: 14px;
    border-radius: 10px;
    width: 100%;
}
html.mobile-layout body .verify-btn {
    padding: 14px 20px;
    font-size: 15px;
    border-radius: 10px;
    width: 100%;
}

/* 身份证区域 */
html.mobile-layout body #idCardArea {
    padding: 20px 14px;
    width: 100%;
}
html.mobile-layout body #idCardArea input[type="text"] {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 16px;
    letter-spacing: 2px;
}
html.mobile-layout body #idCardArea > div:last-child {
    flex-direction: column;
    align-items: stretch;
}
html.mobile-layout body #idCardArea > div:last-child button,
html.mobile-layout body #idCardArea button.verify-btn {
    padding: 14px 20px;
    width: 100%;
}
html.mobile-layout body .scan-mode-toggle button {
    padding: 12px 10px;
    font-size: 13px;
}

/* 表单页面 */
html.mobile-layout body .form-row,
html.mobile-layout body .form-row-3 {
    grid-template-columns: 1fr !important;
    gap: 12px;
}
html.mobile-layout body .form-card {
    padding: 16px;
    border-radius: 12px;
    width: 100%;
}
html.mobile-layout body .form-card h2 {
    font-size: 16px;
    margin-bottom: 14px;
    padding-bottom: 12px;
}
html.mobile-layout body .form-group input,
html.mobile-layout body .form-group textarea,
html.mobile-layout body .form-group select {
    padding: 12px;
    font-size: 15px;
    border-radius: 8px;
    width: 100%;
}
html.mobile-layout body .form-group label {
    font-size: 14px;
}
html.mobile-layout body .form-actions {
    flex-direction: column;
    gap: 8px;
}
html.mobile-layout body .form-actions .btn {
    width: 100%;
    padding: 14px;
    font-size: 15px;
}
html.mobile-layout body .companion-item {
    padding: 12px;
    border-radius: 10px;
    width: 100%;
}
html.mobile-layout body .companion-item .form-row {
    gap: 10px;
}

/* 详情弹窗 */
html.mobile-layout body .detail-modal.show {
    align-items: flex-end;
}
html.mobile-layout body .detail-content {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 85vh !important;
    padding: 20px 16px !important;
}
html.mobile-layout body .detail-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
}
html.mobile-layout body .detail-item {
    padding: 8px 0;
}
html.mobile-layout body .detail-item .dvalue {
    font-size: 14px;
}
html.mobile-layout body .detail-item .dlabel {
    font-size: 12px;
}

/* 弹窗 */
html.mobile-layout body .modal.show {
    align-items: flex-end;
}
html.mobile-layout body .modal-content {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px 16px !important;
}

/* 核验结果区域 */
html.mobile-layout body .result-area {
    border-radius: 10px;
    margin-top: 12px;
    width: 100%;
}
html.mobile-layout body .result-area .title {
    font-size: 14px;
    padding: 12px 14px;
}
html.mobile-layout body .result-grid {
    grid-template-columns: 1fr !important;
    gap: 4px;
}
html.mobile-layout body .result-grid .item {
    padding: 6px 14px;
}
html.mobile-layout body .result-grid .item .value {
    font-size: 14px;
}
html.mobile-layout body .result-grid .item .label {
    font-size: 12px;
}

/* QR 扫码 */
html.mobile-layout body #qrcode video {
    max-width: 100% !important;
    border-radius: 8px;
}
html.mobile-layout body #qrcode > div {
    width: 100%;
}

/* API 管理页面 */
html.mobile-layout body .key-card {
    flex-direction: column !important;
    gap: 10px !important;
    padding: 14px !important;
    border-radius: 12px;
    width: 100% !important;
}
html.mobile-layout body .key-card .info .name {
    font-size: 14px;
}
html.mobile-layout body .key-card .info .detail {
    font-size: 12px;
}
html.mobile-layout body .key-card .actions {
    width: 100%;
    justify-content: flex-end;
}
html.mobile-layout body .key-card .actions button {
    padding: 8px 14px;
    font-size: 13px;
}

/* 用户管理表格 */
html.mobile-layout body #usersTable {
    min-width: 500px;
    font-size: 13px;
}
html.mobile-layout body #usersTable th,
html.mobile-layout body #usersTable td {
    padding: 8px 6px;
}

/* 日志弹窗 */
html.mobile-layout body .log-content {
    font-size: 12px;
    padding: 10px;
}

/* 状态标签 */
html.mobile-layout body .status-tag {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 4px;
}

/* 分页控件 */
html.mobile-layout body .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 12px 0;
}
html.mobile-layout body .pagination button {
    padding: 8px 12px;
    font-size: 13px;
}
html.mobile-layout body .pagination .page-info {
    width: 100%;
    text-align: center;
    margin-top: 4px;
    font-size: 12px;
}

/* 小屏手机进一步紧凑 */
html.mobile-layout body.small-phone {
    padding-bottom: 50px;
}
html.mobile-layout body.small-phone .dashboard-grid {
    gap: 8px;
}
html.mobile-layout body.small-phone .stat-card {
    padding: 10px;
    border-radius: 10px;
}
html.mobile-layout body.small-phone .stat-card .stat-value {
    font-size: 18px;
}
html.mobile-layout body.small-phone .stat-card .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
    margin-bottom: 6px;
}
html.mobile-layout body.small-phone .stat-card .stat-label {
    font-size: 11px;
}
html.mobile-layout body.small-phone .main-content {
    padding: 8px 10px;
}
html.mobile-layout body.small-phone .page-header h1 {
    font-size: 17px;
}
html.mobile-layout body.small-phone .filter-bar {
    padding: 10px 12px;
    border-radius: 10px;
}
html.mobile-layout body.small-phone .filter-bar .search-input {
    font-size: 14px;
    padding: 10px;
}
html.mobile-layout body.small-phone .form-card {
    padding: 14px;
    border-radius: 10px;
}
html.mobile-layout body.small-phone .form-group input,
html.mobile-layout body.small-phone .form-group textarea,
html.mobile-layout body.small-phone .form-group select {
    padding: 10px;
    font-size: 14px;
}
html.mobile-layout body.small-phone .verify-card {
    padding: 14px;
}
html.mobile-layout body.small-phone .input-group input {
    font-size: 20px;
    padding: 12px;
}
html.mobile-layout body.small-phone .verify-btn {
    padding: 12px 16px;
    font-size: 14px;
}
html.mobile-layout body.small-phone .key-card {
    padding: 12px !important;
    border-radius: 10px;
}
html.mobile-layout body.small-phone .mobile-header {
    padding: 10px 12px;
}
html.mobile-layout body.small-phone .mobile-header .header-title {
    font-size: 14px;
}
html.mobile-layout body.small-phone .mobile-bottom-nav {
    padding: 4px 0;
}
html.mobile-layout body.small-phone .mobile-bottom-nav .nav-item {
    padding: 2px 4px;
    font-size: 10px;
}
html.mobile-layout body.small-phone .mobile-bottom-nav .nav-item .nav-icon {
    font-size: 18px;
}
html.mobile-layout body.small-phone .table-wrap table th,
html.mobile-layout body.small-phone .table-wrap table td {
    padding: 6px 6px;
    font-size: 12px;
}