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

:root {
  --background: #252525;
  --foreground: #fafafa;
  --card: #343434;
  --card-foreground: #fafafa;
  --primary: #0891b2;
  --primary-foreground: #fafafa;
  --secondary: #f97316;
  --secondary-foreground: #fafafa;
  --muted: #454545;
  --muted-foreground: #b5b5b5;
  --accent: #f97316;
  --accent-foreground: #fafafa;
  --destructive: #dc2626;
  --destructive-foreground: #fafafa;
  --border: #454545;
  --input: #343434;
  --ring: #0891b2;
  --radius: 12px;

  /* layout */
  --sidebar-w: 320px;
  --header-h: 64px;
  --page-gutter: 24px;
}

body {
  font-family: "Vazirmatn", "IRANSans", sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  direction: rtl;
  line-height: 1.6;
}

/* Make page a flex column so footer sits at bottom */
.min-h-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1 0 auto;
}

.site-footer {
  margin-top: auto;
}

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

/* Back button placed in the left corner of the header (RTL pages) */
.back-button {
  position: absolute;
  left: var(--page-gutter);
  top: 80px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-foreground);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color .12s, transform .08s;
  z-index: 60;
}
.back-button:hover { background-color: #0e7490; transform: translateY(-1px); }
.back-button .icon { width: 16px; height: 16px; color: var(--primary-foreground); }



.header-content {
  display: flex;
  height: var(--header-h);
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-gutter);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  display: flex;
  height: 32px;
  width: 32px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background-color: var(--primary);
}

.logo-icon .icon {
  height: 16px;
  width: 16px;
  color: var(--primary-foreground);
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--foreground);
}

/* ========== User Dropdown ========== */
.user-dropdown {
  position: relative;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.2s;
}

.user-button:hover {
  background-color: var(--muted);
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--foreground);
}

.avatar {
  height: 32px;
  width: 32px;
  border-radius: 50%;
  background-color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-icon {
  height: 16px;
  width: 16px;
  color: var(--muted-foreground);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 192px;
  background-color: rgb(46, 46, 46);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all .2s;
  z-index: 100;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--card-foreground);
  transition: background-color .2s;
}

.dropdown-item:hover {
  background-color: var(--muted);
}

.dropdown-item.logout {
  color: var(--destructive);
}

.dropdown-item.logout:hover {
  background-color: rgba(220, 38, 38, .1);
}

.dropdown-icon {
  height: 16px;
  width: 16px;
}

/* ========== Layout Grid ========== */
.main-content {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 32px var(--page-gutter);
}

/* Base (mobile/tablet): stack main then sidebar */
.content-grid {
  display: grid;
  gap: 32px;
  grid-template-columns: 1fr;
  grid-template-areas:
    "main"
    "sidebar";
}

.main-area {
  grid-area: main;
}

.sidebar {
  grid-area: sidebar;
}

/* Desktop: dock sidebar under header on the far right */
@media (min-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr;
    /* sidebar goes fixed; grid is single col */
    grid-template-areas: "main";
  }

  .sidebar {
    position: fixed;
    top: calc(var(--header-h) + 16px);
    right: var(--page-gutter);
    width: var(--sidebar-w);
    z-index: 40;
  }


}

/* ========== Sidebar ========== */
.sidebar-card {
  border: 1px solid var(--border);
  background-color: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1);
}

.sidebar-header {
  padding: 24px 24px 16px;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--card-foreground);
}

.sidebar-icon {
  height: 20px;
  width: 20px;
  color: var(--primary);
}

.sidebar-content {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.stat-label {
  color: var(--muted-foreground);
}

.stat-badge {
  display: inline-block;
  background-color: var(--primary);
  color: var(--primary-foreground);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.stat-badge.active {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}

.stat-value {
  font-size: 12px;
  color: var(--muted-foreground);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

/* ========== Main Area ========== */
.content-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 8px;
}

.page-description {
  color: var(--muted-foreground);
}

/* PDFs Grid */
.pdfs-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

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

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

.pdf-card {
  border: 1px solid var(--border);
  background-color: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
  transition: all .2s;
}

.pdf-card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, .15);
  transform: translateY(-4px);
}

.pdf-content {
  padding: 24px;
}

.pdf-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.pdf-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pdf-icon {
  display: flex;
  height: 40px;
  width: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background-color: rgba(8, 145, 178, .1);
}

.pdf-icon .icon {
  height: 20px;
  width: 20px;
  color: var(--primary);
}

.pdf-title {
  font-weight: 600;
  color: var(--card-foreground);
  margin-bottom: 4px;
}

.pdf-date {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted-foreground);
}

.clock-icon {
  height: 12px;
  width: 12px;
}

.pdf-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background-color: var(--primary);
  color: var(--primary-foreground);
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 500;
  transition: background-color .2s;
}

.pdf-button:hover {
  background-color: #0e7490;
}

.button-icon {
  height: 16px;
  width: 16px;
}

/* ========== Empty State ========== */
.empty-state {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  background-color: var(--card);
  border-radius: var(--radius);
}

.empty-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  text-align: center;
}

.empty-icon {
  height: 48px;
  width: 48px;
  color: var(--muted-foreground);
  margin-bottom: 16px;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--card-foreground);
  margin-bottom: 8px;
}

.empty-description {
  color: var(--muted-foreground);
}

/* ========== Footer ========== */
.site-footer {
  border-top: 1px solid var(--border);
  background: transparent;
}

.footer-content {
  text-align: center;
  padding: 10px 0;
}

.footer-text {
  color: var(--muted-foreground);
}

/* ========== Misc / Safety ========== */
.header-content,
.sidebar-card,
.pdf-card {
  max-width: 100%;
  overflow-wrap: anywhere;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--muted);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}