/* Haroon Digital Platform – Custom Styles */

/* Font families + flex column layout to eliminate whitespace above footer */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Arabic / RTL body uses Cairo as primary — legible at all weights,
   designed for both Arabic and Latin, excellent for bilingual sites. */
.font-arabic,
[dir="rtl"] body,
[dir="rtl"],
[lang="ar"] {
    font-family: 'Cairo', 'Noto Sans Arabic', 'Arial Unicode MS', sans-serif;
    font-feature-settings: "kern" 1, "liga" 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* Arabic body-text needs wider line-height for legibility */
[dir="rtl"] p,
[dir="rtl"] li,
[dir="rtl"] td,
[dir="rtl"] .text-sm,
[dir="rtl"] .text-base {
    line-height: 1.9;
    word-spacing: 0.04em;
}

/* Headings in Arabic need slightly reduced weight to avoid heaviness */
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4 {
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.5;
}

/* RTL adjustments */
[dir="rtl"] .space-x-2 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 1;
}

[dir="rtl"] .space-x-3 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 1;
}

[dir="rtl"] .space-x-6 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 1;
}

/* Article content */
.article-content {
    line-height: 1.8;
    font-size: 1.05rem;
}

[dir="rtl"] .article-content {
    text-align: right;
    font-family: 'Cairo', 'Noto Sans Arabic', sans-serif;
    font-size: 1.1rem;
    line-height: 2.1;
    word-spacing: 0.06em;
}

/* Line clamp utilities */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading spinner */
.spinner {
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Card hover effects */
article:hover .article-img {
    transform: scale(1.05);
}

/* Book-style article cover container */
.article-cover-container {
    aspect-ratio: 3 / 4;
    /* Fallback for browsers without aspect-ratio support */
    min-height: 200px;
    background-color: #f8fafc;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.article-cover-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ─── Shared Book Card (article-card.php component) ─── */

.book-card {
    background: #ffffff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.book-card:hover {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13);
    transform: translateY(-3px);
}

/* Cover area – fixed 3:4 ratio */
.book-card-cover-link {
    display: block;
}

.book-card-cover {
    aspect-ratio: 3 / 4;
    min-height: 180px;
    background-color: #f0f4f8;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

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

.book-card:hover .book-card-img {
    transform: scale(1.03);
}

.book-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a 100%);
    color: rgba(255, 255, 255, 0.5);
}

/* Card body */
.book-card-body {
    padding: 0.875rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.25rem;
}

/* Category badge */
.book-card-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: #dbeafe;
    color: #1d4ed8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    align-self: flex-start;
    margin-bottom: 0.15rem;
}

/* Title – max 2 lines */
.book-card-title {
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.45;
    color: #111827;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

/* Journal / source */
.book-card-journal {
    font-size: 0.7rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Publication year */
.book-card-year {
    font-size: 0.68rem;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Footer row: views + action */
.book-card-footer {
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.book-card-views {
    font-size: 0.68rem;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.book-card-action {
    font-size: 0.72rem;
    font-weight: 700;
    color: #1d4ed8;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s;
}

.book-card-action:hover {
    color: #1e40af;
}

/* ─── Pagination component ─── */

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pagination-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.pagination-btn--active {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
    font-weight: 700;
    pointer-events: none;
}

/* Article show page hero cover – centered book style */
.article-hero-cover {
    background-color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    max-height: 360px;
    overflow: hidden;
}

.article-hero-cover img {
    max-height: 320px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Smooth transitions */
* {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Form focus styles */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Button styles */
.btn-primary {
    @apply bg-blue-700 text-white px-6 py-3 rounded-xl font-semibold hover:bg-blue-800 transition-colors;
}

/* Sticky header */
.sticky-header {
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

/* Print styles */
@media print {
    header, footer, .no-print { display: none !important; }
    .article-content { font-size: 12pt; line-height: 1.6; }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .hero-title { font-size: 2rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Category colors */
.cat-medicine { background-color: #fee2e2; color: #dc2626; }
.cat-health { background-color: #dcfce7; color: #16a34a; }
.cat-ai { background-color: #ede9fe; color: #7c3aed; }
.cat-technology { background-color: #dbeafe; color: #1d4ed8; }
.cat-engineering { background-color: #fef3c7; color: #d97706; }
.cat-education { background-color: #e0e7ff; color: #4338ca; }
.cat-business { background-color: #fce7f3; color: #be185d; }
.cat-general { background-color: #ccfbf1; color: #0f766e; }

/* Status badges */
.status-draft { background-color: #f3f4f6; color: #6b7280; }
.status-translation { background-color: #fef3c7; color: #d97706; }
.status-editing { background-color: #dbeafe; color: #1d4ed8; }
.status-review { background-color: #ffedd5; color: #c2410c; }
.status-published { background-color: #dcfce7; color: #15803d; }
