/* Mobile-first professional refinements for the public/personal catalog */
:root {
  --pl-bg: #f4f7fb;
  --pl-surface: #ffffff;
  --pl-text: #162033;
  --pl-muted: #64748b;
  --pl-border: #dbe4ee;
  --pl-primary: #1976D2;
  --pl-primary-dark: #075394;
  --pl-radius: 18px;
  --pl-shadow: 0 14px 34px rgba(15, 23, 42, .08);
  --pl-safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { background: var(--pl-bg); color: var(--pl-text); line-height: 1.9; }
a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(25, 118, 210, .28) !important;
  outline-offset: 3px;
}
.header {
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid rgba(219,228,238,.9);
  box-shadow: 0 10px 28px rgba(15,23,42,.05);
}
.header-elements { max-width: 1200px; margin: 0 auto; align-items: center; padding: 10px 18px; gap: 12px; }
.header img { padding: 0 !important; margin: 0 !important; width: 58px; max-width: 58px !important; height: auto; }
.header strong { font-size: 18px; }
.login-signup, .logout-btn { margin: 0 !important; padding: 0 !important; }
.login-signup a, .logout-btn a { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; }
.menu { padding: 0 !important; border-bottom-width: 3px !important; }
.menu ul { max-width: 1200px; margin: 0 auto; padding: 0 18px; gap: 4px; }
.menu ul li a { display: block; border-radius: 12px; padding: .9rem 1rem !important; font-weight: 800; }
.personal-note { box-shadow: var(--pl-shadow); border-radius: 16px !important; }
.site-menu-toggle { display: none; }

.books-container, .categories-container { gap: 18px; }
.book, .book-box, .category-box, .main-content, .sidebar, .disabled-feature {
  border-radius: var(--pl-radius) !important;
  box-shadow: var(--pl-shadow) !important;
  border: 1px solid rgba(219,228,238,.85);
}
.book { overflow: hidden; margin: 1rem !important; }
.book:hover { transform: translateY(-4px) !important; }
.book img { width: 100% !important; max-width: 280px; min-height: 390px !important; object-fit: cover; display: block; margin: 0 auto; }
.book-buttons a, .library-button, .request-borrow, .more-btn, .borrow-btn, .search-area button, .sidebar-search-box button {
  min-height: 44px; border-radius: 12px !important;
}
.search-area input, .sidebar-search-box input, input, select, textarea {
  min-height: 46px; font-size: 16px !important; border-radius: 12px !important;
}
.book-info { gap: 24px; align-items: flex-start; }
.site-footer, .footer { background: #fff !important; border-color: var(--pl-primary) !important; }
.footer-container { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 18px; padding: 0 18px; }
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links a { color: var(--pl-text); text-decoration: none; }
.footer-bottom { border-top: 1px solid var(--pl-border); margin-top: 18px; padding-top: 12px; }

@media (max-width: 900px) {
  body { padding-bottom: calc(12px + var(--pl-safe-bottom)); }
  .header { position: sticky; top: 0; z-index: 1000; backdrop-filter: blur(16px); }
  .header-elements { padding: 10px 12px; }
  .header-elements > a { min-width: 0; }
  .header strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44vw; display: inline-block; }
  .site-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 14px;
    background: var(--pl-primary);
    color: #fff;
    box-shadow: 0 10px 24px rgba(25,118,210,.28);
    font-size: 22px;
    cursor: pointer;
    margin-right: auto;
  }
  .login-signup a, .logout-btn a { padding: .75rem .9rem !important; font-size: 13px; box-shadow: none !important; }
  .menu {
    display: none;
    position: absolute;
    right: 10px;
    left: 10px;
    top: calc(100% + 8px);
    border: 1px solid var(--pl-border) !important;
    border-radius: 18px;
    box-shadow: 0 18px 34px rgba(15,23,42,.16);
    background: #fff !important;
    padding: 8px !important;
  }
  .menu.open { display: block; }
  .menu ul { display: grid !important; grid-template-columns: 1fr; padding: 0 !important; }
  .menu ul li a { min-height: 46px; }
  .personal-note { margin: 12px 10px !important; font-size: 13px !important; }

  .books-container, .categories-container { margin: 1rem 10px !important; display: grid !important; grid-template-columns: 1fr 1fr; gap: 12px; }
  .book { margin: 0 !important; }
  .book img { max-width: 100% !important; min-height: 250px !important; }
  .book .book-title { font-size: 14px; line-height: 1.8; }
  .book-buttons { flex-direction: column; }
  .book-buttons a { border-radius: 0 !important; }
  .latest-books, .library-categories, .category_title, .library-title { margin: 1.4rem 12px .7rem !important; max-width: none !important; font-size: 20px; }
  .library-button { width: calc(100% - 20px); padding: 1rem !important; }
  .search-area { margin: 1rem 10px !important; display: grid; gap: 8px; }
  .search-area input, .search-area button { width: 100% !important; }
  .library-container { margin: 1rem 10px !important; display: flex !important; flex-direction: column; }
  .main-content, .sidebar { width: 100% !important; margin: 0 0 12px !important; padding: 14px !important; position: static !important; }
  .book-box-info { display: grid !important; grid-template-columns: 96px 1fr; gap: 10px; padding: 12px !important; }
  .book-box img { width: 96px !important; }
  .more-info-button { margin: 10px 0 0 !important; grid-column: 1 / -1; display: grid; gap: 8px; }
  .more-info-button a { display: block; text-align: center; }
  .sidebar-search-box { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .sidebar-search-box input { width: 100% !important; }
  .book-info { flex-direction: column; padding: 18px 12px !important; }
  .book-info img { width: min(75vw, 250px) !important; margin: 0 auto; }
  .info { padding: 0 !important; }
  .book-description { padding: 18px 12px !important; }
  .modal-content { width: calc(100% - 20px) !important; }
  .footer-container { grid-template-columns: 1fr; padding: 0 14px; }
  .footer p { margin-right: 0 !important; }
}

@media (max-width: 520px) {
  .header img { width: 48px; max-width: 48px !important; }
  .header strong { font-size: 15px; max-width: 35vw; }
  .login-signup a, .logout-btn a { font-size: 0; width: 42px; height: 42px; padding: 0 !important; }
  .login-signup a::before { content: 'ورود'; font-size: 12px; }
  .logout-btn a::before { content: 'خروج'; font-size: 12px; }
  .books-container, .categories-container { grid-template-columns: 1fr; }
  .book img { min-height: 330px !important; }
  .book-box-info { grid-template-columns: 1fr; }
  .book-box img { width: 140px !important; margin: 0 auto; }
  h1 { font-size: 22px !important; line-height: 1.7; }
  h2 { font-size: 19px !important; line-height: 1.8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Login/auth page polish on small screens */
@media (max-width: 900px) {
  .auth-page {
    min-height: auto !important;
    padding: 18px 10px !important;
    background: linear-gradient(160deg, #edf5ff 0%, #f7f4ff 100%) !important;
  }
  .auth-container {
    width: 100% !important;
    border-radius: 20px !important;
    box-shadow: var(--pl-shadow) !important;
  }
  .auth-card { padding: 22px 16px !important; }
  .auth-logo { width: 68px !important; height: 68px !important; }
  .auth-form { gap: 1rem !important; }
  .form-options { align-items: flex-start !important; gap: 10px !important; }
  .btn-block { width: 100%; min-height: 48px; }
}
