/**
 * Excel 2016 UI 样式表
 * 纯 CSS 实现的 Excel 2016 界面仿制，不依赖任何外部图片
 * 包含：Ribbon 工具栏、公式栏、单元格网格、行号列标、Sheet 标签栏、状态栏、伪装模式、弹窗
 */

/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f3f3f3;
    font-size: 13px;
    color: #333;
}

/* ========== Excel 主容器 ========== */
#excel-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100% - 60px);
    background-color: #ffffff;
    border: 1px solid #d4d4d4;
}

/* ========== Ribbon 工具栏 ========== */
.ribbon {
    display: flex;
    align-items: center;
    height: 28px;
    background-color: #217346;
    color: #ffffff;
    padding: 0 8px;
    font-size: 13px;
    flex-shrink: 0;
}

.ribbon-tab {
    padding: 4px 10px;
    margin-right: 2px;
    cursor: default;
    border-radius: 2px;
    transition: background-color 0.15s;
    user-select: none;
}

.ribbon-tab:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.ribbon-tab.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* Ribbon 右侧添加自选股按钮 */
.ribbon-add-btn {
    padding: 4px 14px;
    margin-left: auto;
    background-color: rgba(255, 255, 255, 0.18);
    border-radius: 2px;
    cursor: default;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    user-select: none;
    transition: background-color 0.15s;
}

.ribbon-add-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.ribbon-toolbar {
    display: flex;
    align-items: center;
    height: 60px;
    background-color: #f3f3f3;
    border-bottom: 1px solid #d4d4d4;
    padding: 0 8px;
    flex-shrink: 0;
    overflow: hidden;
}

.ribbon-group {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 8px;
    border-right: 1px solid #d4d4d4;
}

.ribbon-group:last-child {
    border-right: none;
}

.ribbon-group-label {
    position: absolute;
    bottom: 2px;
    font-size: 11px;
    color: #666;
}

.ribbon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 2px;
    border-radius: 2px;
    cursor: default;
    color: #333;
    font-size: 11px;
    transition: background-color 0.15s;
    user-select: none;
}

.ribbon-btn:hover {
    background-color: rgba(33, 115, 70, 0.1);
}

.ribbon-btn-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #217346;
}

/* ========== 公式栏 ========== */
.formula-bar {
    display: flex;
    align-items: center;
    height: 24px;
    border-bottom: 1px solid #d4d4d4;
    background-color: #ffffff;
    flex-shrink: 0;
}

.formula-name {
    width: 80px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #d4d4d4;
    font-size: 13px;
    color: #333;
}

.formula-input {
    flex: 1;
    height: 100%;
    border: none;
    outline: none;
    padding: 0 8px;
    font-size: 13px;
    background-color: #ffffff;
    color: #333;
}

/* ========== 表格区域 ========== */
.sheet-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #ffffff;
}

/* 列标 */
.col-headers {
    display: flex;
    position: absolute;
    top: 0;
    left: 30px;
    right: 0;
    height: 20px;
    background-color: #f3f3f3;
    border-bottom: 1px solid #d4d4d4;
    overflow: hidden;
    z-index: 2;
}

.col-header {
    min-width: 100px;
    max-width: 100px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #d4d4d4;
    font-size: 12px;
    color: #666;
    user-select: none;
}

/* 行号 */
.row-headers {
    position: absolute;
    top: 20px;
    left: 0;
    bottom: 0;
    width: 30px;
    background-color: #f3f3f3;
    border-right: 1px solid #d4d4d4;
    overflow: hidden;
    z-index: 2;
}

.row-header {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e0e0e0;
    font-size: 12px;
    color: #666;
    user-select: none;
}

/* 单元格网格 */
.cell-grid {
    position: absolute;
    top: 20px;
    left: 30px;
    right: 0;
    bottom: 0;
    overflow: auto;
    z-index: 1;
}

.cell-row {
    display: flex;
    height: 28px;
}

.cell {
    min-width: 100px;
    max-width: 100px;
    height: 28px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
    color: #333;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    user-select: none;
    background-color: #ffffff;
}

.cell.header-cell {
    background-color: #217346;
    color: #ffffff;
    font-weight: 600;
    cursor: default;
}

.cell.col-name {
    background-color: #f3f3f3;
    font-weight: 600;
    color: #333;
}

/* 涨跌颜色 */
.cell.up {
    color: #e33d3d;
}

.cell.down {
    color: #28a745;
}

.cell.flat {
    color: #666;
}

/* 删除按钮 */
.cell.action-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.delete-btn {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    color: #999;
    font-size: 16px;
    font-weight: 600;
    cursor: default;
    transition: all 0.15s;
    user-select: none;
}

.delete-btn:hover {
    background-color: #e33d3d;
    color: #ffffff;
}

/* 空状态添加按钮 */
.empty-cell {
    text-align: center;
}

.empty-add-btn {
    display: inline-block;
    padding: 8px 24px;
    border: 2px dashed #217346;
    border-radius: 4px;
    color: #217346;
    font-size: 15px;
    font-weight: 600;
    cursor: default;
    user-select: none;
    transition: all 0.15s;
}

.empty-add-btn:hover {
    background-color: #217346;
    color: #ffffff;
    border-style: solid;
}

/* ========== 伪装层 ========== */
.disguise-overlay {
    position: absolute;
    top: 20px;
    left: 30px;
    right: 0;
    bottom: 0;
    background-color: #ffffff;
    display: none;
    z-index: 3;
    overflow: auto;
}

.disguise-overlay.active {
    display: block;
}

.disguise-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.disguise-table th {
    background-color: #217346;
    color: #ffffff;
    padding: 6px 8px;
    text-align: left;
    border: 1px solid #1a5c38;
    font-weight: 600;
}

.disguise-table td {
    padding: 6px 8px;
    border: 1px solid #d4d4d4;
    color: #333;
}

/* ========== Sheet 标签栏 ========== */
.sheet-tabs {
    display: flex;
    align-items: center;
    height: 28px;
    background-color: #f3f3f3;
    border-top: 1px solid #d4d4d4;
    padding: 0 4px;
    flex-shrink: 0;
}

.sheet-tab {
    padding: 4px 16px;
    margin-right: 2px;
    cursor: default;
    font-size: 13px;
    color: #333;
    border-radius: 2px 2px 0 0;
    transition: background-color 0.15s;
    user-select: none;
}

.sheet-tab:hover {
    background-color: rgba(33, 115, 70, 0.1);
}

.sheet-tab.active {
    background-color: #ffffff;
    border: 1px solid #d4d4d4;
    border-bottom: none;
    font-weight: 600;
}

.sheet-tab-add {
    padding: 4px 12px;
    cursor: default;
    font-size: 16px;
    color: #217346;
    border-radius: 2px;
    transition: background-color 0.15s;
    user-select: none;
}

.sheet-tab-add:hover {
    background-color: rgba(33, 115, 70, 0.1);
}

/* ========== 状态栏 ========== */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 22px;
    background-color: #217346;
    color: #ffffff;
    padding: 0 8px;
    font-size: 12px;
    flex-shrink: 0;
}

.status-text {
    user-select: none;
}

.status-time {
    user-select: none;
}

/* ========== 底部广告位 ========== */
.ad-banner {
    width: 100%;
    height: 60px;
    background-color: #f9f9f9;
    border-top: 1px solid #d4d4d4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ad-banner.hidden {
    display: none;
}

/* ========== 弹窗通用样式 ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 400px;
    max-width: 500px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #217346;
    color: #ffffff;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    font-size: 20px;
    cursor: default;
    user-select: none;
    padding: 0 4px;
}

.modal-close:hover {
    color: rgba(255, 255, 255, 0.7);
}

.modal-body {
    padding: 20px 16px;
}

/* ========== 赞赏码弹窗 ========== */
.donation-text {
    text-align: center;
    font-size: 14px;
    color: #333;
    margin-bottom: 16px;
}

.donation-codes {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 16px;
}

.donation-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.donation-qr {
    width: 160px;
    height: 160px;
    border: 1px solid #d4d4d4;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9f9f9;
    margin-bottom: 8px;
}

.qr-placeholder {
    font-size: 12px;
    color: #999;
}

.donation-label {
    font-size: 13px;
    color: #333;
}

.donation-thanks {
    text-align: center;
    font-size: 13px;
    color: #666;
}

/* ========== 添加自选股弹窗 ========== */
.add-symbol-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    color: #333;
    font-weight: 600;
}

.form-input {
    height: 36px;
    padding: 0 12px;
    border: 1px solid #d4d4d4;
    border-radius: 2px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus {
    border-color: #217346;
}

.form-hint {
    font-size: 12px;
    color: #999;
    min-height: 16px;
}

.form-hint.error {
    color: #e33d3d;
}

.form-hint.success {
    color: #28a745;
}

.form-btn {
    height: 36px;
    background-color: #217346;
    color: #ffffff;
    border: none;
    border-radius: 2px;
    font-size: 14px;
    cursor: default;
    transition: background-color 0.15s;
    margin-top: 8px;
}

.form-btn:hover {
    background-color: #1a5c38;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .ribbon-toolbar {
        height: 48px;
    }

    .ribbon-btn {
        width: 40px;
        height: 40px;
    }

    .cell {
        min-width: 80px;
        max-width: 80px;
        font-size: 12px;
    }

    .col-header {
        min-width: 80px;
        max-width: 80px;
    }

    .donation-codes {
        flex-direction: column;
        gap: 16px;
    }

    .modal-content {
        min-width: 90%;
        max-width: 90%;
    }
}
