/* ========================================
   设备维修档案系统 - 全局样式
   手机端 + PC端 适配
   ======================================== */

/* ---- 基础重置 ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 15px;
    color: #333;
    line-height: 1.6;
    background: #f0f4f8;
    -webkit-font-smoothing: antialiased;
}

a { color: #2b6cb0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- 通用按钮 ---- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, opacity 0.2s;
    font-family: inherit;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: #2b6cb0; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #4a5568; }
.btn-danger { background: #e53e3e; color: #fff; }
.btn-success { background: #38a169; color: #fff; }
.btn-outline { background: transparent; color: #fff; border: 1px solid #fff; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }

/* ---- 通用表单 ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
    color: #4a5568;
}
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
}
.form-input:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}
.form-input:read-only, .form-input[readonly] {
    background: #edf2f7;
    color: #718096;
    cursor: not-allowed;
}
textarea.form-input { resize: vertical; }
.form-hint { font-size: 12px; color: #a0aec0; margin-top: 4px; display: block; }
.form-error { color: #e53e3e; font-size: 14px; margin-top: 6px; }
.required { color: #e53e3e; }
.form-row { display: flex; gap: 16px; }
.form-row > .form-group { flex: 1; }
@media (max-width: 600px) { .form-row { flex-direction: column; gap: 0; } }
/* 设备详情页始终保持双列布局 */
.device-container .form-row { flex-direction: row !important; gap: 12px !important; }
.device-container .form-row .form-group { flex: 1; min-width: 0; }
select.form-input { cursor: pointer; }

/* ---- 弹窗 ---- */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-content h3 { margin-bottom: 12px; font-size: 18px; }
.modal-large { max-width: 680px; }
.modal-small { max-width: 380px; }
.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}
.text-danger { color: #e53e3e; font-weight: 600; }

/* ---- 图片预览 ---- */
.image-preview-small img { max-width: 150px; max-height: 100px; border-radius: 6px; margin-top: 8px; }
.image-full { width: 100%; max-width: 300px; border-radius: 8px; margin-top: 10px; }
.repair-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.repair-images img { max-width: 200px; max-height: 150px; border-radius: 6px; object-fit: cover; cursor: pointer; }
@media (max-width: 480px) { .repair-images img { max-width: 120px; max-height: 100px; } }

/* ========================================
   设备详情页（device.php）- 手机端优先
   ======================================== */
.device-page { background: #edf2f7; }
.device-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    padding-bottom: 100px; /* 给底部按钮留空 */
}

.device-header {
    background: linear-gradient(135deg, #2b6cb0, #2c5282);
    color: #fff;
    padding: 24px 20px;
    text-align: center;
}
.device-header h1 { font-size: 20px; margin-bottom: 8px; }
.device-id-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 14px;
    letter-spacing: 1px;
}

/* 加载提示 */
.loading-box {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
}

/* 错误提示 */
.error-box {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
    padding: 16px;
    margin: 16px;
    border-radius: 8px;
    text-align: center;
}

/* 设备信息卡片 */
.device-info { padding: 20px; }
.info-card {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
}
.info-card h3 {
    font-size: 16px;
    color: #2b6cb0;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ebf4ff;
}
.info-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #edf2f7;
}
.info-row:last-child { border-bottom: none; }
.info-label {
    color: #718096;
    font-size: 14px;
    flex-shrink: 0;
    width: 70px;
}
.info-value { flex: 1; font-size: 15px; color: #2d3748; word-break: break-all; }

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}
.status-待维修 { background: #fef5e7; color: #c05621; }
.status-维修中 { background: #ebf8ff; color: #2b6cb0; }
.status-已完成 { background: #f0fff4; color: #276749; }
.status-已取回 { background: #f7fafc; color: #718096; }

/* 维修记录时间轴 */
.repair-timeline { padding: 0 20px 20px; }
.repair-timeline h3 {
    font-size: 18px;
    color: #2d3748;
    margin-bottom: 16px;
}
.timeline-item {
    position: relative;
    padding-left: 24px;
    padding-bottom: 24px;
    border-left: 2px solid #e2e8f0;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 4px;
    width: 10px;
    height: 10px;
    background: #2b6cb0;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #2b6cb0;
}
.timeline-date {
    font-size: 13px;
    color: #a0aec0;
    margin-bottom: 6px;
}
.timeline-content {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.7;
}
.timeline-actions { margin-top: 8px; text-align: right; }

/* 编辑区域 */
.edit-form-section, .add-repair-section {
    padding: 0 20px 20px;
}
.section-title {
    font-size: 18px;
    color: #2d3748;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

/* 底部按钮区 */
.bottom-actions {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 480px;
    width: 100%;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    text-align: center;
    z-index: 100;
}
.bottom-actions .btn { width: 100%; padding: 14px; font-size: 16px; }

/* ========================================
   后台管理页（admin.php）
   ======================================== */
.admin-page { background: #edf2f7; }

/* 顶部导航 */
.admin-nav {
    background: #2d3748;
    color: #fff;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    height: 56px;
}
.nav-inner h1 { font-size: 18px; white-space: nowrap; }
.nav-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.admin-container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px 40px;
}

/* 工具栏 */
.admin-toolbar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: center;
}
.admin-toolbar .search-box { flex: 1; max-width: 400px; }
.admin-toolbar .search-box input { height: 42px; }

/* 员工管理区域 */
.staff-section {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.staff-section h3 {
    font-size: 17px;
    color: #2d3748;
    margin-bottom: 12px;
}
.staff-toolbar {
    display: flex;
    align-items: center;
}

/* 表格 */
.table-wrapper {
    background: #fff;
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table thead { background: #f7fafc; }
.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 700;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f7fafc; }
.data-table .table-loading { text-align: center; color: #a0aec0; padding: 40px; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
}
.pagination button {
    padding: 8px 14px;
    border: 1px solid #cbd5e0;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: #4a5568;
}
.pagination button:hover { background: #edf2f7; }
.pagination button.active { background: #2b6cb0; color: #fff; border-color: #2b6cb0; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ========================================
   登录页（admin_login.php）
   ======================================== */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #2b6cb0, #2c5282);
}
.login-container {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-container h1 { text-align: center; font-size: 22px; margin-bottom: 4px; color: #2d3748; }
.login-container h2 { text-align: center; font-size: 15px; color: #718096; margin-bottom: 24px; font-weight: normal; }

/* ---- 设备类型标签 ---- */
.type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}
.type-computer { background: #ebf8ff; color: #2b6cb0; }
.type-printer { background: #faf5ff; color: #6b46c1; }

/* ---- 动态配置区域 ---- */
.specs-area {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.specs-title {
    font-size: 15px;
    color: #4a5568;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #e2e8f0;
}

/* ---- 复选框标签 ---- */
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal !important;
    font-size: 15px !important;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ========================================
   响应式适配
   ======================================== */
@media (max-width: 768px) {
    .admin-nav { padding: 0 12px; }
    .nav-inner h1 { font-size: 15px; }
    .nav-right { gap: 6px; font-size: 12px; }
    .nav-right .btn-sm { font-size: 11px; padding: 4px 8px; }
    .admin-container { padding: 0 12px 20px; }
    .admin-toolbar { flex-direction: column; }
    .admin-toolbar .search-box { max-width: 100%; }
    .data-table th, .data-table td { padding: 8px 10px; font-size: 13px; }
    .login-container { margin: 20px; padding: 24px; }
    .modal-large { max-width: 95vw; }
}
