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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f0f2f5;
  color: #1a1a2e;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Layout ===== */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Card ===== */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 30px;
  width: 100%;
}

/* ===== Logo ===== */
.logo {
  display: block;
  max-width: 180px;
  height: auto;
  margin: 0 auto 12px;
}

.card-header {
  text-align: center;
  margin-bottom: 16px;
}

.card-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 4px;
}

.card-header p {
  color: #6b7280;
  font-size: 0.88rem;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: #374151;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group input[type="file"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fafafa;
}

.form-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: #fff;
}

.required {
  color: #ef4444;
}

.input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* ===== Terms ===== */
.terms-group {
  margin-top: 12px;
}

.terms-box {
  max-height: 120px;
  overflow-y: auto;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 0.8rem;
  color: #4b5563;
  margin-bottom: 10px;
}

.terms-box h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: #1a1a2e;
}

.terms-box ol {
  padding-left: 20px;
}

.terms-box li {
  margin-bottom: 8px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  flex-shrink: 0;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-outline {
  background: transparent;
  color: #2563eb;
  border: 1px solid #2563eb;
}

.btn-outline:hover {
  background: #2563eb;
  color: #fff;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert ul {
  padding-left: 20px;
  margin: 0;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

/* ===== Error Page ===== */
.error-card {
  text-align: center;
  padding: 60px 40px;
}

.error-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  color: #f59e0b;
}

.error-card h1 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.error-card p {
  color: #6b7280;
  margin-bottom: 24px;
}

/* ===== Login ===== */
.login-card {
  max-width: 420px;
  margin: 0 auto;
}

.back-link {
  text-align: center;
  margin-top: 20px;
}

.back-link a {
  color: #6b7280;
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link a:hover {
  color: #2563eb;
}

/* ===== PDF Viewer ===== */
.viewer-body {
  background: #1a1a2e;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.viewer-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #16213e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-logo {
  height: 30px;
  width: auto;
}

.toolbar-title {
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.95rem;
}

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

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: background 0.2s;
}

.toolbar-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.toolbar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#pageInfo, #zoomLevel {
  color: #94a3b8;
  font-size: 0.85rem;
  min-width: 60px;
  text-align: center;
}

#viewerContainer {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 20px;
}

#pdfViewer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pdf-canvas {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  height: auto;
}

#loadingIndicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #94a3b8;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-text {
  color: #ef4444;
}

/* ===== Screenshot Protection Overlay ===== */
#screenshotOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a2e;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#screenshotOverlay.active {
  display: flex;
}

#screenshotOverlay p {
  color: #94a3b8;
  font-size: 1.1rem;
  max-width: 400px;
  line-height: 1.6;
}

/* ===== Admin ===== */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
}

.admin-header {
  background: #1a1a2e;
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-logo {
  height: 32px;
  width: auto;
}

.admin-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-user {
  font-size: 0.85rem;
  color: #94a3b8;
}

.admin-main {
  padding: 24px;
}

.admin-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.admin-section h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: #1a1a2e;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header h2 {
  margin-bottom: 0;
}

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

.search-input {
  padding: 8px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  width: 220px;
}

.search-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== Table ===== */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: #f8fafc;
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: #2563eb;
}

th.sort-asc::after {
  content: ' \25B2';
  font-size: 0.7rem;
}

th.sort-desc::after {
  content: ' \25BC';
  font-size: 0.7rem;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

tbody tr:hover {
  background: #f8fafc;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-error {
  background: #fef2f2;
  color: #991b1b;
}

/* ===== PDF Status ===== */
.pdf-status {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
}

.upload-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-form .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

.upload-form .btn {
  width: auto;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  color: #9ca3af;
  padding: 40px;
}

/* ===== Fit form to viewport ===== */
.form-card {
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

/* ===== Responsive ===== */
@media (max-height: 750px) {
  .logo {
    max-width: 140px;
    margin-bottom: 8px;
  }

  .card-header {
    margin-bottom: 10px;
  }

  .card-header h1 {
    font-size: 1.2rem;
  }

  .card {
    padding: 20px;
  }

  .form-group {
    margin-bottom: 8px;
  }

  .form-group input[type="text"],
  .form-group input[type="email"],
  .form-group input[type="tel"],
  .form-group input[type="password"] {
    padding: 8px 12px;
  }

  .terms-box {
    max-height: 80px;
    padding: 8px 12px;
  }

  .terms-group {
    margin-top: 8px;
  }

  .btn {
    padding: 8px 20px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .card {
    padding: 20px;
  }

  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-header-right {
    flex-wrap: wrap;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-actions {
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .upload-form {
    flex-direction: column;
  }

  .upload-form .btn {
    width: 100%;
  }

  .viewer-toolbar {
    padding: 0 10px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .toolbar-left {
    width: 100%;
    text-align: center;
  }

  #viewerContainer {
    top: 90px;
  }
}
