/* 2026-08-29 提取自 excel/index.php
 * Luckysheet 编辑页专用样式
 * - 顶部状态栏（玻璃质感 / 私有-公开-会员三态）
 * - 浮动按钮（保存/另存为/属性/JSON）
 * - 加载中遮罩
 * - 模态框
 * - 移动端适配
 */

/* =========================================================
 * 2026-08-29 v4：隐藏 Luckysheet 自带的 share-logo / Demo 提示
 *   - .luckysheet-share-logo：底部右侧的"分享/Logo"按钮
 *   - 工具栏右侧的 demo 浮窗
 * ========================================================= */
.luckysheet-share-logo,
.luckysheet-wa-icon,
.luckysheet-info-detail,
#luckysheet-demo-print,
#luckysheet-demo-print div,
.luckysheet-print-area .print,
.luckysheet-demo-div {
    display: none !important;
    visibility: hidden !important;
}

/* 打印时隐藏 luckysheet */
@media print {
    #luckysheet {
        display: none;
    }
    .topbar,
    .float-btn,
    .privacy-badge,
    .id-badge,
    .class-badge,
    .title-wrap {
        display: none !important;
    }
}

/* =========================================================
 * 2026-08-29 v5：属性面板 #infoDiv 浮动在分类徽章/属性按钮下方
 *   - 玻璃质感白底 + 圆角 + 阴影
 *   - 顶部带 X 关闭按钮 + 标题
 *   - 默认隐藏，点击分类徽章或"⚙️ 属性"打开
 * ========================================================= */
#infoDiv {
    display: none;
    position: fixed;
    min-width: 320px;
    max-width: 460px;
    padding: 14px 18px 16px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 13px;
    color: #1f2937;
    line-height: 1.6;
}

#infoDiv::before {
    /* 顶部小箭头，指向徽章/按钮 */
    content: '';
    position: absolute;
    top: -7px;
    left: 28px;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.98);
    border-left: 1px solid rgba(0, 0, 0, 0.06);
    border-top:  1px solid rgba(0, 0, 0, 0.06);
    transform: rotate(45deg);
}

/* 关闭按钮（JS 注入到 #infoDiv 第一个元素） */
.info-close-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 16px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}
.info-close-btn:hover {
    background: #e5e7eb;
    color: #111827;
}

#infoDiv select,
#infoDiv input[type="text"] {
    width: 100%;
    margin-top: 4px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#infoDiv select:focus,
#infoDiv input[type="text"]:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#infoDiv input[type="checkbox"] {
    margin-right: 4px;
    vertical-align: middle;
}

#infoDiv label {
    display: inline-block;
    margin: 6px 0 2px;
    color: #4b5563;
    font-weight: 600;
    font-size: 12px;
}

/* =========================================================
 * 顶部状态栏（玻璃质感 / Glassmorphism）
 * ========================================================= */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    z-index: 9998;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* --- 左：Logo + 标题 --- */
.topbar-logo {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 12px;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    margin-right: 4px;
    font-weight: 700;
    color: #2c3e50;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.topbar-logo .logo-icon {
    font-size: 18px;
}

/* --- 中：隐私徽标 + ID --- */
.topbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: default;
    user-select: none;
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.privacy-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.privacy-badge .privacy-icon {
    font-size: 13px;
    line-height: 1;
}

.privacy-badge.privacy-private {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.privacy-badge.privacy-public {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.privacy-badge.privacy-member {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
}

.privacy-badge.privacy-unknown {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
}

.id-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    background: rgba(44, 62, 80, 0.08);
    color: #34495e;
    font-weight: 500;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    border: 1px solid rgba(0, 0, 0, 0.05);
    white-space: nowrap;
}

.doc-name {
    color: #7f8c8d;
    font-size: 12.5px;
    margin-left: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

/* 2026-08-29：分类徽章 */
.class-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.class-badge.class-empty {
    background: rgba(149, 165, 166, 0.10);
    color: #95a5a6;
    border-color: rgba(149, 165, 166, 0.25);
}

.class-badge.class-set {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.12), rgba(142, 68, 173, 0.08));
    color: #6c3483;
    border-color: rgba(155, 89, 182, 0.25);
}

.class-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.class-badge .class-icon {
    font-size: 13px;
    line-height: 1;
}

/* 2026-08-29：顶部标题输入框（替代原 .doc-name） */
.title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 120px;
    max-width: 420px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.title-wrap:focus-within {
    border-color: rgba(25, 118, 210, 0.5);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.12);
}

.title-wrap .title-icon {
    font-size: 13px;
    line-height: 1;
    opacity: 0.7;
    flex-shrink: 0;
}

.title-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    padding: 2px 0;
    font-family: inherit;
}

.title-input::placeholder {
    color: #95a5a6;
    font-weight: 400;
}

/* --- 右：动作按钮组 --- */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-actions .float-btn {
    position: static;       /* 不再 fixed，由 flex 布局控制 */
    box-shadow: none;
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: 8px;
}

.topbar-actions .float-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.topbar-actions .float-btn.btn-icon {
    padding: 6px 9px;
    font-size: 14px;
}

/* 调整按钮颜色（更柔和，更现代） */
#saveBtn    { background: linear-gradient(135deg, #FF9800, #F57C00); }
#saveAsBtn  { background: linear-gradient(135deg, #FF7043, #F4511E); }
#attrBtn    { background: linear-gradient(135deg, #8E24AA, #7B1FA2); }
#showJsonBtn{ background: linear-gradient(135deg, #43A047, #2E7D32); }
#loadJsonBtn{ background: linear-gradient(135deg, #1E88E5, #1565C0); }

/* =========================================================
 * 不可访问 / 不存在 中央提示
 * ========================================================= */
.access-block {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 16px;
    padding: 48px 56px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
    z-index: 9000;
    max-width: 440px;
    width: calc(100% - 40px);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    border: 1px solid rgba(0, 0, 0, 0.04);
    animation: access-fade-in 0.3s ease;
}

@keyframes access-fade-in {
    from { opacity: 0; transform: translate(-50%, -46%); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

.access-block .access-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 16px;
    display: inline-block;
}

.access-block.access-private .access-icon {
    /* 私有时给锁加个柔光 */
    filter: drop-shadow(0 4px 12px rgba(231, 76, 60, 0.4));
}

.access-block.access-notFound .access-icon {
    filter: drop-shadow(0 4px 12px rgba(149, 165, 166, 0.4));
}

.access-block .access-title {
    font-size: 22px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.access-block .access-msg {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 24px;
    line-height: 1.7;
}

.access-block .access-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.access-block .access-action {
    display: inline-block;
    padding: 10px 24px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.access-block .access-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.access-block .access-action.secondary {
    background: #fff;
    color: #34495e;
    border: 1px solid #dcdfe6;
    box-shadow: none;
}

.access-block .access-action.secondary:hover {
    background: #f5f7fa;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* 不可访问时让 luckysheet 容器隐藏 */
body.access-denied #luckysheet {
    display: none !important;
}

/* 加载中遮罩 */
.loading-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.6);
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-mask .spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #ddd;
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================================
 * 浮动按钮（兼容直接放在 .topbar 之外的情况）
 * ========================================================= */
.float-btn {
    position: fixed;
    top: 60px;
    z-index: 9999;
    padding: 8px 14px;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.float-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

#saveBtn     { right: 220px; }
#saveAsBtn   { right: 130px; }
#attrBtn     { right: 40px; }
#showJsonBtn { right: 360px; }
#loadJsonBtn { right: 490px; }

/* =========================================================
 * 属性面板
 * ========================================================= */
#infoDiv {
    position: fixed;
    top: 60px;
    left: 12px;
    z-index: 9999;
    padding: 14px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    min-width: 220px;
    display: none;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#infoDiv select,
#infoDiv input[type="text"] {
    margin-top: 4px;
    margin-bottom: 6px;
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}

#infoDiv label {
    font-size: 13px;
    margin-top: 4px;
    display: inline-block;
}

/* =========================================================
 * 模态框
 * ========================================================= */
.modal-mask {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-box {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    height: 80%;
    overflow: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.modal-box h2 {
    margin-top: 0;
    font-size: 18px;
    color: #333;
}

.modal-box pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 75%;
    overflow: auto;
    background-color: #f5f5f5;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.modal-box textarea {
    width: 100%;
    height: 70%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    resize: none;
    font-size: 13px;
    box-sizing: border-box;
}

.modal-box .btn {
    margin-top: 10px;
    padding: 8px 15px;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.modal-box .btn-primary { background-color: #4CAF50; }
.modal-box .btn-info    { background-color: #2196F3; }
.modal-box .btn-warning { background-color: #FF9800; }

#jsonFileInput { display: none; }

/* =========================================================
 * 加载提示（spinner）
 * ========================================================= */
#loadingIndicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 14px 22px;
    border-radius: 6px;
    z-index: 11000;
    font-family: Arial, sans-serif;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#loadingIndicator .spinner-dot {
    width: 18px;
    height: 18px;
    border: 3px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* =========================================================
 * luckysheet 自身 loading 动画
 * ========================================================= */
@keyframes loading-rotate {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes loading-dash {
    0%   { stroke-dasharray: 1, 200;     stroke-dashoffset: 0; }
    50%  { stroke-dasharray: 90, 150;    stroke-dashoffset: -40px; }
    100% { stroke-dasharray: 90, 150;    stroke-dashoffset: -120px; }
}

.loadingAnimation {
    width: 3em;
    height: 3em;
    animation: loading-rotate 2s linear infinite;
}

.loadingAnimation circle {
    animation: loading-dash 1.5s ease-in-out infinite;
    stroke-dasharray: 90, 150;
    stroke-dashoffset: 0;
    stroke-width: 2;
    stroke: currentColor;
    stroke-linecap: round;
}

/* 顶部栏占位，避免 luckysheet 顶到玻璃栏下方 */
#luckysheet {
    top: 48px !important;
    height: calc(100% - 48px) !important;
}

/* =========================================================
 * 移动端适配
 * ========================================================= */
@media screen and (max-width: 768px) {
    .topbar {
        height: 44px;
        padding: 0 10px;
        gap: 8px;
    }

    .topbar-logo {
        font-size: 13px;
        padding-right: 8px;
    }

    .topbar-logo .logo-text {
        display: none;
    }

    .privacy-badge {
        font-size: 11px;
        padding: 4px 10px;
    }

    .id-badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    .doc-name {
        display: none;
    }

    /* 2026-08-29：移动端标题输入框 */
    .title-wrap {
        max-width: 200px;
    }
    .title-input {
        font-size: 12px;
    }
    .class-badge .class-text {
        max-width: 64px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-actions .float-btn {
        padding: 5px 9px;
        font-size: 11.5px;
    }

    .topbar-actions .float-btn.btn-text {
        display: none;
    }

    #luckysheet {
        top: 44px !important;
        height: calc(100% - 44px) !important;
    }

    #infoDiv {
        top: 54px !important;
        left: 8px !important;
        right: 8px !important;
        font-size: 14px !important;
        padding: 12px !important;
    }

    #infoDiv select,
    #infoDiv input[type="text"] {
        height: 36px;
        font-size: 14px;
    }

    #infoDiv input[type="checkbox"] {
        transform: scale(1.4);
        margin-right: 8px;
    }

    .modal-box {
        width: 95% !important;
        height: 90% !important;
        margin: 2% auto !important;
    }

    .modal-close {
        font-size: 32px !important;
    }

    .access-block {
        padding: 32px 24px;
    }

    .access-block .access-icon {
        font-size: 48px;
    }

    .access-block .access-title {
        font-size: 18px;
    }

    body, html {
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}
