/* ============================================================
   交互式元素周期表侧面板 - 样式
   ============================================================ */

/* 触发按钮 */
#pt-toggle-btn {
    position: fixed;
    bottom: 130px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(99,102,241,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}
#pt-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99,102,241,0.6);
}

/* 遮罩层 */
#pt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1001;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}
#pt-overlay.active {
    display: block;
    opacity: 1;
}

/* 侧面板 */
#pt-panel {
    position: fixed;
    top: 0;
    right: -480px;
    width: 440px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 1002;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#pt-panel.active {
    right: 0;
}

/* 面板头部 */
#pt-panel .pt-header {
    padding: 16px 20px;
    border-bottom: 2px solid #6366f1;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
#pt-panel .pt-header h3 {
    margin: 0;
    font-size: 18px;
    color: #6366f1;
    white-space: nowrap;
}
#pt-panel .pt-header .pt-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
#pt-panel .pt-header .pt-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* 搜索栏 */
.pt-search-wrap {
    padding: 12px 20px;
    flex-shrink: 0;
}
.pt-search-wrap input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}
.pt-search-wrap input:focus {
    border-color: #6366f1;
}

/* 图例 */
.pt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 8px 20px;
    flex-shrink: 0;
    font-size: 11px;
}
.pt-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.pt-legend .pt-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

/* 网格滚动区 */
.pt-grid-scroll {
    flex: 1;
    overflow: auto;
    padding: 4px 16px 20px;
    -webkit-overflow-scrolling: touch;
}

/* 周期表网格 - 18列 + 1 列标签 */
.pt-grid {
    display: grid;
    grid-template-columns: 28px repeat(18, 1fr);
    gap: 2px;
    min-width: 380px;
    font-size: 11px;
}

/* 行标签 */
.pt-row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #999;
    font-size: 13px;
    padding: 2px;
}
.pt-row-label.pt-la,
.pt-row-label.pt-ac {
    color: #f59e0b;
}

/* 空白填充单元 */
.pt-empty {
    background: transparent;
    min-height: 48px;
}

/* 元素方块 */
.pt-cell {
    border-radius: 4px;
    padding: 2px;
    text-align: center;
    cursor: pointer;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    position: relative;
    overflow: hidden;
}
.pt-cell:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 5;
}
.pt-cell .pt-z {
    font-size: 9px;
    line-height: 1;
    opacity: 0.7;
}
.pt-cell .pt-symbol {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.1;
}
.pt-cell .pt-name {
    font-size: 9px;
    line-height: 1.1;
    opacity: 0.8;
}

/* 高亮匹配 */
.pt-cell.pt-highlight {
    filter: brightness(1.2);
    box-shadow: 0 0 0 2px #ef4444;
    z-index: 3;
}

/* 模糊未匹配 */
.pt-cell.pt-dim {
    opacity: 0.25;
    filter: grayscale(0.6);
}

/* ---- 按分类着色 ---- */
.pt-cat-alkali-metal        { background: #ff6b6b; color: #fff; }
.pt-cat-alkaline-earth      { background: #ffa94d; color: #fff; }
.pt-cat-transition-metal    { background: #ffd43b; color: #333; }
.pt-cat-post-transition-metal { background: #69db7c; color: #1f3a1a; }
.pt-cat-metalloid           { background: #4dabf7; color: #fff; }
.pt-cat-nonmetal            { background: #20c997; color: #fff; }
.pt-cat-halogen             { background: #da77f2; color: #fff; }
.pt-cat-noble-gas           { background: #748ffc; color: #fff; }
.pt-cat-lanthanide          { background: #f783ac; color: #fff; }
.pt-cat-actinide            { background: #e64980; color: #fff; }

/* ---- 元素详情区 ---- */
#pt-detail {
    flex-shrink: 0;
    border-top: 2px solid #e0e0e0;
    background: #fafafa;
    padding: 14px 20px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}
#pt-detail.visible {
    display: block;
}
#pt-detail .pt-det-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
#pt-detail .pt-det-symbol {
    font-size: 32px;
    font-weight: 700;
    color: #6366f1;
}
#pt-detail .pt-det-name {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}
#pt-detail .pt-det-en {
    font-size: 13px;
    color: #888;
}
#pt-detail table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}
#pt-detail table td {
    padding: 4px 8px;
    border-bottom: 1px solid #eee;
}
#pt-detail table td:first-child {
    color: #888;
    width: 70px;
    white-space: nowrap;
}
#pt-detail .pt-det-insert {
    margin-top: 8px;
    padding: 6px 16px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
#pt-detail .pt-det-insert:hover {
    background: #4f46e5;
}

/* 移动端适配 */
@media (max-width: 768px) {
    #pt-panel {
        width: 100vw;
        right: -100vw;
    }
    #pt-toggle-btn {
        bottom: 135px;
        right: 16px;
        width: 42px;
        height: 42px;
        font-size: 18px;
    }
}
