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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: Georgia, 'Times New Roman', Times, serif;
  background: #f4f1ea;
  color: #1e1e1e;
  line-height: 1.7;
  text-align: justify;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: #3b2a1c;
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover { color: #6b4f34; }

img { max-width: 100%; height: auto; }

/* ===== Container ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

/* ===== Navigation ===== */
.navbar {
  background: #2b2118;
  color: #f4f1ea;
  padding: 16px 0;
  border-bottom: 4px solid #8b7355;
}
.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.nav-brand {
  font-size: 1.4rem;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.nav-links li a {
  display: inline-block;
  padding: 8px 16px;
  color: #d4c9b8;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.95rem;
  transition: background 0.2s, color 0.2s;
}
.nav-links li a:hover,
.nav-links li a.active {
  background: #4a3b2a;
  color: #f4f1ea;
}

/* ===== Typography ===== */
.page-header {
  text-align: center;
  margin: 40px 0 28px;
}
.page-header h1 {
  font-size: 2.2rem;
  color: #2b2118;
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.subtitle {
  font-size: 1.1rem;
  color: #5a4a3a;
  font-style: italic;
}

h2 {
  font-size: 1.5rem;
  color: #2b2118;
  margin-bottom: 16px;
  font-weight: 600;
}

/* ===== Controls Bar (Search & Sort) ===== */
.controls-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
}
.search-wrapper {
  flex: 1 1 300px;
  min-width: 200px;
}
.search-wrapper input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #c4b69c;
  border-radius: 6px;
  font-size: 1rem;
  background: #fcf9f4;
  color: #1e1e1e;
  font-family: inherit;
}
.search-wrapper input:focus {
  outline: none;
  border-color: #8b7355;
  box-shadow: 0 0 0 3px rgba(139,115,85,0.25);
}
.sort-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sort-wrapper label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #3b2a1c;
}
.sort-wrapper select {
  padding: 10px 14px;
  border: 2px solid #c4b69c;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fcf9f4;
  color: #1e1e1e;
  font-family: inherit;
  cursor: pointer;
}
.sort-wrapper select:focus {
  outline: none;
  border-color: #8b7355;
  box-shadow: 0 0 0 3px rgba(139,115,85,0.25);
}

/* ===== Document Grid ===== */
.document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}
.doc-card {
  background: #fcf9f4;
  border: 1px solid #d4c9b8;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.doc-card:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  transform: translateY(-3px);
}
.doc-card h3 {
  font-size: 1.15rem;
  color: #2b2118;
  margin-bottom: 8px;
  font-weight: 700;
}
.doc-card .doc-meta {
  font-size: 0.85rem;
  color: #7a6a5a;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #e8e0d2;
  display: flex;
  justify-content: space-between;
}
.doc-card .doc-type {
  display: inline-block;
  background: #e8e0d2;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #3b2a1c;
}
.doc-card .doc-date {
  font-style: italic;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #7a6a5a;
  font-style: italic;
  font-size: 1.15rem;
}

/* ===== Card (generic) ===== */
.card {
  background: #fcf9f4;
  border: 1px solid #d4c9b8;
  border-radius: 8px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.card h2 {
  text-align: center;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #2b2118;
  font-size: 0.95rem;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="file"] {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #c4b69c;
  border-radius: 6px;
  font-size: 1rem;
  background: #fcf9f4;
  color: #1e1e1e;
  font-family: inherit;
}
.form-group input:focus {
  outline: none;
  border-color: #8b7355;
  box-shadow: 0 0 0 3px rgba(139,115,85,0.25);
}
.form-group input[type="file"] {
  padding: 8px 10px;
}
.form-error {
  color: #b33a2a;
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 0.9rem;
  text-align: center;
}
.form-success {
  color: #2b6b3a;
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 0.9rem;
  text-align: center;
}
.form-help {
  text-align: center;
  color: #7a6a5a;
  font-style: italic;
  margin-top: 12px;
  font-size: 0.9rem;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 12px 28px;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
  text-align: center;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: #3b2a1c;
  color: #f4f1ea;
  width: 100%;
}
.btn-primary:hover { background: #5a4230; }
.btn-secondary {
  background: #8b7355;
  color: #fcf9f4;
  width: 100%;
}
.btn-secondary:hover { background: #a08a6a; }

/* ===== Modal (Viewer) ===== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal[aria-hidden="false"] {
  display: flex;
}
.modal-backdrop {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
}
.modal-content {
  position: relative;
  background: #fcf9f4;
  border-radius: 8px;
  max-width: 900px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 32px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 2rem;
  color: #5a4a3a;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}
.modal-close:hover { color: #2b2118; }
.viewer-body {
  padding: 8px 0;
  text-align: left;
}
.viewer-body iframe {
  width: 100%;
  min-height: 70vh;
  border: none;
}
.viewer-body img {
  display: block;
  max-width: 100%;
  margin: 0 auto;
}
.viewer-body pre {
  background: #f4f1ea;
  padding: 20px;
  border: 1px solid #d4c9b8;
  border-radius: 4px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.9rem;
  max-height: 70vh;
  overflow-y: auto;
}

/* ===== Authorized User List ===== */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f4f1ea;
  border: 1px solid #e0d6c4;
  border-radius: 6px;
  flex-wrap: wrap;
  gap: 8px;
}
.user-entry .user-info {
  font-size: 0.95rem;
}
.user-entry .user-info strong {
  color: #2b2118;
}
.user-entry .user-info em {
  color: #7a6a5a;
  font-size: 0.85rem;
}
.user-entry .btn-remove {
  background: #b33a2a;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: background 0.2s;
}
.user-entry .btn-remove:hover { background: #942e20; }

.section-divider {
  border: none;
  border-top: 1px solid #d4c9b8;
  margin: 28px 0;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  background: #2b2118;
  color: #a0907a;
  text-align: center;
  padding: 20px 0;
  font-size: 0.85rem;
  border-top: 4px solid #8b7355;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .nav-container { flex-direction: column; text-align: center; }
  .nav-links { justify-content: center; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .sort-wrapper { justify-content: stretch; }
  .sort-wrapper select { flex: 1; }
  .document-grid { grid-template-columns: 1fr; }
  .modal-content { padding: 20px; width: 95%; }
}
