/**
 * General Notes Styles V2 (行囊库)
 * 情境化流式排布 - CSS Columns Masonry
 */

/* ==================== Modal ==================== */
#generalNotesModal {
    display: none;
    position: fixed;
    z-index: 2147483640;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.gn-modal-content {
    background: #F8FAFC;
    width: 95%;
    max-width: 1400px;
    /* 固定高度，避免筛选时跳动 */
    height: 85vh;
    border-radius: 24px;
    border-radius: 24px;
    box-shadow: 0 25px 80px rgba(98, 111, 71, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ==================== Header ==================== */
.gn-modal-header {
    padding: 24px 32px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gn-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.gn-header-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    position: relative;
}

.gn-header-icon .gn-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #EF4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

.gn-header-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: #1E293B;
}

.gn-header-stats {
    display: flex;
    gap: 16px;
    margin-top: 4px;
}

.gn-stat {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #CBD5E1;
    /* 默认未选中颜色（浅灰） */
    transition: all 0.3s;
}

.gn-stat.active {
    font-weight: 800;
    /* 选中加粗 */
    font-size: 0.8rem;
    /* 稍微放大 */
}

/* 仅在选中时应用颜色 */
.gn-stat-note.active {
    color: var(--primary-color);
}

.gn-stat-link.active {
    color: #5D8AA8;
    /* Muted Blue for distinct contrast */
}

.gn-stat-image.active {
    color: #DAA55D;
    /* Darker shade of accent for text visibility */
}

.gn-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #F1F5F9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #64748B;
    transition: all 0.2s;
}

.gn-close-btn:hover {
    background: #E2E8F0;
    color: #1E293B;
}

/* ==================== Toolbar ==================== */
.gn-toolbar {
    padding: 16px 32px;
    background: #fff;
    border-top: 1px solid #F1F5F9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* 左右分离 */
    gap: 24px;
}

.gn-filter-group {
    display: flex;
    background: transparent;
    border-radius: 0;
    padding: 0;
    height: 40px;
    box-sizing: border-box;
    gap: 8px;
    /* 增加按钮间距 */
}

.gn-filter-btn {
    padding: 0 16px;
    /* 增加内边距 */
    height: 40px;
    /* 与搜索框等高 */
    border-radius: 20px;
    /* 圆角胶囊样式 */
    border: none;
    background: transparent;
    color: #64748B;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.gn-filter-btn i {
    font-size: 0.9rem;
}

.gn-filter-btn:hover {
    color: #1E293B;
}

.gn-filter-btn.active {
    background: #fff;
    color: #0F172A;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    /* 更柔和的阴影 */
    border: 1px solid #E2E8F0;
    /* 增加边框 */
}

/* 右侧操作组 */
.gn-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
    /* 靠右对齐 */
}

.gn-search-box {
    width: 320px;
    /* 固定宽度，不再占据剩余所有空间 */
    position: relative;
    max-width: 100%;
}

.gn-search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94A3B8;
}

.gn-search-input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 40px;
    border: none;
    /* 去除边框 */
    border-radius: 20px;
    /* 胶囊圆角 */
    font-size: 0.9rem;
    background: #F8FAFC;
    /* 浅灰背景 */
    transition: all 0.2s;
    box-sizing: border-box;
    color: #334155;
    /* 强制去除外部可能存在的 margin */
    margin: 0;
}

.gn-search-input:focus {
    outline: none;
    background: #F1F5F9;
    /* focus时稍微加深背景 */
}

.gn-search-input::placeholder {
    color: #94A3B8;
}

.gn-add-btn {
    height: 40px;
    padding: 0 20px;
    border-radius: 12px;
    border: none;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.gn-add-btn:hover {
    background: #334155;
    transform: translateY(-1px);
}

/* ==================== Masonry Container (CSS Multi-column) ==================== */
.gn-items-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 32px;
    /* 核心：CSS Multi-column 垂直填充布局 */
    column-count: 3;
    column-gap: 20px;
}

.gn-items-container::-webkit-scrollbar {
    width: 6px;
}

.gn-items-container::-webkit-scrollbar-track {
    background: transparent;
}

.gn-items-container::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

/* ==================== Cards ==================== */
.gn-card {
    /* 断裂预防：卡片不可分割 */
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    /* 垂直间距 */
    margin-bottom: 20px;
    /* 基础样式 */
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #E2E8F0;
    position: relative;
    transition: all 0.25s ease;
    box-sizing: border-box;
    /* 确保完整性 */
    display: inline-block;
    width: 100%;
}

.gn-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.gn-card:hover .gn-card-actions {
    opacity: 1;
    transform: translateY(0);
}

/* Card type colors - Earth Tone Mapping */
.gn-card.gn-card-text {
    border-left: 4px solid var(--primary-color);
    /* Sage */
    background: linear-gradient(135deg, #F9FBEF 0%, #FFF 50%);
}

.gn-card.gn-card-link {
    border-left: 4px solid #5D8AA8;
    /* Muted Blue */
    background: linear-gradient(135deg, #F0F7FA 0%, #FFF 50%);
    /* Blue tint bg */
}

.gn-card.gn-card-image {
    border-left: 4px solid var(--accent-color);
    /* Warm Orange */
    background: linear-gradient(135deg, #FFF8ED 0%, #FFF 50%);
}

/* Pinned badge */
.gn-pinned-badge {
    position: absolute;
    top: -8px;
    left: 16px;
    background: #EF4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Card header */
.gn-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.gn-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.gn-icon-text {
    background: #F0F4E8;
    color: var(--primary-color);
}

.gn-icon-link {
    background: #E6F0F5;
    color: #5D8AA8;
}

.gn-icon-image {
    background: #FFF4E0;
    color: #DAA55D;
    /* Darker Accent */
}

.gn-card-title-group {
    flex: 1;
    min-width: 0;
    /* 标题安全区：右侧预留 40px 给操作按钮 */
    padding-right: 40px;
}

.gn-card-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1E293B;
    /* 自动截断 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gn-card-date {
    font-size: 0.75rem;
    color: #94A3B8;
    margin-top: 2px;
}

/* Card content */
.gn-card-content {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 12px;
    word-break: break-word;
}

.gn-card-link {
    display: block;
    font-size: 0.85rem;
    color: #3B82F6;
    text-decoration: none;
    word-break: break-all;
    line-height: 1.5;
    margin-bottom: 12px;
}

.gn-card-link:hover {
    text-decoration: underline;
}

.gn-card-image {
    width: 100%;
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: transform 0.2s;
}

.gn-card-image:hover {
    transform: scale(1.02);
}

/* Card footer */
.gn-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gn-card-type {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 8px;
}

.gn-card.gn-card-text .gn-card-type {
    background: #F0F4E8;
    color: var(--primary-color);
}

.gn-card.gn-card-link .gn-card-type {
    background: #E6F0F5;
    color: #5D8AA8;
}

.gn-card.gn-card-image .gn-card-type {
    background: #FFF4E0;
    color: #DAA55D;
}

/* Card actions (hover) - Z轴悬浮控制器 */
.gn-card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    /* 默认隐藏 */
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    /* Z轴隔离 */
    z-index: 10;
    pointer-events: none;
}

.gn-card:hover .gn-card-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.gn-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.15s;
}

.gn-pin-btn {
    background: #F0F4E8;
    color: var(--primary-color);
}

.gn-pin-btn:hover {
    background: #DBEAFE;
}

.gn-pin-btn.pinned {
    background: #3B82F6;
    color: white;
}

.gn-edit-btn {
    background: #F0FDF4;
    color: #22C55E;
}

.gn-edit-btn:hover {
    background: #DCFCE7;
}

.gn-delete-btn {
    background: #FEF2F2;
    color: #EF4444;
}

.gn-delete-btn:hover {
    background: #FEE2E2;
}

/* ==================== Empty State ==================== */
/* ==================== Empty State ==================== */
.gn-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 0 20px;
    color: #94A3B8;
}

.gn-empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: #F1F5F9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #CBD5E1;
}

.gn-empty-state h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    color: #64748B;
}

.gn-empty-add-btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    background: #1E293B;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.gn-empty-add-btn:hover {
    background: #334155;
}

/* ==================== Add Form Modal ==================== */
#gnAddFormModal {
    display: none;
    position: fixed;
    z-index: 2147483645;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

.gn-form-content {
    background: #fff;
    width: 90%;
    max-width: 800px;
    /* 加大弹窗宽度 */
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(0);
    animation: gnFormSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

@keyframes gnFormSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Type Selector */
.gn-type-selector {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.gn-type-btn {
    flex: 1;
    height: 56px;
    padding: 0;
    border-radius: 16px;
    border: none;
    background: #F8FAFC;
    color: #94A3B8;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.gn-type-btn i {
    font-size: 1.1rem;
}

.gn-type-btn:hover {
    background: #F1F5F9;
    color: #64748B;
}

/* Active States for Types */
.gn-type-btn.active[data-type="TEXT"] {
    background: #F0F4E8;
    color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color) inset;
}

.gn-type-btn.active[data-type="LINK"] {
    background: #E6F0F5;
    color: #5D8AA8;
    box-shadow: 0 0 0 2px #5D8AA8 inset;
}

.gn-type-btn.active[data-type="IMAGE"] {
    background: #FFF4E0;
    color: #DAA55D;
    box-shadow: 0 0 0 2px var(--accent-color) inset;
}

/* Inputs */
.gn-form-group {
    margin-bottom: 20px;
}

.gn-form-input {
    width: 100%;
    padding: 20px 24px;
    border-radius: 16px;
    border: none;
    background: #F8FAFC;
    color: #334155;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    box-sizing: border-box;
    transition: all 0.2s;
}

.gn-form-input::placeholder {
    color: #CBD5E1;
    font-weight: 600;
}

.gn-form-input:focus {
    outline: none;
    background: #F1F5F9;
    box-shadow: 0 0 0 4px rgba(241, 245, 249, 0.5);
}

.gn-form-textarea {
    min-height: 240px;
    /* 加高输入框 */
    resize: none;
    line-height: 1.6;
}

.gn-image-upload-area {
    border: 2px dashed #E2E8F0;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #F8FAFC;
}

.gn-image-upload-area:hover {
    border-color: #CBD5E1;
    background: #F1F5F9;
}

.gn-image-upload-area:focus {
    outline: none;
    border-color: #3B82F6;
    background: #F0F9FF;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.gn-image-upload-area i {
    font-size: 2rem;
    color: #CBD5E1;
    margin-bottom: 12px;
}

.gn-image-upload-area p {
    margin: 0;
    color: #94A3B8;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Actions Footer */
.gn-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 8px;
}

/* Status Label */
.gn-form-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #CBD5E1;
    transition: color 0.3s;
}

.gn-status-dot {
    font-size: 0.6rem;
    transition: color 0.3s;
}

/* Dynamic Status Colors */
.gn-form-status.status-text {
    color: #A8A29E;
}

.gn-form-status.status-text .gn-status-dot {
    color: var(--primary-color);
}

.gn-form-status.status-link {
    color: #A8A29E;
}

.gn-form-status.status-link .gn-status-dot {
    color: #5D8AA8;
}

.gn-form-status.status-image {
    color: #A8A29E;
}

.gn-form-status.status-image .gn-status-dot {
    color: var(--accent-color);
}

#gnFormStatusType {
    text-transform: uppercase;
}

/* Buttons */
.gn-btn-save {
    padding: 14px 32px;
    border-radius: 12px;
    border: none;
    background: var(--primary-color);
    /* 默认浅灰，符合图2风格 */
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.gn-btn-save:hover {
    background: var(--primary-light);
    color: #fff;
}

/* 如果需要取消按钮样式 */
.gn-btn-cancel {
    background: transparent;
    color: #94A3B8;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

.gn-btn-cancel:hover {
    background: #F1F5F9;
    color: #64748B;
}

.gn-btn-save {
    font-family: 'Inter', sans-serif;
}

/* ==================== Image Preview ==================== */
.gn-image-preview-modal {
    position: fixed;
    z-index: 2147483650;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.gn-image-preview-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.gn-image-preview-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    cursor: default;
}

.gn-image-preview-content button {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
}

/* ==================== Responsive ==================== */
@media (max-width: 1200px) {
    .gn-items-container {
        column-count: 2;
    }
}

@media (max-width: 700px) {
    .gn-items-container {
        column-count: 1;
    }

    .gn-toolbar {
        flex-wrap: wrap;
    }

    .gn-search-box {
        order: 3;
        flex-basis: 100%;
        margin-top: 12px;
    }
}