/* ============================================
   Knowledge Hub - Main Stylesheet
   ============================================ */

/* Variables */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f1f5f9;
    color: var(--dark);
    line-height: 1.5;
}

/* Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.95);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    max-width: 1280px;
    margin: 0 auto;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-decoration: none;
}

.logo:hover {
    opacity: 0.8;
}

.nav {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.nav a {
    padding: 8px 16px;
    color: var(--secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-weight: 500;
}

.nav a:hover {
    background: var(--light);
    color: var(--primary);
}

.nav a.active {
    background: var(--primary);
    color: white;
}

/* Mobile menu button */
.menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--dark);
}

/* ============================================
   Hero Section (Homepage)
   ============================================ */
.hero {
    text-align: center;
    padding: 60px 24px;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
    border-radius: var(--radius);
    margin: 24px 0 48px;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--dark), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 16px;
}

.hero p {
    font-size: 1.25rem;
    color: var(--secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Search Bar */
.search-container {
    max-width: 600px;
    margin: 32px auto 0;
}

.search-box {
    display: flex;
    gap: 12px;
    background: white;
    border-radius: 60px;
    padding: 8px 8px 8px 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.search-box input {
    flex: 1;
    border: none;
    font-size: 1rem;
    padding: 12px 0;
    outline: none;
}

.search-box button {
    background: var(--primary);
    border: none;
    padding: 10px 28px;
    border-radius: 40px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.search-box button:hover {
    background: var(--primary-dark);
}

/* ============================================
   Browse Sections
   ============================================ */
.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 32px 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

/* Category Cards */
.category-card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.2s;
    border: 1px solid var(--border);
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.category-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.category-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.category-count {
    color: var(--gray);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Institution Cards */
.institution-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    color: var(--dark);
    border: 1px solid var(--border);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.institution-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.institution-icon {
    font-size: 1.8rem;
}

.institution-name {
    font-weight: 500;
}

/* Content Cards (Videos & Documents) */
.content-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.2s;
    border: 1px solid var(--border);
    display: block;
}

.content-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-thumbnail {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.card-content {
    padding: 16px;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    font-size: 0.8rem;
    color: var(--gray);
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: var(--light);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--secondary);
}

.content-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ============================================
   Forms
   ============================================ */
.form-card {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    max-width: 600px;
    margin: 40px auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.form-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}

.form-subtitle {
    text-align: center;
    color: var(--gray);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 32px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 12px;
}

.tab {
    padding: 8px 20px;
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--gray);
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.tab.active {
    color: var(--primary);
    background: rgba(37,99,235,0.1);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 24px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(37,99,235,0.05);
}

/* ============================================
   Alerts & Messages
   ============================================ */
.alert {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    display: none;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 32px 24px;
    margin-top: 60px;
    text-align: center;
    color: var(--gray);
    font-size: 0.875rem;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .search-box {
        flex-direction: column;
        border-radius: var(--radius);
        padding: 16px;
    }
    
    .search-box button {
        width: 100%;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 16px;
        border-bottom: 1px solid var(--border);
    }
    
    .nav.open {
        display: flex;
    }
    
    .menu-btn {
        display: block;
    }
    
    .grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .form-card {
        padding: 20px;
        margin: 20px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Add to your existing style.css or replace the grid and card sections */

/* Grid Layout - More balanced */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 28px;
    margin-bottom: 48px;
}

/* Content Card - Consistent sizing */
.content-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: #1e293b;
    transition: all 0.25s ease;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 100%;
    cursor: pointer;
}

.content-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0,0,0,0.15);
    border-color: #cbd5e1;
}

/* Card Thumbnail - Fixed aspect ratio */
.card-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Card Content - Consistent padding */
.card-content {
    padding: 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Card Title - Fixed height for consistency */
.card-title {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.4;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
    color: #1e293b;
}

/* Card Meta - Bottom section */
.card-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Card Tags - Wrap nicely */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 12px;
}

.tag {
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    color: #475569;
    font-weight: 500;
}

/* Content Badge */
.content-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 2;
}

/* Type Badge on Thumbnail */
.type-badge-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 2;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .card-title {
        font-size: 0.95rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) and (max-width: 1280px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1281px) {
    .grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
