/* ==========================================================================
   Modern Library Website - Design System & Stylesheet
   WCAG 2.1 AA Accessible, Fully Responsive, Mobile-First
   ========================================================================== */

:root {
  --font-primary: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Literata', Georgia, Cambria, 'Times New Roman', serif;

  /* Color Palette - Elegant, inviting library colors */
  --color-primary: #153259;
  --color-primary-dark: #0f2440;
  --color-primary-light: #285596;
  
  --color-accent: #d97706; /* Warmer amber */
  --color-accent-hover: #b45309;
  --color-accent-light: #fef3c7;

  --color-success: #065f46;
  --color-success-bg: #d1fae5;
  --color-danger: #991b1b;
  --color-danger-bg: #fee2e2;

  --bg-page: #f8fafc; /* Softer light blue-grey */
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1f5f9;
  --bg-muted: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --text-inverse: #ffffff;

  --border-color: #cbd5e1;
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --border-radius-pill: 9999px;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -1px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  --shadow-hover: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 10px 10px -5px rgba(15, 23, 42, 0.04);

  --container-max: 1200px;
  --font-scale: 1;
}

/* Accessibility: High Contrast Mode */
body.high-contrast {
  --bg-page: #000000;
  --bg-surface: #000000;
  --bg-surface-alt: #1a1a1a;
  --text-main: #ffffff;
  --text-muted: #ffffff;
  --text-light: #ffffff;
  --color-primary: #ffff00;
  --color-primary-dark: #000000;
  --color-primary-light: #ffff00;
  --color-accent: #ffff00;
  --color-accent-hover: #ffff00;
  --color-accent-light: #000000;
  --border-color: #ffffff;
  --text-inverse: #000000;
}
body.high-contrast .hero {
  background: #000000 !important;
  color: #ffffff !important;
  box-shadow: none !important;
}
body.high-contrast .btn-catalog-nav, 
body.high-contrast .card-tag,
body.high-contrast .btn-primary,
body.high-contrast .catalog-search-box button {
  background-color: #ffff00 !important;
  color: #000000 !important;
  border: 2px solid #ffff00 !important;
}
body.high-contrast .card, 
body.high-contrast .site-header,
body.high-contrast .catalog-search-box,
body.high-contrast .service-box {
  border: 2px solid #ffffff !important;
  background-color: #000000 !important;
}
body.high-contrast .a11y-bar {
  background-color: #000000 !important;
  border-bottom: 2px solid #ffffff !important;
}
body.high-contrast .a11y-btn {
  background: transparent !important;
  border: 2px solid #ffff00 !important;
  color: #ffff00 !important;
}
body.high-contrast .live-status-pill {
  background: #000 !important;
  border: 2px solid #fff !important;
}
body.high-contrast a {
  color: #ffff00 !important;
  text-decoration: underline !important;
}
body.high-contrast h1, body.high-contrast h2, body.high-contrast h3, body.high-contrast h4, body.high-contrast h5 {
  color: #ffff00 !important;
}

body.font-large { --font-scale: 1.15; }
body.font-xlarge { --font-scale: 1.3; }

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

html {
  font-size: calc(16px * var(--font-scale));
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-page);
  background-image: url('../img/paper-texture.svg'); /* Fine paper texture */
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary-light); text-decoration: none; transition: color 0.2s ease, transform 0.2s; }
a:hover { color: var(--color-accent); }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

.container { width: 100%; max-width: var(--container-max); margin: 0 auto; padding: 0 1.5rem; }

/* Accessibility Top Bar */
.a11y-bar {
  background-color: var(--color-primary-dark);
  color: var(--text-inverse);
  font-size: 0.85rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.a11y-bar .container {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem;
}
.a11y-controls { display: flex; align-items: center; gap: 0.5rem; }
.a11y-btn {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2);
  padding: 4px 10px; border-radius: var(--border-radius-sm); cursor: pointer; font-size: 0.8rem; font-weight: 500;
  transition: all 0.2s;
}
.a11y-btn:hover { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.4); }

/* Site Header */
.site-header {
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 0;
}
.site-header .container {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}

.brand {
  display: flex; align-items: center; gap: 0.75rem;
}
.brand img {
  width: 48px; height: 48px;
}
.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
}
/* We hide the tagline on smaller screens to save space */
.brand-text p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.15rem;
  display: none;
}
@media (min-width: 1024px) {
  .brand-text p { display: block; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

.mobile-nav-toggle {
  display: none; background: none; border: none; font-size: 1.75rem; color: var(--color-primary); cursor: pointer; padding: 0.5rem;
}

.main-nav ul {
  display: flex; list-style: none; gap: 1.5rem; align-items: center; margin: 0; padding: 0;
}
.main-nav a {
  color: var(--text-muted); font-weight: 600; font-size: 0.95rem; white-space: nowrap;
  padding: 0.5rem 0; border-bottom: 2px solid transparent;
}
.main-nav a:hover {
  color: var(--color-primary);
  border-bottom-color: var(--color-accent);
}

.btn-catalog-nav {
  background-color: var(--color-accent);
  color: #fff !important;
  padding: 0.6rem 1.75rem;
  border-radius: var(--border-radius-pill);
  font-weight: 700 !important;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  border: none !important;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-catalog-nav:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

@media (max-width: 1024px) {
  .mobile-nav-toggle { display: block; }
  .main-nav {
    display: none; position: absolute; top: 100%; left: 0; width: 100%;
    background: var(--bg-surface); padding: 1rem; box-shadow: var(--shadow-md);
    border-top: 1px solid var(--border-color);
  }
  .main-nav.active { display: block; }
  .main-nav ul { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .main-nav a { border-bottom: none; }
}

/* Announcement Banner */
.announcement-banner {
  padding: 1rem 0; font-size: 0.95rem; font-weight: 500; text-align: center; border-bottom: 1px solid rgba(0,0,0,0.05);
}
.announcement-banner.info { background-color: var(--color-primary-light); color: white; }
.announcement-banner.warning { background-color: var(--color-accent-light); color: var(--color-accent-hover); }
.announcement-banner.danger { background-color: var(--color-danger-bg); color: var(--color-danger); }
.announcement-banner .container { display: flex; align-items: center; justify-content: center; gap: 0.75rem; text-align: left; }
.announcement-banner span { font-size: 1.25rem; }

/* Hero Section */
.hero {
  background: linear-gradient(135deg, rgba(15, 36, 64, 0.95) 0%, rgba(21, 50, 89, 0.95) 100%), url('../img/bookshelf-pattern.svg');
  background-size: cover, 300px;
  background-position: center, top left;
  background-blend-mode: multiply, normal;
  color: var(--text-inverse);
  padding: 5.5rem 0;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 -10px 20px -10px rgba(0,0,0,0.3);
}
/* Decorative background shape for hero */
.hero::after {
  content: "";
  position: absolute;
  top: -50%; left: -10%; width: 120%; height: 200%;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.hero-content {
  max-width: 800px; margin: 0 auto; position: relative; z-index: 2;
}

.live-status-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(4px);
  padding: 0.5rem 1.25rem; border-radius: var(--border-radius-pill);
  font-size: 0.9rem; font-weight: 600; margin-bottom: 2rem;
  border: 1px solid rgba(255,255,255,0.2);
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; background-color: #cbd5e1; }
.status-dot.open { background-color: #34d399; box-shadow: 0 0 8px #34d399; }
.status-dot.closed { background-color: #f87171; box-shadow: 0 0 8px #f87171; }

.hero h2 {
  font-family: var(--font-heading); font-size: 2.75rem; font-weight: 700; line-height: 1.2; margin-bottom: 1rem; text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.hero .subtitle {
  font-size: 1.2rem; color: #cbd5e1; margin-bottom: 2.5rem; font-weight: 400;
}

.catalog-search-box {
  display: flex; gap: 0.5rem; background: var(--bg-surface); padding: 0.5rem;
  border-radius: var(--border-radius-pill); max-width: 640px; margin: 0 auto 2.5rem auto;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.catalog-search-box input {
  flex: 1; border: none; background: transparent; padding: 0.75rem 1.5rem;
  font-size: 1.05rem; font-family: var(--font-primary); color: var(--text-main);
  outline: none; border-radius: var(--border-radius-pill);
}
.catalog-search-box button {
  background: var(--color-accent); color: #fff; border: none; padding: 0.75rem 2rem;
  border-radius: var(--border-radius-pill); font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: background 0.2s; white-space: nowrap;
}
.catalog-search-box button:hover { background: var(--color-accent-hover); }

.hero-quick-actions {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem;
}
.btn-secondary-hero {
  background: rgba(255,255,255,0.1); color: #fff; padding: 0.65rem 1.25rem;
  border-radius: var(--border-radius-pill); border: 1px solid rgba(255,255,255,0.2);
  font-size: 0.95rem; font-weight: 500; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.btn-secondary-hero:hover {
  background: rgba(255,255,255,0.2); transform: translateY(-2px); border-color: rgba(255,255,255,0.4); color: #fff;
}

/* Sections */
.section { padding: 5rem 0; }
.alt-bg { background-color: var(--bg-surface-alt); }
.section-header { text-align: center; max-width: 700px; margin: 0 auto 3.5rem auto; }
.section-header h3 { font-family: var(--font-heading); font-size: 2.25rem; color: var(--color-primary); margin-bottom: 0.5rem; }
.section-header p { font-size: 1.1rem; color: var(--text-muted); }

/* Grids */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }

/* Cards */
.card {
  background: var(--bg-surface);
  border-radius: var(--border-radius-md);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03), inset 0 0 0 1px rgba(255,255,255,0.5);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex; flex-direction: column;
  position: relative;
}
.card:hover {
  transform: translateY(-4px); 
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  border-color: #cbd5e1;
}
.card-img {
  width: 100%; height: 220px; object-fit: cover; border-bottom: 1px solid var(--border-color);
}
.card-body { padding: 1.5rem; flex: 1; display: flex; flex-direction: column; position: relative; }
.card-tag {
  position: absolute;
  top: -12px;
  right: 20px;
  background: var(--color-accent);
  color: #fff;
  padding: 1rem 0.75rem 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% 85%, 0% 100%);
  z-index: 10;
}
.card-title {
  font-family: var(--font-heading); font-size: 1.35rem; color: var(--color-primary-dark); margin-bottom: 0.5rem; line-height: 1.3;
  margin-top: 0.5rem; /* Space for the bookmark */
}
.card-meta { font-size: 0.85rem; color: var(--text-light); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.card-text { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; }

.event-date-badge {
  background: var(--color-accent-light); color: var(--color-accent-hover);
  padding: 0.4rem 0.75rem; border-radius: var(--border-radius-sm); font-size: 0.85rem; font-weight: 700;
  margin-bottom: 1rem; display: inline-flex; align-items: center; gap: 0.4rem;
}

/* Services */
.service-box {
  background: var(--bg-surface); padding: 2rem; border-radius: var(--border-radius-md);
  text-align: center; border: 1px solid var(--border-color); transition: box-shadow 0.2s;
}
.service-box:hover { box-shadow: var(--shadow-md); }
.service-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.service-box h4 { font-family: var(--font-heading); color: var(--color-primary); margin-bottom: 0.5rem; font-size: 1.25rem; }
.service-box p { font-size: 0.95rem; color: var(--text-muted); }

/* Banner Tritius */
.palmknihy-banner {
  background: linear-gradient(to right, #1e3a8a, #3b82f6); color: white; border-radius: var(--border-radius-md);
  padding: 2.5rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 2rem; margin-top: 3rem;
  box-shadow: var(--shadow-md);
}
.palmknihy-content h4 { font-family: var(--font-heading); font-size: 1.5rem; margin-bottom: 0.5rem; }
.palmknihy-content p { color: #bfdbfe; font-size: 1rem; max-width: 600px; }
.btn-palmknihy {
  background: #fff; color: #1e3a8a !important; padding: 0.8rem 1.5rem; border-radius: var(--border-radius-pill);
  font-weight: 700; white-space: nowrap; box-shadow: var(--shadow-sm); transition: transform 0.2s;
}
.btn-palmknihy:hover { transform: scale(1.05); }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.9rem; color: var(--color-primary-dark); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: var(--border-radius-sm);
  font-family: var(--font-primary); font-size: 1rem; background: var(--bg-surface); color: var(--text-main);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--color-primary-light); outline: none; box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.15);
}

.btn-primary {
  background: var(--color-primary); color: #fff; border: none; padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-sm); font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: background 0.2s, transform 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary:hover { background: var(--color-primary-light); transform: translateY(-1px); }

/* Tables */
.hours-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.hours-table td { padding: 0.85rem 0.5rem; border-bottom: 1px solid var(--border-color); font-size: 1rem; }
.hours-table tr:last-child td { border-bottom: none; }
.hours-table tr.today td { background-color: var(--color-success-bg); color: var(--color-success); border-radius: var(--border-radius-sm); padding-left: 0.75rem; padding-right: 0.75rem; border-bottom: none; }

/* Pricing badges */
.pricing-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pricing-badge {
  padding: 0.4rem 0.85rem; border-radius: var(--border-radius-pill); font-size: 0.85rem;
  display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 500; border: 1px solid var(--border-color); color: var(--text-main);
}

.contact-info-list { list-style: none; display: flex; flex-direction: column; gap: 1.25rem; }
.contact-info-list li { display: flex; gap: 1rem; align-items: flex-start; }
.contact-icon { font-size: 1.5rem; background: var(--bg-surface-alt); padding: 0.5rem; border-radius: var(--border-radius-sm); line-height: 1; }

/* Footer */
.site-footer {
  background-color: var(--color-primary-dark); color: #cbd5e1; padding: 4rem 0 1.5rem 0; margin-top: auto;
}
.site-footer h5 { color: #fff; font-size: 1.1rem; margin-bottom: 1rem; font-family: var(--font-heading); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 3rem; margin-bottom: 3rem; }
.site-footer ul { list-style: none; }
.site-footer ul li { margin-bottom: 0.5rem; }
.site-footer a { color: #cbd5e1; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.footer-bottom { text-align: center; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.85rem; }

@media (max-width: 768px) {
  .hero h2 { font-size: 2rem; }
  .catalog-search-box { flex-direction: column; border-radius: var(--border-radius-sm); }
  .catalog-search-box input { border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0; }
  .catalog-search-box button { border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm); width: 100%; }
  .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
}

/* Utils */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.text-center { text-align: center; }

/* ==========================================================================
   Admin Panel Styles
   ========================================================================== */

.admin-body {
  background-color: #f1f5f9;
  font-family: var(--font-primary);
  color: var(--text-main);
  min-height: 100vh;
}

.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 260px;
  background-color: var(--color-primary-dark);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.admin-sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-sidebar-header h2 {
  font-size: 1.2rem;
  color: #fff;
  font-family: var(--font-heading);
}

.admin-nav {
  list-style: none;
  padding: 1rem 0;
  margin: 0;
  flex: 1;
}

.admin-nav-item {
  width: 100%;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.5rem;
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border-left: 4px solid transparent;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.admin-nav-link:hover {
  background-color: rgba(255,255,255,0.08);
  color: #fff;
}

.admin-nav-link.active {
  background-color: rgba(255,255,255,0.12);
  color: #fff;
  border-left-color: var(--color-accent);
  font-weight: 700;
}

.admin-sidebar-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  background: #fff;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.admin-content {
  padding: 2rem;
  flex: 1;
  max-width: 1100px;
}

.admin-panel {
  display: none;
  background: #fff;
  padding: 2rem;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.admin-panel.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-danger {
  background-color: #dc2626;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-danger:hover { background-color: #b91c1c; color: #fff; }

@media (max-width: 850px) {
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .admin-content { padding: 1rem; }
}
