/* ═══════════════════════════════════════════════════ */
/* 📚 HADITH DASHBOARD - Native App Style (Library Clone) */
/* ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Bengali:wght@300;400;500;600;700&display=swap');

.had-home {
    font-family: 'Noto Sans Bengali', sans-serif;
    max-width: 98%;
    margin: 0 auto;
    padding: 0 8px 20px 8px;
    color: #263238;
}

/* ═══════ SEARCH BAR ═══════ */
.had-search-wrapper {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 0 8px;
    background: inherit;
}

.had-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    overflow: hidden;
}

.had-search-box:focus-within {
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.2), 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.had-search-icon {
    position: absolute;
    left: 16px;
    color: #90a4ae;
    font-size: 18px;
    pointer-events: none;
    transition: color 0.3s;
}

.had-search-box:focus-within .had-search-icon {
    color: #2196F3;
}

.had-search-input {
    width: 100%;
    border: none;
    outline: none;
    padding: 14px 16px 14px 46px;
    font-size: 15px;
    font-family: 'Noto Sans Bengali', sans-serif;
    background: transparent;
    color: #263238;
}

.had-search-input::placeholder {
    color: #b0bec5;
}

.had-search-clear {
    position: absolute;
    right: 12px;
    background: #eceff1;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: #607d8b;
    transition: all 0.2s;
}

.had-search-clear:hover {
    background: #cfd8dc;
}

.had-search-clear.show {
    display: flex;
}

/* ═══════ SEARCH RESULTS ═══════ */
.had-search-results {
    background: #fff;
    border-radius: 14px;
    margin-top: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-height: 60vh;
    overflow-y: auto;
    display: none;
    animation: hadSlideDown 0.25s ease;
}

.had-search-results.show {
    display: block;
}

@keyframes hadSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.had-search-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}

.had-search-item:last-child {
    border-bottom: none;
}

.had-search-item:hover,
.had-search-item:active {
    background: #e3f2fd;
}

.had-search-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    margin-right: 12px;
}

.had-search-item-info h4 {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 500;
    color: #263238;
    line-height: 1.4;
}

.had-search-item-info span {
    font-size: 12px;
    color: #90a4ae;
}

/* ═══════ STATS BAR ═══════ */
.had-stats-bar {
    display: flex;
    gap: 10px;
    margin: 6px 0 4px;
}

.had-stat-chip {
    flex: 1;
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.had-stat-chip .num {
    font-size: 18px;
    font-weight: 700;
    color: #1565c0;
    display: block;
}

.had-stat-chip .label {
    font-size: 11px;
    color: #90a4ae;
    margin-top: 2px;
    display: block;
}

/* ═══════ SECTION HEADERS ═══════ */
.had-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 20px 4px 10px;
}

.had-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #37474f;
    display: flex;
    align-items: center;
    gap: 8px;
}

.had-section-title .emoji {
    font-size: 18px;
}

.had-section-more {
    font-size: 12px;
    color: #2196F3;
    text-decoration: none;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
    background: #e3f2fd;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.had-section-more:hover {
    background: #bbdefb;
}

/* ═══════ LAST READ / FAVORITES SCROLL ═══════ */
.had-books-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.had-books-scroll::-webkit-scrollbar {
    display: none;
}

.had-book-card {
    flex: 0 0 140px;
    scroll-snap-align: start;
    background: #ffffff;
    border-radius: 14px;
    padding: 14px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.had-book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 14px 14px 0 0;
}

/* Random-ish colors for cards */
.had-book-card:nth-child(odd)::before {
    background: linear-gradient(90deg, #42a5f5, #1e88e5);
}

.had-book-card:nth-child(even)::before {
    background: linear-gradient(90deg, #66bb6a, #43a047);
}


.had-book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.had-book-card:active {
    transform: scale(0.97);
}

.had-book-cover {
    width: 100%;
    height: 80px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    /* Default fallback */
}

/* Color variants class */
.had-book-cover.c1 {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
}

.had-book-cover.c2 {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
}

.had-book-cover.c3 {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
}

.had-book-cover.c4 {
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
}

.had-book-cover.c5 {
    background: linear-gradient(135deg, #fce4ec, #f8bbd0);
}

.had-book-cover.c6 {
    background: linear-gradient(135deg, #e0f7fa, #b2ebf2);
}

.had-book-title {
    font-size: 12.5px;
    font-weight: 500;
    color: #37474f;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    margin-bottom: auto;
}

.had-book-meta {
    font-size: 10.5px;
    color: #90a4ae;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.had-empty-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: #fff;
    border-radius: 14px;
    text-align: center;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

.had-empty-placeholder .emoji {
    font-size: 36px;
    margin-bottom: 8px;
}

.had-empty-placeholder p {
    margin: 0;
    font-size: 13px;
    color: #90a4ae;
}

/* ═══════ BOOK/CATEGORY GRID ═══════ */
.had-categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (min-width: 600px) {
    .had-categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .had-categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

.had-cat-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
}

.had-cat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.had-cat-card.active {
    border-color: #2196F3;
    background: linear-gradient(135deg, #e3f2fd, #fff);
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.15);
}

.had-cat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 8px;
}

/* Icon Colors */
.had-cat-icon.ci1 {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
}

.had-cat-icon.ci2 {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
}

.had-cat-icon.ci3 {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
}

.had-cat-icon.ci4 {
    background: linear-gradient(135deg, #f3e5f5, #e1bee7);
}

.had-cat-icon.ci5 {
    background: linear-gradient(135deg, #fce4ec, #f8bbd0);
}

.had-cat-icon.ci6 {
    background: linear-gradient(135deg, #e0f7fa, #b2ebf2);
}

.had-cat-icon.ci7 {
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
}

.had-cat-icon.ci8 {
    background: linear-gradient(135deg, #e8eaf6, #c5cae9);
}

.had-cat-name {
    font-size: 13px;
    font-weight: 500;
    color: #37474f;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.had-cat-count {
    font-size: 11px;
    color: #90a4ae;
    margin-top: 3px;
}

/* ═══════ EXPANDED BOOK PANEL ═══════ */
.had-cat-books-panel {
    grid-column: 1 / -1;
    background: #ffffff;
    border-radius: 14px;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    opacity: 0;
    margin-bottom: 15px;
}

.had-cat-books-panel.open {
    max-height: 2000px;
    padding: 12px;
    opacity: 1;
}

.had-cat-books-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.had-cat-books-panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #1565c0;
}

.had-cat-books-panel-close {
    background: #eceff1;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #607d8b;
    transition: all 0.2s;
}

.had-cat-books-panel-close:hover {
    background: #cfd8dc;
}

.had-cat-book-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    color: inherit;
    margin-bottom: 2px;
}

.had-cat-book-item:hover {
    background: #f5f9ff;
}

.had-cat-book-item:active {
    background: #e3f2fd;
    transform: scale(0.99);
}

.had-cat-book-item .book-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-right: 12px;
}

.had-cat-book-item .book-name {
    font-size: 13.5px;
    font-weight: 400;
    color: #37474f;
    line-height: 1.4;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e3f2fd;
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: hadSpin 0.7s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes hadSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Fade In */
.had-fade-in {
    animation: hadFadeIn 0.4s ease forwards;
    opacity: 0;
}

@keyframes hadFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}