/*
 * MinDoc 首页卡片样式
 * 支持三种展示模式：Grid(网格) / List(列表) / Card(大卡片)
 * 使用与主题统一的配色方案
 */

/* ========================================
   Header 视图样式下拉菜单
   ======================================== */
.manual-header .navbar-nav > li.view-toggle-nav {
    display: flex;
    align-items: center;
    height: 60px;
    padding: 0 10px;
}

.view-style-dropdown {
    position: relative;
}

.view-style-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--tech-bg-secondary);
    border: 1px solid var(--tech-border);
    border-radius: var(--tech-radius);
    color: var(--tech-text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 36px;
    line-height: 1;
    white-space: nowrap;
}

.view-style-btn:hover {
    background: var(--tech-bg-tertiary);
    border-color: var(--tech-accent);
}

.view-style-btn .fa-chevron-down {
    font-size: 10px;
    color: var(--tech-text-muted);
    transition: transform 0.2s ease;
}

.view-style-dropdown.open .view-style-btn .fa-chevron-down {
    transform: rotate(180deg);
}

.view-style-icon {
    color: var(--tech-accent);
}

/* 下拉菜单 */
.view-style-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    min-width: 180px;
    padding: 8px 0;
    border: 1px solid var(--tech-border);
    border-radius: var(--tech-radius-lg);
    box-shadow: var(--tech-shadow-lg);
    background: var(--tech-bg-card);
    z-index: 1000;
}

.view-style-menu .dropdown-header {
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--tech-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: transparent;
}

.view-style-menu .divider {
    height: 1px;
    margin: 8px 0;
    background: var(--tech-border);
}

.view-style-menu > li > a.view-style-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--tech-text-secondary);
    font-size: 13px;
    font-weight: 400;
    transition: all 0.15s ease;
    background: transparent;
}

.view-style-menu > li > a.view-style-option:hover {
    background: var(--tech-bg-secondary);
    color: var(--tech-text-primary);
}

.view-style-menu > li > a.view-style-option.active {
    color: var(--tech-accent);
    background: rgba(16, 185, 129, 0.08);
}

.view-style-option .fa {
    width: 16px;
    text-align: center;
    color: var(--tech-text-muted);
}

.view-style-option.active .fa:first-child {
    color: var(--tech-accent);
}

.view-style-option .check-icon {
    margin-left: auto;
    font-size: 12px;
    color: var(--tech-accent);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.view-style-option.active .check-icon {
    opacity: 1;
}

/* 列数选择器 */
.columns-selector {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
}

.col-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--tech-border);
    border-radius: var(--tech-radius);
    background: var(--tech-bg-secondary);
    color: var(--tech-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.col-btn:hover {
    border-color: var(--tech-accent);
    color: var(--tech-accent);
}

.col-btn.active {
    background: var(--tech-accent);
    border-color: var(--tech-accent);
    color: #FFFFFF;
}

/* ========================================
   Grid 网格模式
   ======================================== */
.view-grid {
    display: none;
    padding: 10px;
}

.view-grid.active {
    display: block;
}

/* 根据列数设置布局 */
.view-grid[data-cols="3"] .list-item { width: 33.333%; }
.view-grid[data-cols="4"] .list-item { width: 25%; }
.view-grid[data-cols="5"] .list-item { width: 20%; }
.view-grid[data-cols="6"] .list-item { width: 16.666%; }

.view-grid .list-item {
    float: left;
    padding: 12px;
    margin: 0;
    height: auto;
    border: none !important;
    background: transparent;
    transition: transform 0.2s ease;
}

.view-grid .list-item:hover {
    transform: translateY(-4px);
}

.view-grid .manual-item-standard {
    width: 100%;
}

.view-grid .manual-item-standard > dt {
    margin-bottom: 10px;
    height: auto;
}

.view-grid .manual-item-standard .cover {
    border: none !important;
    width: 100%;
    height: auto;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: var(--tech-radius-lg) !important;
    box-shadow: var(--tech-shadow) !important;
    transition: all 0.3s ease;
}

.view-grid .list-item:hover .cover {
    box-shadow: var(--tech-shadow-lg), 0 0 20px var(--tech-accent-glow) !important;
}

.view-grid .manual-item-standard a.name {
    color: var(--tech-text-primary) !important;
    font-size: 14px;
    font-weight: 600;
}

.view-grid .manual-item-standard a.name:hover {
    color: var(--tech-accent) !important;
}

.view-grid .manual-item-standard .author {
    color: var(--tech-text-muted) !important;
    font-size: 12px;
}

/* ========================================
   List 列表模式
   ======================================== */
.view-list {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 10px;
}

.view-list.active {
    display: grid;
}

.book-card-item {
    background: var(--tech-bg-card);
    border: 1px solid var(--tech-border);
    border-radius: var(--tech-radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.book-card-item:hover {
    transform: translateY(-4px);
    border-color: var(--tech-accent);
    box-shadow: var(--tech-shadow-lg), 0 0 20px var(--tech-accent-glow);
}

/* 卡片封面 */
.book-card-cover {
    position: relative;
    width: 100%;
    height: 140px;
    overflow: hidden;
    background: linear-gradient(135deg,
        var(--tech-bg-tertiary) 0%,
        var(--tech-bg-secondary) 50%,
        var(--tech-bg-primary) 100%);
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.book-card-item:hover .book-card-cover img {
    transform: scale(1.05);
}

.book-card-cover a {
    display: block;
    width: 100%;
    height: 100%;
}

/* 卡片内容区 */
.book-card-content {
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* 卡片头部 */
.book-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--tech-border);
}

.book-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--tech-text-primary);
    flex: 1;
    overflow: hidden;
}

.book-card-title a {
    color: var(--tech-text-primary);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-card-title a:hover {
    color: var(--tech-accent);
}

.book-card-author {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--tech-text-muted);
    margin-left: 10px;
    white-space: nowrap;
}

.book-card-author i {
    color: var(--tech-accent);
    font-size: 11px;
}

/* 文档列表 */
.book-card-docs {
    flex: 1;
    margin-bottom: 10px;
}

.doc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.doc-item {
    display: flex;
    align-items: center;
    padding: 6px 0;
    position: relative;
}

.doc-item::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom,
        transparent 0%,
        var(--tech-accent) 20%,
        var(--tech-accent) 80%,
        transparent 100%);
    opacity: 0.25;
}

.doc-item:first-child::before { top: 50%; }
.doc-item:last-child::before { bottom: 50%; }

.doc-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tech-bg-tertiary);
    border: 2px solid var(--tech-accent);
    margin-right: 10px;
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.doc-item:hover .doc-indicator {
    background: var(--tech-accent);
    box-shadow: 0 0 8px var(--tech-accent-glow);
}

.doc-link {
    color: var(--tech-text-secondary);
    font-size: 13px;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    transition: color 0.2s ease;
}

.doc-link:hover { color: var(--tech-accent); }

.doc-text {
    color: var(--tech-text-muted);
    font-size: 13px;
}

.doc-empty .doc-indicator {
    background: var(--tech-bg-tertiary);
    border-color: var(--tech-text-muted);
}

/* 卡片底部 */
.book-card-footer {
    padding-top: 10px;
    border-top: 1px solid var(--tech-border);
}

.view-more-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--tech-accent);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.view-more-link:hover {
    color: var(--tech-accent-hover);
    transform: translateX(3px);
}

.view-more-link i {
    font-size: 11px;
    transition: transform 0.2s ease;
}

.view-more-link:hover i { transform: translateX(3px); }

/* ========================================
   Card 大卡片模式
   ======================================== */
.view-card {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
    padding: 10px;
}

.view-card.active {
    display: grid;
}

.card-item-large {
    background: var(--tech-bg-card);
    border: 1px solid var(--tech-border);
    border-radius: var(--tech-radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.card-item-large:hover {
    transform: translateY(-5px);
    border-color: var(--tech-accent);
    box-shadow: var(--tech-shadow-lg), 0 0 25px var(--tech-accent-glow);
}

.card-large-cover {
    position: relative;
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: linear-gradient(135deg,
        var(--tech-bg-tertiary) 0%,
        var(--tech-bg-secondary) 50%,
        var(--tech-bg-primary) 100%);
}

.card-large-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.card-item-large:hover .card-large-cover img {
    transform: scale(1.06);
}

.card-large-cover a {
    display: block;
    width: 100%;
    height: 100%;
}

.card-large-content {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-large-title {
    margin: 0 0 8px 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--tech-text-primary);
}

.card-large-title a {
    color: var(--tech-text-primary);
    text-decoration: none;
}

.card-large-title a:hover {
    color: var(--tech-accent);
}

.card-large-desc {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: var(--tech-text-muted);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-large-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--tech-border);
}

.card-large-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--tech-text-muted);
}

.card-large-meta i {
    color: var(--tech-accent);
    font-size: 11px;
}

.card-large-docs {
    margin-bottom: 14px;
}

.card-large-docs h4 {
    margin: 0 0 8px 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--tech-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-large-docs ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.card-large-docs li {
    padding: 5px 0;
}

.card-large-docs li a {
    color: var(--tech-text-secondary);
    font-size: 13px;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.card-large-docs li a::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--tech-accent);
    margin-right: 8px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.card-large-docs li a:hover {
    color: var(--tech-accent);
}

.card-large-docs li a:hover::before {
    opacity: 1;
}

.card-large-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--tech-border);
    color: var(--tech-accent);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.card-large-link:hover {
    color: var(--tech-accent-hover);
    transform: translateX(3px);
}

.card-large-link i {
    transition: transform 0.2s ease;
}

.card-large-link:hover i {
    transform: translateX(3px);
}

/* ========================================
   空状态
   ======================================== */
.empty-state {
    color: var(--tech-text-muted);
    font-family: var(--tech-font-mono);
    font-size: 14px;
    background: transparent;
    height: auto;
    margin: 60px auto;
    padding: 40px;
    position: relative;
}

.empty-state::before {
    content: '';
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    background: var(--tech-bg-secondary);
    border-radius: 50%;
    box-shadow: 0 0 20px var(--tech-accent-glow);
    animation: pulse-glow 2s ease-in-out infinite;
}

/* ========================================
   响应式设计
   ======================================== */
@media screen and (max-width: 1200px) {
    .view-list { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
    .view-card { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

@media screen and (max-width: 840px) {
    .view-style-btn {
        padding: 6px 10px;
        font-size: 12px;
        height: 32px;
    }

    .view-style-btn .view-style-text {
        display: none;
    }

    .view-list {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 8px;
    }

    .view-card {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 8px;
    }

    .book-card-cover { height: 120px; }
    .book-card-content { padding: 12px 14px; }
    .book-card-header { flex-direction: column; gap: 6px; align-items: flex-start; }
    .book-card-author { margin-left: 0; }

    .card-large-cover { height: 130px; }
    .card-large-content { padding: 14px 16px; }
    .card-large-meta { gap: 10px; }
}

@media screen and (max-width: 480px) {
    .view-grid[data-cols="3"] .list-item,
    .view-grid[data-cols="4"] .list-item,
    .view-grid[data-cols="5"] .list-item,
    .view-grid[data-cols="6"] .list-item {
        width: 50%;
    }

    .view-grid .list-item { padding: 8px; }

    .book-card-title { font-size: 14px; }
    .doc-link { font-size: 12px; }
    .card-large-title { font-size: 15px; }
}

/* ========================================
   动画
   ======================================== */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 10px var(--tech-accent-glow);
    }
    50% {
        box-shadow: 0 0 20px var(--tech-accent-glow), 0 0 35px rgba(16, 185, 129, 0.12);
    }
}