/* ============================================================
   Dreamanual 全站 - 公共样式库
   适用于首页和所有工具页面
   ============================================================ */

/* ===== 颜色变量（Tailwind v4 语义化灰度） ===== */
:root {
    /* 灰度色阶 — 映射自 Tailwind v4 Slate */
    --gray-1:  var(--tw-slate-900);
    --gray-3:  var(--tw-slate-800);
    --gray-6:  var(--tw-slate-500);
    --gray-14: var(--tw-slate-200);
    --gray-15: var(--tw-slate-50);

    /* 品牌/功能色 — 映射自 Tailwind v4 */
    --blue:    var(--tw-blue-700);
    --orange:  var(--tw-orange-500);
    --focus:   var(--tw-blue-500);
    --white:   #FFFFFF;

    /* 字体 */
    --font-base: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace;
    --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== 基础重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: var(--font-base);
    background: var(--gray-15);
    color: var(--gray-1);
    -webkit-font-smoothing: antialiased;
}

body {
    overflow-x: hidden;
}

/* ===== 卡片 ===== */
.gc-card {
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--tw-neutral-200);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Tab 面板切换 */
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: flex;
}

/* ===== 页面标题区（新设计 - 色板专用） ===== */
.gc-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gc-title {
    font-size: 28px;
    line-height: 42px;
    font-weight: 700;
    color: var(--gray-1);
}

.gc-subtitle {
    font-size: 14px;
    line-height: 20px;
    color: var(--tw-slate-400);
    font-family: var(--font-en);
    font-weight: 500;
}

/* ===== Tab 导航 ===== */
.gc-tab-bar {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0;
    padding: 8px;
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--tw-neutral-200);
    flex-wrap: nowrap;
    align-self: flex-start;
}

.gc-tab {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    color: var(--tw-slate-500);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: none;
    background: transparent;
    font-family: inherit;
}

.gc-tab:hover {
    color: var(--gray-1);
}

.gc-tab.active {
    background: var(--gray-1);
    color: var(--white);
    font-weight: 600;
}

/* ===== 区块标题 ===== */
.gc-section-title {
    font-size: 18px;
    line-height: 28px;
    font-weight: 700;
    color: var(--gray-3);
}

.gc-section-hint {
    font-size: 12px;
    line-height: 18px;
    color: var(--tw-slate-400);
}

/* ===== 输入框（新设计） ===== */
.gc-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 200px;
    height: 40px;
    padding: 0 12px;
    background: var(--tw-slate-50);
    border: 1px solid var(--tw-slate-200);
    border-radius: 12px;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    box-sizing: border-box;
}

.gc-input-wrap:focus-within {
    background: var(--white);
    border-color: var(--focus);
}

.gc-input-hash,
.gc-input-unit {
    font-size: 14px;
    line-height: 18px;
    color: var(--tw-slate-400);
    user-select: none;
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.gc-input-field {
    flex: 1;
    height: 100%;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--gray-3);
    font-size: 14px;
    line-height: 18px;
    font-family: var(--font-mono);
    outline: none;
    text-align: left;
    letter-spacing: 1px;
}

.gc-input-preview {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.gc-input-preview-lg {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
    border: 1px solid var(--tw-slate-200);
}

/* ===== 输入框（旧设计 - 栅格计算器兼容） ===== */
.gc-inputs-row {
    display: flex;
    gap: 24px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.gc-input-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 200px;
    flex-shrink: 0;
}

/* 确保 .gc-input-wrap 在 .gc-input-group 内自适应宽度 */
.gc-input-group .gc-input-wrap {
    width: 100%;
}

.gc-input-label {
    font-size: 14px;
    line-height: 22px;
    color: var(--tw-slate-900);
    text-align: left;
    margin-bottom: 12px;
    white-space: nowrap;
}

.gc-input {
    width: 200px;
    height: 40px;
    padding: 0 12px;
    background: var(--tw-slate-50);
    border: 1px solid var(--tw-slate-200);
    border-radius: 12px;
    color: var(--tw-slate-900);
    font-size: 14px;
    line-height: 22px;
    font-family: var(--font-mono);
    outline: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    text-align: left;
    -moz-appearance: textfield;
    box-sizing: border-box;
}

.gc-input:focus {
    background: var(--tw-white);
    border-color: var(--focus);
}
.gc-input::-webkit-outer-spin-button,
.gc-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 当 .gc-input 被包裹在 .gc-input-wrap 内时，去除自身边框与背景 */
.gc-input-wrap .gc-input {
    background: transparent;
    border: none;
    border-radius: 0;
    width: auto;
    flex: 1;
    padding: 0;
}

.gc-input-note {
    font-size: 12px;
    line-height: 18px;
    color: var(--tw-slate-500);
    margin-top: 12px;
    text-align: left;
    white-space: nowrap;
}

/* ===== 提示文字 ===== */
.gc-hint {
    font-size: 12px;
    line-height: 18px;
    color: var(--tw-slate-500);
    text-align: left;
    margin-top: 8px;
}

/* ===== 计算结果（旧设计 - 栅格计算器兼容） ===== */
.gc-results-row {
    display: flex;
    gap: 16px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.gc-result-item {
    background: var(--tw-slate-50);
    border: 1px solid var(--tw-slate-200);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 100px;
    flex-shrink: 0;
}

.gc-result-item .gc-result-value {
    font-size: 16px;
    line-height: 22px;
    color: var(--tw-slate-900);
    font-weight: 700;
    font-family: var(--font-mono);
}

.gc-result-item .gc-result-label {
    font-size: 12px;
    line-height: 16px;
    color: var(--tw-slate-400);
    margin-top: 4px;
}

/* ===== 结果卡片（新设计 - 色板专用） ===== */
.gc-result-card {
    width: 120px;
    height: 92px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    background: var(--tw-slate-50);
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid var(--tw-slate-200);
    flex-shrink: 0;
}

.gc-result-card.accent {
    background: var(--tw-blue-50);
}

.gc-result-card .gc-result-label {
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    color: var(--tw-slate-400);
    font-family: var(--font-en);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 16px;
    display: flex;
    align-items: center;
}

.gc-result-card .gc-result-value {
    font-size: 18px;
    line-height: 24px;
    color: var(--gray-3);
    font-family: var(--font-mono);
    font-weight: 700;
    height: 24px;
    display: flex;
    align-items: center;
}

.gc-result-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    margin-top: 4px;
    line-height: 16px;
}

.gc-result-badge.ok {
    background: var(--tw-blue-100);
    color: var(--tw-blue-700);
}

.gc-result-badge.adjusted {
    background: var(--tw-blue-100);
    color: var(--tw-blue-700);
}

/* 映射色阶卡片专用 */
.gc-result-card.map {
    gap: 4px;
}

.gc-result-card.map .map-label {
    font-size: 11px;
    line-height: 16px;
    font-weight: 500;
    color: var(--tw-blue-500);
    font-family: var(--font-en);
    letter-spacing: 0.55px;
    height: 16px;
    display: flex;
    align-items: center;
}

.gc-result-card.map .map-value {
    font-size: 18px;
    line-height: 24px;
    color: var(--tw-blue-700);
    font-family: var(--font-mono);
    font-weight: 700;
    height: 24px;
    display: flex;
    align-items: center;
}

.gc-result-card.map .map-status {
    font-size: 10px;
    line-height: 16px;
    color: var(--tw-blue-400);
    height: 16px;
    display: flex;
    align-items: center;
}

/* ===== 色板表格 ===== */
.tw-palette-wrap {
    width: 100%;
}

.tw-palette-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: max-content;
}

.tw-palette-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tw-palette-header-name {
    width: 64px;
    flex-shrink: 0;
}

.tw-palette-header-shades {
    display: flex;
    gap: 4px;
    flex: 1;
}

.tw-palette-shade-label {
    flex: 1;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 12px;
    line-height: 16px;
    color: var(--tw-slate-400);
    border-radius: 8px;
    font-family: var(--font-mono);
    min-width: 48px;
}

.tw-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tw-color-name {
    width: 64px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 14px;
    line-height: 16px;
    color: var(--tw-slate-400);
    border-radius: 8px;
    font-family: var(--font-en);
    font-weight: 700;
    padding-right: 8px;
}

.tw-color-swatches {
    display: flex;
    gap: 4px;
    flex: 1;
}

.tw-color-swatch {
    flex: 1;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    position: relative;
    min-width: 48px;
}

.tw-color-swatch:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 20;
}

/* 色块 tooltip */
.tw-color-swatch .swatch-tooltip,
.cp-hue-cell .cell-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: var(--tw-slate-900);
    color: #FFFFFF;
    padding: 12px 16px;
    border-radius: 12px;
    font-family: var(--font-mono);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.15s ease;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.tooltip-shade {
    font-size: 14px;
    line-height: 18px;
    color: var(--tw-slate-400);
    font-weight: 400;
}

.tooltip-hex {
    font-size: 16px;
    line-height: 22px;
    color: #FFFFFF;
    font-weight: 600;
}

.tw-color-swatch:hover .swatch-tooltip,
.cp-hue-cell:hover .cell-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* ===== 同明度/APCA 色块网格 ===== */
.cp-hue-grid {
    display: grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 4px;
    width: 100%;
}

.cp-hue-cell {
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    position: relative;
    min-width: 0;
}

.cp-hue-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 20;
}

/* ===== Toast ===== */
.cp-toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-1);
    color: var(--white);
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    pointer-events: none;
}

.cp-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== 底部备案 ===== */
.page-footer {
    display: flex;
    gap: 32px;
    padding-top: 8px;
}

.page-footer span,
.page-footer a {
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    color: var(--tw-slate-400);
    text-decoration: none;
}

/* ===== 栅格预览（仅栅格计算器使用） ===== */
.gc-grid-preview {
    display: flex;
    width: 100%;
    padding: 0;
    justify-content: flex-start;
    align-items: stretch;
    margin-top: 16px;
    background: var(--gray-15);
    border-radius: 8px;
    overflow: hidden;
}

.gc-col-bar {
    background: rgba(29, 78, 216, 0.15);
    border: 1px solid var(--blue);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
    margin: 16px 0;
    overflow: hidden;
    min-height: 64px;
}
.gc-col-bar:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}

.gc-col-num {
    font-size: 14px;
    line-height: 22px;
    color: var(--gray-1);
    font-weight: 600;
    transition: opacity 0.15s ease;
}

.gc-gutter {
    flex-shrink: 0;
    align-self: stretch;
}

.gc-margin-bar {
    background: rgba(255, 105, 0, 0.15);
    border-radius: 0;
    flex-shrink: 0;
    align-self: stretch;
}
.gc-margin-bar:first-child {
    border-right: 2px dashed var(--orange);
}
.gc-margin-bar:last-child {
    border-left: 2px dashed var(--orange);
}

/* tooltip */
.gc-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-1);
    color: var(--white);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}
.gc-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--gray-1);
}
.gc-col-bar:hover .gc-tooltip {
    opacity: 1;
}

/* ===== 响应式 ===== */
@media (max-width: 1023px) {
    .gc-card {
        padding: 24px;
    }

    .gc-tab-bar {
        flex-wrap: wrap;
    }

    .gc-tab {
        padding: 10px 16px;
        font-size: 13px;
    }

    .tw-color-name,
    .tw-palette-header-name {
        width: 56px;
        font-size: 12px;
    }

    .tw-palette-shade-label {
        font-size: 11px;
        min-width: 36px;
    }

    .tw-color-swatch,
    .cp-hue-cell {
        height: 36px;
    }

    .gc-inputs-row { gap: 16px; }
    .gc-input-group { width: 160px; }
    .gc-input-wrap { width: 160px; }
    .gc-results-row { gap: 10px; }
}

@media (max-width: 767px) {
    .gc-title-area {
        gap: 2px;
        margin-bottom: 0;
    }

    .gc-title {
        font-size: 24px;
        line-height: 32px;
    }

    .gc-subtitle {
        font-size: 12px;
        line-height: 18px;
    }

    .gc-card {
        padding: 16px;
        border-radius: 12px;
        gap: 16px;
    }

    .gc-section-title {
        font-size: 16px;
        line-height: 24px;
    }

    .gc-section-hint {
        font-size: 11px;
        line-height: 16px;
    }

    .gc-tab-bar {
        padding: 4px;
        border-radius: 10px;
        gap: 4px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        align-self: stretch;
        display: flex;
    }

    .gc-tab {
        flex: 1;
        padding: 8px 0;
        font-size: 12px;
        line-height: 18px;
        text-align: center;
        justify-content: center;
    }

    .smartmap-results {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        justify-content: flex-start;
    }

    .smartmap-results .gc-result-card {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .tw-palette-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tw-palette-wrap::-webkit-scrollbar {
        display: none;
    }

    .smartmap-input-row {
        gap: 8px;
        width: 100%;
    }

    .smartmap-input-row .gc-input-wrap {
        flex: 1;
        width: auto;
    }

    .gc-input-preview-lg {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .gc-input-wrap {
        height: 36px;
        border-radius: 10px;
    }

    .gc-input-field {
        font-size: 13px;
    }

    .gc-result-card {
        width: 100px;
        height: 84px;
        padding: 12px 14px;
    }

    .gc-result-card .gc-result-label {
        font-size: 10px;
        height: 14px;
    }

    .gc-result-card .gc-result-value {
        font-size: 16px;
        line-height: 22px;
        height: 22px;
    }

    .gc-result-card.map .map-label {
        height: 14px;
    }

    .gc-result-card.map .map-value {
        height: 22px;
    }

    .gc-result-card.map .map-status {
        height: 14px;
    }

    .smartmap-results {
        gap: 8px;
    }

    .tw-color-name,
    .tw-palette-header-name {
        width: 48px;
        font-size: 11px;
    }

    .tw-palette-shade-label {
        min-width: 32px;
        font-size: 10px;
    }

    .tw-color-swatch,
    .cp-hue-cell {
        height: 32px;
        border-radius: 8px;
    }

    .apca-input-row {
        gap: 8px;
        flex-wrap: wrap;
    }

    .apca-preview-lg {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .apca-input-box {
        width: 160px;
        height: 36px;
        border-radius: 10px;
    }

    .apca-lc-box {
        width: 160px;
        height: 36px;
        border-radius: 10px;
    }

    .gc-inputs-row {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
        align-items: flex-start;
        justify-content: flex-start;
    }
    .gc-input-group {
        width: calc(50% - 6px);
        flex-shrink: 0;
    }
    .gc-input-group .gc-input-wrap {
        width: 100%;
    }
    .gc-input-note {
        white-space: normal;
    }
    .gc-results-row {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        align-items: stretch;
    }
    .gc-result-item {
        flex: 1;
        width: auto;
        min-width: 0;
        max-width: none;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
    }
    .gc-result-item .gc-result-label { margin-top: 4px; margin-left: 0; }
    .gc-grid-preview { overflow-x: auto; }
}
