/* SINAP Digital Library - Modern Design System */

/* Design System Variables */
:root {
    /* Colors - Medical Theme */
    --primary: #1a5f1a;
    --primary-light: #2d7a2d;
    --primary-dark: #0f3f0f;
    --primary-50: #f0f9f0;
    --primary-100: #d9f2d9;
    --primary-500: #1a5f1a;

    /* Neutrals */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic Colors */
    --success: #059669;
    --error: #dc2626;
    --warning: #d97706;
    --info: #0284c7;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;

    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-2xl: 2rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* Layout */
    --container-max-width: 1280px;
    --container-padding: var(--space-6);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--gray-900);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout Components */
.section {
    width: 100%;
}

.section-inner {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.section-full {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

/* Typography System */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }
.text-4xl { font-size: var(--font-size-4xl); }
.text-5xl { font-size: var(--font-size-5xl); }

.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.text-gray-500 { color: var(--gray-500); }
.text-gray-600 { color: var(--gray-600); }
.text-gray-700 { color: var(--gray-700); }
.text-gray-800 { color: var(--gray-800); }
.text-gray-900 { color: var(--gray-900); }
.text-primary { color: var(--primary); }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--gray-900);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

/* Links */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-dark);
}

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

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--container-padding);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-logo {
    width: 48px;
    height: 48px;
}

.site-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.site-subtitle {
    font-size: var(--font-size-sm);
    color: var(--gray-600);
    margin: 0;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--gray-700);
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--primary);
}

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

/* Mobile menu toggle - hide on desktop */
.mobile-menu-toggle {
    display: none;
}

/* Breadcrumbs */
.breadcrumbs {
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--gray-200);
    position: relative;
}

.breadcrumbs::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0.3;
}

.breadcrumb-list {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: var(--font-size-sm);
    gap: 0;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    position: relative;
}

.breadcrumb-link {
    color: var(--gray-600);
    text-decoration: none;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-weight: 500;
    position: relative;
}

.breadcrumb-link:hover {
    color: var(--primary);
    background: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.breadcrumb-current {
    color: white;
    font-weight: 600;
    padding: var(--space-2) var(--space-3);
    background: var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.breadcrumb-separator {
    color: var(--gray-400);
    margin: 0 var(--space-1);
    opacity: 0.7;
    transition: all 0.2s ease;
}

.breadcrumb-item:hover .breadcrumb-separator {
    opacity: 1;
    color: var(--primary);
}

/* Hero Section */
.hero {
    background: linear-gradient(rgba(15, 63, 15, 0.7), rgba(15, 63, 15, 0.8)),
                url('../images/library-many-vertical.jpg') center/cover;
    color: white;
    padding: var(--space-24) 0;
    text-align: center;
    position: relative;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: var(--font-size-5xl);
    font-weight: 800;
    margin-bottom: var(--space-6);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-subtitle {
    font-size: var(--font-size-xl);
    font-weight: 400;
    opacity: 0.9;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Main Content */
.main-content {
    padding: var(--space-12) 0;
    min-height: 60vh;
}

/* Grid System */
.grid {
    display: grid;
    gap: var(--space-8);
}

.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.content-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: var(--space-8);
    align-items: start;
}

/* Cards */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-header {
    margin-bottom: var(--space-6);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.card-description {
    color: var(--gray-600);
}

/* Resource Cards */
.resource-card {
    display: flex;
    gap: var(--space-6);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    background: white;
    border: 1px solid var(--gray-200);
    transition: all 0.2s ease;
}

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

.resource-thumbnail {
    width: 120px;
    height: 160px;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.resource-content {
    flex: 1;
}

.resource-meta {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    background: var(--primary-50);
    color: var(--primary);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
}

.resource-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-2);
    line-height: 1.3;
}

.resource-title a {
    color: inherit;
}

.resource-title a:hover {
    color: var(--primary);
}

.resource-authors {
    color: var(--gray-600);
    margin-bottom: var(--space-2);
}

.resource-date {
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-4);
}

.resource-actions {
    display: flex;
    gap: var(--space-3);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

.btn svg {
    flex-shrink: 0;
    vertical-align: middle;
}

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--font-size-base);
}

/* Forms */
.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: all 0.15s ease;
    background: white;
}

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

.form-input::placeholder {
    color: var(--gray-400);
}

/* Search */
.search-form {
    display: flex;
    gap: var(--space-4);
    align-items: end;
}

.search-field {
    flex: 1;
}

.search-button {
    padding: var(--space-3) var(--space-6);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

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

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

.sidebar-section {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
}

.sidebar-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-4);
}

.filter-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.filter-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease;
}

.filter-item:hover {
    background: var(--gray-50);
}

.filter-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.filter-label {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--gray-700);
}

.filter-count {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    background: var(--gray-100);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    font-weight: 500;
}

/* Footer */
.footer {
    background: var(--gray-900);
    color: white;
    padding: var(--space-16) 0 var(--space-8);
    margin-top: var(--space-20);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-8);
    margin-bottom: var(--space-8);
}

.footer-section h3 {
    color: white;
    margin-bottom: var(--space-4);
}

.footer-section p,
.footer-section a {
    color: var(--gray-400);
    line-height: 1.6;
}

.footer-section a:hover {
    color: white;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.footer-bottom {
    border-top: 1px solid var(--gray-800);
    padding-top: var(--space-6);
    text-align: center;
    color: var(--gray-500);
}

/* Alerts */
.alert {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
    font-size: var(--font-size-sm);
}

.alert-error {
    background: #fef2f2;
    color: var(--error);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* Utility Classes */
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-8 { margin-top: var(--space-8); }
.text-center { text-align: center; }

/* Responsive Design */
@media (max-width: 1000px) {
    :root {
        --container-padding: var(--space-4);
    }

    .content-layout {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }

    .sidebar {
        order: -1;
    }
}

@media (max-width: 768px) {
    /* Mobile-first improvements */
    .section-inner {
        padding: 0 var(--space-4);
    }

    .hero {
        padding: var(--space-8) 0;
    }

    .hero-title {
        font-size: var(--font-size-4xl);
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .resource-card {
        flex-direction: column;
        text-align: center;
    }

    .resource-thumbnail {
        align-self: center;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-1);
    }

    .header-inner {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }
}

@media (max-width: 480px) {
    :root {
        --container-padding: var(--space-3);
    }

    .hero {
        padding: var(--space-16) 0;
    }

    .hero-title {
        font-size: var(--font-size-3xl);
    }

    .card {
        padding: var(--space-4);
    }
}

/* ===== Upload Form Improvements ===== */
.upload-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-8) var(--container-padding);
}

.upload-content {
    max-width: 100%;
}

.upload-form {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.form-section {
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--gray-200);
}

.form-section:last-child {
    border-bottom: none;
}

.form-section-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--space-6);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
}

.form-group-full {
    grid-column: 1 / -1;
}

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

/* Make textareas and descriptions more compact */
#description,
#abstract {
    min-height: 80px;
}

/* Compact spacing for better fit */
.form-group {
    margin-bottom: 0;
}

.form-help {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--font-size-xs);
    color: var(--gray-500);
}

/* Mobile: Stack form fields */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .upload-form {
        padding: var(--space-4);
    }

    /* Mobile Header - Remove sticky, left-align text */
    .header {
        position: relative; /* Remove sticky on mobile */
        top: auto;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start; /* Left align on mobile */
        gap: var(--space-2);
    }

    .header-brand {
        width: 100%;
        flex-direction: row;
        align-items: center;
    }

    .site-title {
        font-size: var(--font-size-lg);
    }

    .site-subtitle {
        font-size: var(--font-size-xs);
    }

    /* Mobile Navigation - Hamburger menu */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: none;
        border: 1px solid var(--gray-300);
        border-radius: var(--radius-md);
        cursor: pointer;
        color: var(--gray-700);
        transition: all 0.2s ease;
    }

    .mobile-menu-toggle:hover {
        background: var(--gray-100);
        border-color: var(--gray-400);
    }

    .header-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-bottom: 1px solid var(--gray-200);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .header-nav.active {
        display: block;
    }

    .nav-menu {
        flex-direction: column;
        width: 100%;
        padding: var(--space-4) 0;
    }

    .nav-link {
        width: 100%;
        padding: var(--space-3) var(--container-padding);
        border-radius: 0;
    }

    /* Mobile breadcrumbs - prevent overflow */
    .breadcrumbs {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .breadcrumbs::-webkit-scrollbar {
        display: none;
    }

    .breadcrumb-list {
        white-space: nowrap;
        min-width: min-content;
    }

    .breadcrumb-item {
        display: inline-flex;
    }

    /* Mobile Search - Fix multi-line issue */
    .hero-search {
        width: 100%;
    }

    .search-container {
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
        width: 100%;
    }

    .search-input {
        width: 100%;
        font-size: var(--font-size-base);
    }

    .search-button {
        width: 100%;
        justify-content: center;
    }
}

/* ===== Back to Top Button ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    z-index: 999;
}

.back-to-top:hover {
    background: var(--primary-dark);
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top.show {
    display: flex;
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}