/* public/logbook.css */

/* ============================================================
   1. 全局基础设置
   ============================================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background: #f9f9f9;
    color: #333;
    line-height: 1.6;
}

/* 强制全局容器 98% 宽度 */
.container {
    max-width: 98% !important; 
    margin: 20px auto;
    padding: 20px;
    box-sizing: border-box;
}

/* 顶部导航栏 */
.header {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 10px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.header-content {
    max-width: 98% !important; 
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}
.header h1 {
    margin: 0;
    font-size: 24px;
    color: #007bff;
}
.user-info {
    display: flex;
    align-items: center;
}
.user-info span {
    margin-right: 15px;
    font-size: 16px;
}
#logout-button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}
#logout-button:hover { background: #c82333; }


/* ============================================================
   2. 通用表单样式
   ============================================================ */
.form-container {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}
.form-container h2 {
    margin-top: 0;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}
label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 14px;
}

/* 基础输入框样式 (所有) */
input[type="text"], input[type="password"], input[type="datetime-local"], input[type="date"],
input[type="number"], select, textarea {
    padding: 0 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    height: 38px !important; /* 强制统一高度 */
}
textarea { height: auto !important; min-height: 80px; padding: 8px; resize: vertical; }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
.form-field { display: flex; flex-direction: column; flex-grow: 1; flex-basis: 0; min-width: 50px; }

/* 按钮组 */
.form-buttons { margin-top: 20px; display: flex; gap: 10px; }
button {
    background: #007bff; color: white; padding: 8px 15px;
    border: none; border-radius: 4px; cursor: pointer; font-size: 14px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
}
button:hover { background: #0056b3; }
#clear-form-button { background: #6c757d; }

/* 功率按钮组特殊处理 */
.form-row-power { display: flex; align-items: stretch; height: 38px; }
.power-buttons { display: flex; flex-direction: column; flex-basis: 30px; margin-right: 5px; gap: 2px; }
.power-buttons button { flex: 1; padding: 0 8px; font-size: 10px; background: #6c757d; border: none; border-radius: 2px; cursor: pointer; color: white; }
.power-input { flex: 1; }
.power-input input { height: 100%; width: 100%; }
.power-btn-active { background: #007bff !important; }

/* ============================================================
   3. 【核心】Logbook 页面布局与尺寸
   ============================================================ */
.list-controls {
    display: flex;
    justify-content: space-between; /* 关键：将左右两部分分开 */
    gap: 10px;
    align-items: center;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
#controls-left { display: flex; align-items: center; } 
#controls-right { display: flex; align-items: center; gap: 10px; }
.control-group { display: flex; align-items: center; }

/* Logbook 搜索栏硬编码尺寸 */
#limit-select    { width: 100px !important; } /* 页数选择: 100px */
#search-callsign { width: 200px !important; } /* 搜索呼号: 200px */
#search-date     { width: 150px !important; } /* 日期选择: 150px */

/* Logbook 录入表单：允许占满右侧栏的格子，但不超过 100% */
#log-form input[type="text"], 
#log-form input[type="number"], 
#log-form input[type="datetime-local"], 
#log-form select,
#log-form textarea {
    width: 100% !important;
}


/* ============================================================
   4. 【核心】Profile 页面尺寸
   ============================================================ */

/* Identity & Account */
#phone, #callsign             { width: 200px !important; } /* 手机号 / 呼号: 200px */
#old_password, #new_password, #question1, #answer1 { width: 300px !important; } /* 统一宽度：密码和安全问题 (300px) */
#lotw_username, #lotw_password { width: 200px !important; } /* LoTW 账号 / 密码: 200px */
#qrz_api_key                  { width: 500px !important; } /* QRZ API Key: 500px */

/* Station Profiles - 表单 */
#profile_name { width: 300px !important; } /* 模板名称: 300px */

/* Station Profiles - 参数输入框统一 140px (覆盖所有短/中长参数) */
.station-field-group input {
    width: 140px !important;
}

/* Station Profiles - 已保存模板列表宽度 */
.station-item {
    width: 250px !important; /* 已保存模板宽度: 250px */
}


/* ============================================================
   5. 表格 & 其他辅助样式
   ============================================================ */
.log-list-container {
    background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.list-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 2px solid #007bff; padding-bottom: 10px;
}
.export-button {
    background: #28a745; 
    color: white;
    font-size: 14px;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: 4px;
    height: 38px; 
    display: inline-flex;
    align-items: center;
}
.export-button:hover { background: #218838; }
.table-wrapper { overflow-x: auto; }
#log-table { width: 100%; border-collapse: collapse; margin-top: 20px; }

#log-table th,
#log-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left; /* 默认靠左，具体内容居中由 JS 添加 .text-center 类控制 */
    font-size: 14px;
    white-space: nowrap;
}

/* 强制表头全部居中 */
#log-table th { 
    background: #f4f4f4; 
    text-align: center !important; 
}

.text-center { text-align: center !important; }
.result-message { margin-top: 15px; padding: 10px; border-radius: 4px; display: none; }
.result-message.success { background: #d4edda; color: #155724; display: block; }
.result-message.error { background: #f8d7da; color: #721c24; display: block; }

/* 动作按钮 (默认用于图标，固定尺寸) */
.action-button, .delete-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;  
    height: 28px; 
    padding: 0;   
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

/* ------------------------------------------------------------
   【新增】Admin / Callbooks 按钮样式修复
   ------------------------------------------------------------ */

/* 1. 确保表格操作列居中对齐 */
#user-table td:last-child, 
#callbooks-table td:last-child {
    text-align: center;
    vertical-align: middle; /* 垂直居中 */
}

/* 2. 按钮容器：使用 Flexbox 确保按钮组居中且间距一致 */
.admin-action-group {
    display: flex;
    justify-content: center; /* 水平居中 */
    align-items: center;
    gap: 6px; /* 按钮间距 */
}

/* 3. 按钮内容：覆盖 action-button 的固定尺寸，使其适应文本内容 */
.admin-action-group .action-button {
    width: auto !important;
    height: auto !important;
    padding: 6px 8px !important; /* 标准化内边距，确保统一外观 */
    font-size: 12px !important; /* 紧凑型字体 */
    white-space: nowrap; /* 防止按钮内容换行 */
}

/* 4. 修复 Admin 按钮颜色 */
.admin-action-group .reset-password-button { background: #ffc107; color: #333; }
.admin-action-group .reset-password-button:hover { background: #e0a800; }
.admin-action-group .toggle-role-button { background: #17a2b8; }
.admin-action-group .toggle-role-button:hover { background: #138496; }
.admin-action-group .action-button-edit { background: #17a2b8; color: white; } /* Callbooks Edit Button */
.admin-action-group .action-button-edit:hover { background: #138496; }

.icon-svg { width: 16px; height: 16px; fill: currentColor; }

/* ============================================================
   6. 积分流水弹窗样式 (Modal)
   ============================================================ */
/* 遮罩层 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000; /* 最高层级 */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 弹窗主体 */
.modal-container {
    background-color: #fff;
    width: 400px;
    max-width: 90%;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    overflow: hidden;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

/* 弹窗头部 */
.modal-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
}
.modal-close-btn:hover { color: #333; }

/* 弹窗内容列表 */
.modal-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* 列表项 (复用之前的样式逻辑) */
.log-item {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f1f1;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.log-item:last-child { border-bottom: none; }
.log-item:hover { background-color: #fcfcfc; }

.log-info { display: flex; flex-direction: column; gap: 4px; }
.log-reason { font-weight: 500; color: #333; }
.log-date { color: #999; font-size: 12px; }

.log-amount { font-weight: bold; font-size: 14px; }
.amount-plus { color: #28a745; } /* 绿色 + */
.amount-minus { color: #dc3545; } /* 红色 - */

/* 状态提示 */
.modal-loading, .modal-empty {
    padding: 30px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* --- 状态圆点样式 --- */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

/* 三种状态颜色 */
.status-dot.empty {
    background-color: #dc3545; /* 红 */
    box-shadow: 0 0 4px rgba(220, 53, 69, 0.4);
}
.status-dot.template {
    background-color: #28a745; /* 绿 */
    box-shadow: 0 0 4px rgba(40, 167, 69, 0.4);
}
.status-dot.manual {
    background-color: #007bff; /* 蓝 */
    box-shadow: 0 0 4px rgba(0, 123, 255, 0.4);
}

/* --- 底部图例说明样式 --- */
.station-legend {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end; /* 靠右显示 */
    gap: 15px;
    font-size: 12px;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ============================================================
   7. 【新增】数据维护工具栏样式 (5列布局)
   ============================================================ */

/* 维护工具栏容器 */
.maintenance-toolbar {
    display: grid;
    /* 桌面端强制 5 列 */
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-top: 10px;
}

/* 单个微卡片 */
.tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 5px;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    text-align: center;
    position: relative;
    min-height: 90px; /* 统一高度 */
}

/* 悬停效果 */
.tool-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #007bff;
}

/* 点击反馈 */
.tool-item:active {
    transform: scale(0.98);
}

/* 图标样式 */
.tool-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

/* 标题样式 */
.tool-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
}

/* 描述小字 (可选) */
.tool-desc {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    transform: scale(0.9);
}

/* --- 颜色区分 (增强识别度) --- */
/* 模板下载 (灰色/中立) */
.tool-item.type-template .tool-icon { filter: grayscale(100%); opacity: 0.7; }
/* CSV (绿色系) */
.tool-item.type-csv-in { border-bottom: 3px solid #28a745; }
.tool-item.type-csv-out { border-bottom: 3px solid #1e7e34; }
/* ADIF (蓝色系) */
.tool-item.type-adif-in { border-bottom: 3px solid #17a2b8; }
.tool-item.type-adif-out { border-bottom: 3px solid #007bff; }

/* 移动端适配：屏幕小于 768px 时变为 2列 或 3列，防止挤压 */
@media (max-width: 768px) {
    .maintenance-toolbar {
        grid-template-columns: repeat(3, 1fr); /* 手机端 3列布局 */
    }
    /* 让最后两个元素自动填补空缺，或者保持网格 */
}
@media (max-width: 480px) {
    .maintenance-toolbar {
        grid-template-columns: repeat(2, 1fr); /* 小屏手机 2列 */
    }
}