/* ============================================
   PASTPAPERS HUB — DESIGN SYSTEM
   ============================================ */

:root {
  /* Colors */
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --success: #10b981;
  --danger: #ef4444;

  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --bg: #f8fafc;
  --bg-alt: #ffffff;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* ============================================
   LAYOUT
   ============================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

main {
  padding: 48px 24px;
  min-height: 70vh;
  max-width: 1200px;
  margin: 0 auto;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin-bottom: 24px;
}

h2 {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  margin: 40px 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

h3 { font-size: 1.15rem; margin-bottom: 10px; }
h4 { font-size: 1rem; margin-bottom: 8px; }

p { margin-bottom: 14px; color: var(--text); }
p + p { margin-top: 0; }

small { font-size: 0.85rem; color: var(--text-muted); }

/* ============================================
   HEADER
   ============================================ */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding-top: 16px;
  padding-bottom: 16px;
}

.logo {
  color: #fff !important;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.logo:hover { color: var(--accent) !important; }

.site-header nav {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.site-header nav a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.site-header nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.search-form {
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: var(--transition);
}

.search-form:focus-within {
  background: rgba(255, 255, 255, 0.25);
  border-color: var(--accent);
}

.search-form input {
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: #fff;
  outline: none;
  width: 220px;
  font-size: 0.9rem;
}

.search-form input::placeholder { color: rgba(255, 255, 255, 0.7); }

.search-form button {
  padding: 10px 18px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.search-form button:hover { background: var(--accent-hover); }

/* ============================================
   HERO
   ============================================ */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 80px 40px;
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: 48px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 158, 11, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.hero > * { position: relative; z-index: 1; }

.hero h1 {
  color: #fff;
  font-size: clamp(1.75rem, 5vw, 3rem);
  margin-bottom: 16px;
  font-weight: 800;
}

.hero p {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: rgba(255, 255, 255, 0.9);
  margin: 0 auto 32px;
  max-width: 640px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: var(--primary-dark) !important;
  padding: 12px 26px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
  white-space: nowrap;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(245, 158, 11, 0.3);
  color: var(--primary-dark) !important;
}

.btn:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: #fff !important;
  border: 2px solid rgba(255, 255, 255, 0.6);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
  box-shadow: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff !important;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 8px 16px rgba(30, 64, 175, 0.3);
}

.btn-download {
  background: var(--success);
  color: #fff !important;
  font-size: 1.05rem;
  padding: 16px 34px;
  font-weight: 700;
}

.btn-download:hover {
  background: #059669;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.35);
  color: #fff !important;
}

/* ============================================
   CARDS & GRID
   ============================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.card {
  background: var(--bg-alt);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  color: var(--text);
}

.card:hover::before { transform: scaleX(1); }

.card h3 {
  color: var(--primary-dark);
  margin: 12px 0 8px;
  font-size: 1.05rem;
  line-height: 1.4;
}

.card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
  flex-grow: 1;
}

.card small {
  color: var(--text-light);
  font-size: 0.8rem;
  margin-top: auto;
  display: block;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  width: fit-content;
}

/* ============================================
   FILTERS
   ============================================ */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
  background: var(--bg-alt);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.filters select {
  padding: 11px 14px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  flex: 1;
  min-width: 140px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.filters select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.filters .btn { padding: 11px 26px; }

/* ============================================
   PAPER DETAIL
   ============================================ */
.paper-detail {
  background: var(--bg-alt);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.paper-detail h1 { margin-top: 16px; }

.paper-detail .meta {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.paper-detail .btn-download { margin: 16px 0; }

/* ============================================
   ARTICLES (University / Static pages)
   ============================================ */
article {
  background: var(--bg-alt);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

article h2 { margin-top: 32px; }

article p, article ul, article ol { color: #334155; }

article ul, article ol { padding-left: 24px; margin-bottom: 16px; }
article li { margin-bottom: 8px; }

/* ============================================
   AD SLOTS
   ============================================ */
.ad-slot {
  margin: 32px 0;
  padding: 16px;
  background: var(--bg-alt);
  border-radius: var(--radius);
  text-align: center;
  min-height: 100px;
  border: 1px dashed var(--border);
  overflow: hidden;
}

/* ============================================
   TABLES (Admin)
   ============================================ */
table {
  width: 100%;
  background: var(--bg-alt);
  border-collapse: collapse;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f1f5f9; }

td a { color: var(--danger); font-weight: 500; }
td a:hover { text-decoration: underline; }

/* ============================================
   FORMS
   ============================================ */
form input,
form select,
form textarea {
  width: 100%;
  padding: 12px 14px;
  margin: 6px 0;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: #fff;
  color: var(--text);
  transition: var(--transition);
}

form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

form textarea { min-height: 100px; resize: vertical; }

/* Login form */
.container > form {
  background: var(--bg-alt);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #cbd5e1;
  padding: 56px 0 24px;
  margin-top: 64px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 40px;
  margin-bottom: 40px;
}

.site-footer h4 {
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.site-footer p {
  color: #94a3b8;
  font-size: 0.9rem;
  line-height: 1.7;
}

.site-footer a {
  color: #cbd5e1;
  display: block;
  text-decoration: none;
  padding: 5px 0;
  font-size: 0.9rem;
  transition: var(--transition);
}

.site-footer a:hover {
  color: var(--accent);
  padding-left: 4px;
}

.copyright {
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 24px;
  color: #64748b;
  font-size: 0.85rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .search-form input { width: 160px; }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }

  .site-header .container {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .site-header nav {
    justify-content: center;
    width: 100%;
  }

  .search-form { width: 100%; }
  .search-form input { flex: 1; width: auto; }

  main { padding: 32px 16px; }

  .hero { padding: 56px 24px; }

  .grid { grid-template-columns: 1fr; }

  .filters { flex-direction: column; }
  .filters select { width: 100%; }

  .paper-detail, article { padding: 24px; }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  h2 { margin: 32px 0 16px; }
}

@media (max-width: 480px) {
  .site-header nav a {
    padding: 6px 10px;
    font-size: 0.88rem;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .btn-download {
    padding: 14px 24px;
    font-size: 1rem;
  }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 16px; }
.mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 32px; }

/* Error message */
.error {
  color: var(--danger);
  background: #fef2f2;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  background: var(--bg-alt);
  border-radius: var(--radius);
  border: 1px dashed var(--border-dark);
}

/* Scrollbar (Webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* Selection */
::selection {
  background: var(--accent);
  color: var(--primary-dark);
}

/* Print */
@media print {
  .site-header, .site-footer, .ad-slot, .btn { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
}