/* Islamic Books – theme */
:root {
  --color-green-deep: #0d5c2e;
  --color-green-dark: #1a472a;
  --color-gold: #c9a227;
  --color-gold-dark: #b8860b;
  --color-cream: #faf8f5;
  --color-text: #1a1a1a;
  --color-text-muted: #4a4a4a;
  --color-border: rgba(13, 92, 46, 0.2);
  --font-heading: 'Amiri', 'Noto Naskh Arabic', serif;
  --font-body: 'Source Sans 3', 'Inter', system-ui, sans-serif;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-cream);
  min-height: 100vh;
}

/* Subtle Islamic geometric background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30z' fill='none' stroke='%230d5c2e' stroke-width='0.15' opacity='0.08'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--color-green-deep);
  text-decoration: none;
}
a:hover {
  color: var(--color-gold-dark);
  text-decoration: underline;
}

/* Layout */
.app-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--color-green-deep) 0%, var(--color-green-dark) 100%);
  color: #fff;
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow);
}
.app-header h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 600;
}
.app-header a {
  color: inherit;
  text-decoration: none;
}
.app-header a:hover {
  color: var(--color-gold);
  text-decoration: none;
}
.app-header .refresh-link {
  font-size: 0.9rem;
  opacity: 0.9;
}

.app-header-home {
  padding: 1.25rem 1.5rem;
}
.app-header-home .header-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
.app-header-home .logo-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.app-header-home .logo-link:hover {
  color: var(--color-gold);
  text-decoration: none;
}
.app-header-home .header-tagline {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  font-weight: 400;
  opacity: 0.92;
  font-family: var(--font-body);
}

.main-wrap {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: calc(100vh - 180px);
}

/* Footer */
.app-footer {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, var(--color-green-dark) 0%, #0f2e1c 100%);
  color: rgba(255, 255, 255, 0.9);
  margin-top: 3rem;
  padding: 2rem 1.5rem 1.5rem;
}
.app-footer a {
  color: var(--color-gold);
  text-decoration: none;
}
.app-footer a:hover {
  color: #fff;
  text-decoration: underline;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.footer-brand {
  margin-bottom: 1.5rem;
}
.footer-logo {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}
.footer-tagline {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.85;
}
.footer-contact {
  margin-bottom: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}
.footer-heading {
  margin: 0 0 0.75rem;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}
.footer-item {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.footer-label {
  display: inline-block;
  min-width: 4rem;
  opacity: 0.85;
}
.footer-bottom {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
}
.footer-copy {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.8;
}
@media (min-width: 600px) {
  .app-footer .footer-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: start;
  }
  .footer-bottom {
    grid-column: 1 / -1;
  }
}

/* Breadcrumb */
.breadcrumb {
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.breadcrumb a {
  color: var(--color-green-deep);
}
.breadcrumb span {
  margin: 0 0.35rem;
  color: var(--color-gold-dark);
}

/* Cards grid – home (folders) */
.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.folder-card {
  display: block;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  color: var(--color-text);
  text-decoration: none;
}
.folder-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(13, 92, 46, 0.12);
  text-decoration: none;
  color: var(--color-green-deep);
}
.folder-card .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--color-gold);
}
.folder-card .name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.1rem;
}

/* Folder view – list of subfolders and files */
.content-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.content-list li {
  margin-bottom: 0.5rem;
}
.content-list a.item-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.content-list a.item-link:hover {
  background: rgba(13, 92, 46, 0.04);
  border-color: var(--color-gold);
  text-decoration: none;
  color: var(--color-text);
}
.content-list .item-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(201, 162, 39, 0.15);
  border-radius: 6px;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.content-list .item-name {
  flex: 1;
  font-weight: 500;
}
.content-list .item-type {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  margin: 1rem 0 0.5rem;
  color: var(--color-green-dark);
}
.section-title:first-child {
  margin-top: 0;
}

/* View page – reader / player */
.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}
.viewer-header .back-link {
  color: var(--color-green-deep);
  font-weight: 500;
}
.viewer-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin: 0;
  color: var(--color-green-dark);
}
.viewer-fullscreen-wrap {
  position: relative;
}
.viewer-fullscreen-wrap:fullscreen,
.viewer-fullscreen-wrap:-webkit-full-screen,
.viewer-fullscreen-wrap:-moz-full-screen,
.viewer-fullscreen-wrap:-ms-fullscreen {
  background: #fff;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.viewer-fullscreen-wrap:fullscreen .pdf-viewer-wrap,
.viewer-fullscreen-wrap:-webkit-full-screen .pdf-viewer-wrap,
.viewer-fullscreen-wrap:-moz-full-screen .pdf-viewer-wrap,
.viewer-fullscreen-wrap:-ms-fullscreen .pdf-viewer-wrap {
  min-height: 100vh;
}
.viewer-fullscreen-wrap:fullscreen .media-player-wrap video,
.viewer-fullscreen-wrap:fullscreen .media-player-wrap audio,
.viewer-fullscreen-wrap:-webkit-full-screen .media-player-wrap video,
.viewer-fullscreen-wrap:-webkit-full-screen .media-player-wrap audio {
  max-width: 100%;
}
.viewer-fullscreen-wrap:fullscreen .image-viewer-wrap,
.viewer-fullscreen-wrap:-webkit-full-screen .image-viewer-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-fullscreen-wrap:fullscreen .image-viewer-wrap img,
.viewer-fullscreen-wrap:-webkit-full-screen .image-viewer-wrap img {
  max-height: 100vh;
  width: auto;
  max-width: 100%;
}

/* PDF viewer container – fully responsive */
.pdf-viewer-wrap {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 50vh;
  max-width: 100%;
  width: 100%;
}
.pdf-canvas-container {
  padding: 1rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  box-sizing: border-box;
}
.pdf-viewer-wrap canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}
@media (max-width: 768px) {
  .pdf-viewer-wrap {
    margin: 0 -0.5rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    min-height: 60vh;
  }
  .pdf-canvas-container {
    padding: 0.75rem;
  }
  .main-wrap {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* Audio / video */
.media-player-wrap {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  max-width: 700px;
  margin: 0 auto;
}
.media-player-wrap video,
.media-player-wrap audio {
  width: 100%;
  display: block;
}

/* Text content */
.text-content-wrap {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  white-space: pre-wrap;
  font-size: 1rem;
  line-height: 1.7;
}
.text-content-wrap.render-html {
  white-space: normal;
}
.text-content-wrap.render-html h1,
.text-content-wrap.render-html h2 {
  font-family: var(--font-heading);
  color: var(--color-green-dark);
}

/* Image viewer */
.image-viewer-wrap {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  text-align: center;
}
.image-viewer-wrap img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Spreadsheet / document table */
.spreadsheet-wrap {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow-x: auto;
  max-width: 100%;
}
.spreadsheet-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}
.spreadsheet-wrap th,
.spreadsheet-wrap td {
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}
.spreadsheet-wrap th {
  background: rgba(13, 92, 46, 0.08);
  font-weight: 600;
  color: var(--color-green-dark);
}

/* Document content (Word/ODT HTML output) */
.document-content-wrap {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
  overflow-x: auto;
}
.document-content-wrap h1,
.document-content-wrap h2,
.document-content-wrap h3 {
  font-family: var(--font-heading);
  color: var(--color-green-dark);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}
