/* ═══════════════════════════════════════════════════════════════════════════
   style.css — Attachment Form System
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg:          #f8f9fb;
  --white:       #ffffff;
  --border:      #e4e9f0;
  --border-focus:#1a3c5e;
  --text-primary:#0f1a2a;
  --text-secondary:#5a6882;
  --text-muted:  #94a3b8;
  --accent:      #1a3c5e;
  --accent-light:#e8f0f8;
  --accent-hover:#0f2a45;
  --success:     #15803d;
  --success-bg:  #f0fdf4;
  --success-border:#bbf7d0;
  --error:       #b91c1c;
  --error-bg:    #fef2f2;
  --error-border:#fecaca;
  --shadow-sm:   0 1px 3px rgba(15,26,42,.06), 0 1px 2px rgba(15,26,42,.04);
  --shadow-md:   0 4px 16px rgba(15,26,42,.08), 0 2px 6px rgba(15,26,42,.05);
  --shadow-lg:   0 8px 32px rgba(15,26,42,.10), 0 4px 12px rgba(15,26,42,.06);
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  0.2s ease;
  --font-body:   'DM Sans', -apple-system, sans-serif;
  --font-display:'DM Serif Display', Georgia, serif;
}

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

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Page Wrapper ────────────────────────────────────────────────────────── */
.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 760px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark { flex-shrink: 0; display: flex; }

.header-text {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.institution-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.header-divider {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-title-tag {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-tag {
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.header-link {
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.header-link:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 40px 24px 60px;
}

/* ── Form Container ──────────────────────────────────────────────────────── */
.form-container {
  max-width: 680px;
  margin: 0 auto;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.form-hero {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.hero-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.hero-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 520px;
}

/* ── Alert Messages ──────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  margin-bottom: 28px;
  border: 1px solid;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error);
}

.alert-icon { flex-shrink: 0; margin-top: 1px; }

.alert-text {
  font-size: 0.9rem;
  line-height: 1.5;
  font-weight: 500;
}

/* ── Instructions Card ───────────────────────────────────────────────────── */
.instructions-card {
  background: var(--accent-light);
  border: 1px solid #c8daf0;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 36px;
}

.instructions-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.instructions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.instructions-list li {
  font-size: 0.875rem;
  color: #2d4a6e;
  padding-left: 18px;
  position: relative;
  line-height: 1.55;
}

.instructions-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.8rem;
}

/* ── Form Card ───────────────────────────────────────────────────────────── */
.submission-form {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* ── Form Section ────────────────────────────────────────────────────────── */
.form-section {
  padding: 32px 36px;
}

@media (max-width: 600px) {
  .form-section { padding: 24px 20px; }
}

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.section-number {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--border);
  line-height: 1;
  flex-shrink: 0;
  margin-top: -2px;
}

.section-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.section-desc {
  font-size: 0.8375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 0 36px;
}

@media (max-width: 600px) {
  .section-divider { margin: 0 20px; }
}

/* ── Field Group ─────────────────────────────────────────────────────────── */
.field-group { display: flex; flex-direction: column; gap: 8px; }

.field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.required-dot {
  color: #e53e3e;
  margin-left: 2px;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.input-wrapper, .textarea-wrapper { position: relative; }

.form-input,
.form-textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  resize: vertical;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,60,94,.12);
}

.form-input:hover:not(:focus),
.form-textarea:hover:not(:focus) {
  border-color: #b8c4d6;
}

.form-input.input-error,
.form-textarea.input-error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(185,28,28,.1);
}

.inline-error {
  font-size: 0.8125rem;
  color: var(--error);
  margin-top: 4px;
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 5px;
  transition: color var(--transition);
}

/* ── Declaration Box ─────────────────────────────────────────────────────── */
.declaration-box {
  background: #fafbfc;
  border-top: 1px solid var(--border);
  padding: 24px 36px;
}

@media (max-width: 600px) {
  .declaration-box { padding: 20px; }
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}

.checkbox-input { display: none; }

.checkbox-custom {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--white);
  margin-top: 1px;
  position: relative;
  transition: all var(--transition);
}

.checkbox-input:checked + .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-input:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(42deg);
}

.checkbox-text {
  font-size: 0.8375rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── Submit Area ─────────────────────────────────────────────────────────── */
.submit-area {
  padding: 28px 36px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  background: var(--white);
}

@media (max-width: 600px) {
  .submit-area { padding: 20px; align-items: stretch; }
}

.submit-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: white;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 28px;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(26,60,94,.25);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:disabled,
.submit-btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.submit-btn.loading .btn-text::after {
  content: '...';
  animation: dots 1s infinite;
}

@keyframes dots {
  0%, 33%  { content: '.'; }
  34%, 66% { content: '..'; }
  67%, 100%{ content: '...'; }
}

@media (max-width: 600px) {
  .submit-btn { width: 100%; justify-content: center; }
}

.submit-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN PAGE STYLES
   ═══════════════════════════════════════════════════════════════════════════ */
.admin-body { background: var(--bg); }

.admin-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 60px;
}

.admin-header .header-inner { max-width: 1200px; }

.admin-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.admin-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.admin-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stats-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.stats-number {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--accent);
  line-height: 1;
}

.stats-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px 10px 42px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26,60,94,.1);
}

.search-clear {
  position: absolute;
  right: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition);
  white-space: nowrap;
}
.search-clear:hover { background: var(--border); color: var(--text-primary); }

.search-btn {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--white);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.search-btn:hover { background: var(--accent-hover); }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-container {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.data-table thead {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}

.data-table th {
  padding: 13px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.data-table tbody tr:last-child { border-bottom: none; }

.data-table tbody tr:hover { background: #fafcff; }

.data-table td {
  padding: 14px 16px;
  vertical-align: top;
}

.col-reg     { width: 170px; }
.col-att     { width: auto; }
.col-hub     { width: auto; }
.col-date    { width: 130px; }
.col-actions { width: 100px; }

.reg-badge {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.cell-text {
  max-width: 280px;
}

.text-preview {
  cursor: default;
}

.preview-text,
.full-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.expand-btn {
  display: inline-block;
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  margin-left: 4px;
  text-decoration: underline;
  text-decoration-style: dotted;
  transition: color var(--transition);
}
.expand-btn:hover { color: var(--accent-hover); }

.date-main {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.date-time {
  display: block;
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: var(--error);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.delete-btn:hover {
  background: var(--error-bg);
  border-color: var(--error);
}

.table-footer {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  text-align: right;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 64px 40px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.empty-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 16px 0 6px;
}

.empty-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  background: var(--white);
}

.site-footer p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .institution-name { display: none; }
  .header-divider { display: none; }
  .admin-page-header { align-items: flex-start; }
  .search-form { flex-direction: column; }
}
