/**
 * 公共样式 - 工具栏、筛选面板、模态框等
 * 用于 home.html 和 map_tianditu.html
 */

/* CSS 变量 */
:root {
    --primary: #409eff;
    --primary-dark: #337ecc;
    --danger: #f56c6c;
    --success: #67c23a;
    --warning: #e6a23c;
    --text: #303133;
    --text-light: #909399;
    --border: #dcdfe6;
    --bg: #f5f5f5;
    --white: #ffffff;
    --toolbar-bg: rgba(255, 255, 255, 0.85);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* 搜索框 */
.search-box, .search-container {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}
.search-box input, .search-container input {
    width: 320px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-size: 14px;
    color: #475569;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box input:focus, .search-container input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1), var(--shadow);
    outline: none;
}

/* 搜索建议下拉容器 */
.suggests {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* 建议项样式 */
.suggest-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background-color 0.2s ease;
}
.suggest-item:hover,
.suggest-item.active {
    background: rgba(64, 158, 255, 0.08);
}
.suggest-item:last-child {
    border-bottom: none;
}

/* 空态提示 */
.suggest-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* 建议项标题 */
.suggest-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 关键词高亮 */
.suggest-highlight {
    color: #409eff;
    font-weight: bold;
}

/* 建议项地址 */
.suggest-address {
    font-size: 12px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 20px;
}

/* 定位图标 */
.suggest-icon {
    color: #409eff;
    font-size: 14px;
}

/* 滚动条 */
.suggests::-webkit-scrollbar {
    width: 6px;
}
.suggests::-webkit-scrollbar-thumb {
    background: #dcdfe6;
    border-radius: 3px;
}

/* 切换地图按钮 - 护眼优化 */
.switch-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    padding: 8px 16px;
    background: rgba(180, 170, 200, 0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(150, 140, 180, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    color: #475569;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.2s;
}
.switch-btn:hover {
    background: rgba(140, 130, 170, 0.75);
    color: white;
    border-color: transparent;
}

/* 登录按钮区 */
.login-btns {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    display: flex;
    gap: 10px;
}
.login-btn {
    padding: 8px 20px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}
.login-btn:hover {
    background: var(--primary-dark);
}
.login-btn.secondary {
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
}
.login-btn.secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* 坐标面板 - 隐身模式（水印态） */
.coords-panel {
    position: absolute;
    bottom: 30px;
    right: 10px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.35);
    padding: 6px 10px;
    border-radius: 4px;
    box-shadow: none;
    font-size: 12px;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.7);
}

.beian-bar {
    position: fixed;
    bottom: 8px;
    right: 10px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
}
.beian-bar a {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-family: monospace;
    color: #888;
    text-decoration: none;
}
.beian-bar a:hover {
    color: #bbb;
}
.beian-bar img {
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

/* ========== 工具栏样式 ========== */
.toolbar {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.65);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-radius: 0 12px 12px 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s;
    min-width: 60px;
}
.toolbar.collapsed {
    transform: translateY(-50%) translateX(-100%);
}
.toolbar-toggle {
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.06);
    font-size: 12px;
    color: var(--text-light);
}
.toolbar-toggle:hover {
    color: var(--primary);
}

/* 筛选面板 */
.filter-panel {
    display: none;
    padding: 15px;
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    max-height: 400px;
    overflow-y: auto;
}
.filter-panel.show {
    display: block;
}
.filter-panel h4 {
    margin: 10px 0 8px;
    font-size: 13px;
    color: var(--text-light);
    font-weight: normal;
}
.filter-panel h4:first-child {
    margin-top: 0;
}
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.filter-checkbox:hover {
    background: var(--bg);
}
.filter-checkbox input {
    cursor: pointer;
}
.filter-date {
    display: flex;
    gap: 8px;
}
.filter-date input {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    width: 130px;
}
.filter-btn {
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}
.filter-btn:hover {
    background: var(--primary-dark);
}

/* 工具栏菜单 */
.toolbar-menu {
    list-style: none;
    margin: 0;
    padding: 10px 0;
}
.toolbar-menu li {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: bold;
    color: var(--text);
    transition: background 0.2s;
}
.toolbar-menu li:hover {
    background: rgba(0, 0, 0, 0.04);
}
.toolbar-menu li a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.toolbar-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* 用户信息区 */
.toolbar-user {
    padding: 12px 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.toolbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.06);
}
.toolbar-username {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 未读徽章 */
.unread-badge {
    background: var(--danger);
    color: var(--white);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

/* ========== 模态框通用样式 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.modal.show {
    display: flex;
}
.modal-content {
    background: var(--white);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* ========== 图集面板样式 ========== */
.album-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 350px;
    height: 100%;
    background: var(--toolbar-bg);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}
.album-panel.show {
    transform: translateX(0);
}
.album-panel-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.album-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.album-panel-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    background: none;
    border: none;
    line-height: 1;
}
.album-panel-close:hover {
    color: var(--text);
}
.album-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* 照片网格 */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.photo-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
}
.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}
.photo-item:hover img {
    transform: scale(1.05);
}

/* 照片统计 */
.photo-count {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--white);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .toolbar {
        top: auto;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 12px 12px 0 0;
        width: 100%;
        max-width: 400px;
        overflow: visible;
    }
    .toolbar.collapsed {
        transform: translateX(-50%);
        max-height: 36px;
        overflow: hidden;
    }
    .toolbar-toggle {
        position: relative;
        display: block;
        right: auto;
        top: auto;
        transform: none;
        width: 100%;
        height: 32px;
        border-radius: 12px 12px 0 0;
        text-align: center;
        font-size: 16px;
        line-height: 32px;
    }
    .toolbar-body {
        max-height: 70vh;
        overflow-y: auto;
        overflow-x: hidden;
        transition: max-height 0.3s ease, opacity 0.3s ease;
        opacity: 1;
    }
    .toolbar.collapsed .toolbar-body {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
    }
    .search-box input, .search-container input {
        width: 200px;
    }
    .album-panel {
        width: 100%;
    }
    /* 坐标面板不被底部工具栏遮挡 */
    .coords-panel {
        bottom: 85px;
    }
    /* 筛选面板限高，防止遮满屏幕 */
    .filter-panel {
        max-height: 55vh;
        overflow-y: auto;
    }
    /* 全面屏手势安全区：防止底部手势条与工具栏按钮重叠 */
    .toolbar {
        padding-bottom: env(safe-area-inset-bottom);
    }
    /* 软键盘弹起时隐藏底部工具栏内容区，防止安卓将其顶到屏幕中间，但保留拨片按钮 */
    body:has(input:focus, textarea:focus) .toolbar .toolbar-body {
        display: none !important;
    }
}

/* 横屏时工具栏进一步压缩高度 */
@media (max-width: 768px) and (orientation: landscape) {
    .toolbar {
        max-height: 85vh;
    }
}

/* ========== 网站 Logo ========== */
#site-logo-box {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    transition: opacity 0.2s;
}
#site-logo-box img {
    height: 12vh;
    max-width: 500px;
    width: auto;
    display: block;
    border-radius: 6px;
    pointer-events: none;
    user-select: none;
}
#site-logo-close {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
    user-select: none;
    opacity: 0;
    transition: opacity 0.15s;
}
#site-logo-box:hover #site-logo-close {
    opacity: 1;
}
#site-logo-close:hover {
    background: rgba(0,0,0,0.7);
}
