/* ==========================================================================
   Project Report Generator - Base & App Styles
   ========================================================================== */
:root {
  --bg-color: #f8fafc;
  --sidebar-bg: rgba(255, 255, 255, 0.95);
  --border-color: #e2e8f0;
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --page-border-blue: #010080;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.app-container { display: flex; height: 100vh; width: 100vw; }

/* ── Sidebar ── */
.sidebar {
  width: 420px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: 4px 0 24px rgba(0,0,0,0.06);
}

.sidebar-header {
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-header h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.sidebar-header p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.4; }

.header-links { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.team-section { width: 100%; margin-top: 8px; }
.team-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.team-names { display: flex; flex-wrap: wrap; gap: 5px; }
.team-names span, .team-names a { font-size: 0.72rem; background: #e0e7ff; color: var(--primary-color); padding: 3px 8px; border-radius: 4px; font-weight: 500; text-decoration: none; transition: background 0.2s, transform 0.1s; }
.team-names a:hover { background: #c7d2fe; }
.team-names a:active { transform: scale(0.96); }
.acknowledgement a { color: inherit; text-decoration: none; }
.acknowledgement a:hover strong { text-decoration: underline; }
.acknowledgement { font-size: 0.7rem; color: var(--text-muted); margin-top: 6px; font-style: italic; }
.acknowledgement strong { color: var(--text-main); font-weight: 600; }
.creator-credit {
  font-size: 0.8rem !important;
  color: var(--primary-color) !important;
  background: #e0e7ff;
  padding: 4px 8px;
  border-radius: 4px;
}
.creator-credit strong { font-weight: 700; }
.header-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.78rem; text-decoration: none; font-weight: 600;
  padding: 5px 10px; border-radius: 6px; transition: background 0.2s;
}
.github-link { color: var(--text-main); background: #e2e8f0; }
.github-link:hover { background: #cbd5e1; }
.mail-link { color: #92400e; background: #fef3c7; }
.mail-link:hover { background: #fde68a; }

/* ── Page Nav ── */
.page-nav { display: flex; gap: 0; margin-top: 14px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-color); }
.page-nav-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 12px; font-size: 0.8rem; font-weight: 600; text-decoration: none; color: var(--text-muted); background: var(--sidebar-bg); transition: all 0.2s; }
.page-nav-tab:hover { background: #1e293b; color: #fff; }
.page-nav-tab.active { background: var(--primary-color); color: #fff; pointer-events: none; }

/* ── Form ── */
#generator-form {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}
#generator-form::-webkit-scrollbar { width: 6px; }
#generator-form::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.sidebar-divider { border: none; border-top: 1px solid var(--border-color); margin: 4px 0; }

h4 {
  font-size: 0.82rem; text-transform: uppercase;
  color: var(--primary-color); letter-spacing: 1.5px;
  font-weight: 700; margin-bottom: -2px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; min-width: 0; }

label { font-size: 0.83rem; font-weight: 600; color: var(--text-main); }

input[type="text"], select {
  width: 100%; padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 0.92rem; font-family: inherit;
  background: #fff; color: #334155;
  transition: all 0.2s ease;
}
input[type="text"]:focus, select:focus {
  outline: none; border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

.student-entry { margin-bottom: 10px; position: relative; }
.btn-remove-student {
  position: absolute; top: 24px; right: -2px;
  background: #fee2e2; color: #dc2626; border: none;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 1rem; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.btn-remove-student:hover { background: #fca5a5; }
.btn-add-student {
  background: #f1f5f9; color: var(--primary-color);
  border: 1px dashed var(--primary-color); border-radius: 8px;
  padding: 8px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
}
.btn-add-student:hover { background: #e0e7ff; }

/* ── Footer Buttons ── */
.sidebar-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border-color);
  display: flex; flex-direction: column; gap: 10px;
}

.sidebar-actions {
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex; flex-direction: column; gap: 10px;
}

.btn-primary, .btn-secondary {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 13px; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s ease; border: none;
}
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(79,70,229,0.25); }
.btn-primary:active { transform: translateY(0) scale(0.98); }

/* Word export buttons */
.word-export-row { display: flex; gap: 10px; }
.btn-word {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px; border-radius: 10px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: none; background: #2b579a; color: #fff;
  transition: all 0.2s ease;
}
.btn-word:hover { background: #1e3f70; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(43,87,154,0.25); }
.btn-word:active { transform: translateY(0) scale(0.98); }
.btn-word-alt { background: #41a5ee; }
.btn-word-alt:hover { background: #2b8fd9; box-shadow: 0 4px 12px rgba(65,165,238,0.25); }
.btn-word:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.merge-section {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 12px; border-top: 1px dashed var(--border-color); margin-top: 2px;
}
.page-select { margin-bottom: 4px; }
.page-checkboxes {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px;
}
.page-checkboxes label {
  font-size: 0.8rem; font-weight: 500;
  display: flex; align-items: center; gap: 4px; cursor: pointer;
}
.merge-label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.upload-area {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1.5px dashed #cbd5e1; border-radius: 10px;
  cursor: pointer; font-size: 0.85rem; color: var(--text-muted);
  background: #f8fafc; transition: all 0.2s ease;
}
.upload-area:hover { border-color: var(--primary-color); background: #f5f3ff; color: var(--primary-color); }
.upload-area.has-file { border-style: solid; border-color: #22c55e; background: #f0fdf4; color: #16a34a; font-weight: 600; }

.btn-merge {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 13px; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  border: none; background: linear-gradient(135deg, #1e293b, #0f172a); color: #fff;
  transition: all 0.2s ease;
}
.btn-merge:hover:not(:disabled) { background: linear-gradient(135deg, #334155, #1e293b); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(15,23,42,0.3); }
.btn-merge:disabled { opacity: 0.35; cursor: not-allowed; }

/* ==========================================================================
   Preview Area
   ========================================================================== */
.preview-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.preview-toolbar {
  height: 56px; background: rgba(255,255,255,0.85);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; font-size: 0.95rem; font-weight: 600;
  backdrop-filter: blur(12px);
}
.zoom-controls {
  display: flex; align-items: center; gap: 14px;
  background: #fff; padding: 5px 12px; border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.zoom-controls button {
  background: none; border: none; font-size: 1.2rem;
  cursor: pointer; width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background 0.2s;
}
.zoom-controls button:hover { background: #f1f5f9; }

.preview-wrapper {
  flex: 1; overflow: auto; padding: 30px;
  display: flex; justify-content: center; align-items: flex-start;
}

/* ==========================================================================
   A4 PAGE TEMPLATE - Exact PDF Replica
   ========================================================================== */
#template-root {
  transform-origin: top center;
  transition: transform 0.2s ease;
  display: flex; flex-direction: column; gap: 30px;
}

.page {
  width: 794px;
  height: 1123px;
  background: #fff;
  font-family: "Times New Roman", Times, serif;
  color: #000;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}

/* ── BORDER: Thin black outline + thick blue rounded border + corner squares ── */
.page-border {
  position: absolute;
  top: 24px; left: 24px; right: 24px; bottom: 24px;
  border: 5px solid var(--page-border-blue);
  border-radius: 10px;
  outline: 2px solid #000;
  outline-offset: 3px;
}

/* Corner squares - filled blue squares at each corner */
.page-border::before,
.page-border::after,
.corner-bl,
.corner-br {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--page-border-blue);
  border: 2px solid #000;
}
.page-border::before { top: -9px; left: -9px; }
.page-border::after { top: -9px; right: -9px; }
.corner-bl { bottom: -9px; left: -9px; }
.corner-br { bottom: -9px; right: -9px; }

/* Inner content area */
.page-content {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 50px 55px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* Page 1 specific: shrink logos/spacing when content is long */
#page-1 .page-content {
  justify-content: space-between;
}
#page-1 .vtu-logo { height: 100px; }
#page-1 .dbit-logo { height: 90px; }
#page-1 .tp-guidance-section { margin: 10px 0 8px; }
#page-1 .tp-footer { margin-top: 0; }

/* ── Shared elements ── */
.logo-container { display: flex; justify-content: center; width: 100%; }
.vtu-logo { height: 130px; width: auto; object-fit: contain; }
.dbit-logo { height: 115px; width: auto; object-fit: contain; }

.page-number-section {
  margin-top: auto;
  width: 100%;
  text-align: center;
  padding-top: 15px;
}
.page-number-section .pn-line {
  width: 200px;
  height: 1px;
  background: #000;
  margin: 0 auto 4px;
}
.page-number-section .pn-num {
  font-size: 11pt;
}

/* ==========================================================================
   PAGE 1: TITLE PAGE
   ========================================================================== */
.tp-university-name {
  font-size: 18pt;
  font-weight: bold;
  text-align: center;
  margin-bottom: 3px;
}
.tp-university-addr {
  font-size: 12pt;
  text-align: center;
  margin-bottom: 10px;
}

.tp-report-line {
  font-size: 14pt;
  text-align: center;
  margin-top: 8px;
}
.tp-on {
  font-size: 14pt;
  font-weight: bold;
  text-align: center;
  margin: 2px 0;
}
.tp-project-title {
  font-size: 14pt;
  font-weight: bold;
  color: #ff0000;
  text-align: center;
  margin-bottom: 8px;
}

.tp-italic {
  font-size: 12pt;
  font-style: italic;
  text-align: center;
  margin: 6px 0 3px;
}
.tp-degree {
  font-size: 14pt;
  text-align: center;
  color: #b90000;
}
.tp-in {
  font-size: 14pt;
  text-align: center;
}
.tp-branch {
  font-size: 14pt;
  text-align: center;
}
.tp-by {
  font-size: 14pt;
  text-align: center;
  margin: 4px 0;
}

.tp-students-table {
  width: 56%;
  margin: 0 auto;
  font-size: 14pt;
  line-height: 1.7;
}
.tp-students-table table { width: 100%; border-collapse: collapse; }
.tp-students-table td { padding: 1px 6px; vertical-align: top; }
.tp-students-table td:first-child { text-align: left; white-space: nowrap; }
.tp-students-table td:last-child { text-align: right; white-space: nowrap; }

.tp-guidance-section {
  text-align: center;
  margin: 18px 0 14px;
}
.tp-guidance-section .tp-italic {
  color: #006cb9;
  font-size: 14pt;
}
.tp-guide-name {
  font-size: 14pt;
  font-weight: bold;
  margin-top: 4px;
}
.tp-guide-info {
  font-size: 12pt;
  text-align: center;
}

.tp-footer {
  text-align: center;
  margin-top: auto;
}
.tp-college-name {
  font-size: 14pt;
  font-weight: bold;
}
.tp-dept-name {
  font-size: 14pt;
  font-weight: bold;
  color: #006cb9;
}
.tp-address {
  font-size: 12pt;
  font-weight: bold;
  margin-top: 2px;
}
.tp-year {
  font-size: 12pt;
  font-weight: bold;
  margin-top: 2px;
}

/* ==========================================================================
   PAGE 2: CERTIFICATE
   ========================================================================== */
.cert-header { text-align: center; width: 100%; margin-bottom: 12px; }
.cert-college-name { font-size: 16pt; font-weight: bold; }
.cert-address { font-size: 12pt; font-weight: bold; margin-top: 3px; }
.cert-dept { font-size: 14pt; font-weight: bold; margin-top: 14px; }

.cert-title {
  font-size: 16pt;
  text-align: center;
  margin-top: 28px;
  letter-spacing: 1px;
}
.cert-underline {
  width: 110px;
  height: 2.5px;
  background: #000;
  margin: 5px auto 25px;
}

.cert-body {
  font-size: 12pt;
  line-height: 2;
  text-align: justify;
  width: 100%;
}

.cert-signatures {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: auto;
  padding-top: 30px;
}
.cert-sig-block { text-align: center; flex: 1; }
.cert-sig-label { font-size: 12pt; font-weight: bold; margin-bottom: 30px; }
.cert-sig-dots { font-size: 12pt; font-weight: bold; margin-bottom: 5px; letter-spacing: -0.5px; }
.cert-sig-name { font-size: 10pt; font-weight: bold; }
.cert-sig-info { font-size: 10pt; font-weight: bold; }
.cert-sig-italic { font-style: italic; font-weight: normal; font-size: 9pt; }

/* ==========================================================================
   PAGE 3: DECLARATION
   ========================================================================== */
.decl-header { text-align: center; width: 100%; margin-bottom: 12px; }
.decl-college-name { font-size: 16pt; font-weight: bold; }
.decl-address { font-size: 12pt; margin-top: 3px; }
.decl-dept { font-size: 14pt; font-weight: bold; margin-top: 14px; }

.decl-title {
  font-size: 16pt;
  font-weight: bold;
  text-align: center;
  margin-top: 30px;
  margin-bottom: 25px;
}

.decl-body {
  font-size: 12pt;
  line-height: 2;
  text-align: justify;
  width: 100%;
}

.decl-footer {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: auto;
  padding-top: 30px;
  align-items: flex-end;
}
.decl-place { font-size: 12pt; font-weight: bold; }
.decl-student-sigs {
  font-size: 12pt;
  font-weight: bold;
  line-height: 1.8;
  text-align: left;
}
.decl-student-sigs table { border-collapse: collapse; }
.decl-student-sigs td { padding: 1px 8px; font-size: 12pt; font-weight: bold; }

/* ==========================================================================
   PAGE 4: ACKNOWLEDGEMENT
   ========================================================================== */
.ack-title {
  font-size: 18pt;
  font-weight: bold;
  text-align: center;
  margin-bottom: 30px;
}
.ack-body {
  font-size: 12pt;
  line-height: 2;
  text-align: justify;
  width: 100%;
}
.ack-body p { margin-bottom: 18px; }

/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */
@media screen and (max-width: 768px) {
  .app-container { flex-direction: column; overflow-y: auto; }
  body { overflow-y: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); flex: none; }
  #generator-form { overflow-y: visible; }
  .preview-area { flex: none; overflow: visible; }
  .preview-wrapper { padding: 20px; overflow-x: auto; justify-content: flex-start; }
  #template-root { transform-origin: top left; }
  .preview-toolbar { z-index: 10; position: sticky; top: 0; }
}
