/* ==========================================================================
   JPLAN CONVERTER - MODERN DESIGN SYSTEM & STYLESHEET
   DepEd ILAW Lesson Plan Converter: Weekly to Daily
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.2);
  
  --secondary: #4f46e5;
  --accent: #059669;
  --accent-light: #ecfdf5;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-card: #ffffff;
  
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-paper: 0 15px 30px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-doc: 'Book Old Style', 'Book Antiqua', 'Palatino Linotype', 'Times New Roman', serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navbar */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.header-container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  fill: #ffffff;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.deped-tag {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, 0.25);
}

/* Main Layout */
.main-content {
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Upload Section */
.upload-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.upload-card:hover {
  box-shadow: var(--shadow-md);
}

.drop-zone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 2.25rem 1.5rem;
  text-align: center;
  background-color: var(--bg-subtle);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-light);
  transform: translateY(-2px);
}

.drop-icon-wrapper {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.drop-zone:hover .drop-icon-wrapper {
  background: var(--primary);
  color: #ffffff;
  transform: scale(1.08);
}

.drop-icon-wrapper svg {
  width: 28px;
  height: 28px;
}

.drop-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.drop-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.button-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #047857 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-accent:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
  transform: translateY(-1px);
}

.btn-outline {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-medium);
}

.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* File Loaded Banner */
.file-info-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to right, #f0fdf4, #ecfdf5);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.file-info-details {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.file-icon {
  width: 36px;
  height: 36px;
  background: #22c55e;
  color: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-icon svg {
  width: 20px;
  height: 20px;
}

.file-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #14532d;
}

.file-meta {
  font-size: 0.78rem;
  color: #166534;
}

/* Conversion Control Bar & Session Selector */
.control-bar {
  display: none;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  flex-direction: column;
  gap: 1rem;
}

.control-bar.active {
  display: flex;
}

.control-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.session-counter-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.session-counter-badge .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Generation Scope Selector Bar */
.generator-scope-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
}

.scope-options-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.scope-label-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.scope-radio-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #ffffff;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
}

.scope-radio-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
}

.scope-radio-label:hover {
  color: var(--primary);
}

.scope-radio-label input[type="radio"] {
  accent-color: var(--primary);
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.manual-input-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.manual-session-input {
  width: 110px;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--primary);
  transition: var(--transition);
}

.manual-session-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.quick-pills-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.quick-pill-btn {
  background: #ffffff;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: var(--transition);
}

.quick-pill-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.quick-pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px var(--primary-glow);
}

/* Session Tabs Navigation */
.tabs-container {
  display: none;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--border-subtle);
  gap: 0.5rem;
}

.tabs-container.active {
  display: flex;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
  font-weight: 700;
}

.tab-badge {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  font-weight: 600;
}

.tab-btn.active .tab-badge {
  background: var(--primary-light);
  color: var(--primary);
}

/* Workspace Split Layout */
.workspace-grid {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.workspace-grid.active {
  display: grid;
}

@media (max-width: 1200px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Left Panel: Form Editor */
.editor-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(to right, #f8fafc, #ffffff);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.editor-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

/* Accordion Sections in Editor */
.form-section {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #ffffff;
  overflow: hidden;
}

.form-section-header {
  padding: 0.75rem 1rem;
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.form-section-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label .tag-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 600;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  background: #ffffff;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-main);
  transition: var(--transition);
  line-height: 1.45;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* Right Panel: Simulated DepEd Word Document Paper Preview */
.preview-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-toolbar {
  padding: 0.75rem 1.25rem;
  background: #1e293b;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preview-title {
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-scroll-container {
  padding: 2rem 1.5rem;
  background: #94a3b8;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

/* Paper Page Simulator */
.paper-page {
  background: #ffffff;
  width: 100%;
  max-width: 820px;
  min-height: 1050px;
  padding: 2.5rem 3rem;
  box-shadow: var(--shadow-paper);
  border-radius: 2px;
  color: #000000;
  font-family: var(--font-doc);
  font-size: 11pt;
  line-height: 1.25;
}

/* DepEd Official Header */
.doc-header {
  text-align: center;
  position: relative;
  margin-bottom: 1.5rem;
}

.doc-logo-center {
  width: 55px;
  height: 55px;
  margin: 0 auto 0.5rem;
  display: block;
}

.doc-country {
  font-size: 11pt;
}

.doc-dept {
  font-size: 12pt;
  font-weight: bold;
}

.doc-region, .doc-division, .doc-district {
  font-size: 10pt;
}

.doc-school {
  font-size: 12pt;
  font-weight: bold;
  letter-spacing: 0.5px;
  margin-top: 0.2rem;
}

.doc-title {
  font-size: 14pt;
  font-weight: bold;
  margin-top: 1rem;
  letter-spacing: 1.5px;
}

/* DepEd Official Lesson Plan Table */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.doc-table th, .doc-table td {
  border: 1px solid #000000;
  padding: 4px 7px;
  vertical-align: top;
  font-size: 10.5pt;
  line-height: 1.25;
}

.doc-col-label {
  width: 38%;
  font-weight: bold;
}

.doc-col-content {
  width: 62%;
}

.doc-banner-row td {
  background: #ffffff;
  padding: 6px 7px;
  font-size: 10pt;
  line-height: 1.2;
}

.doc-banner-title {
  font-weight: bold;
  font-size: 11pt;
  display: block;
  margin-bottom: 2px;
}

.doc-banner-desc {
  font-style: italic;
  font-size: 9.5pt;
  color: #333333;
}

/* Signatures */
.doc-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding: 0 1rem;
}

.doc-sig-block {
  width: 45%;
}

.doc-sig-label {
  font-size: 10pt;
  margin-bottom: 1.75rem;
}

.doc-sig-name {
  font-weight: bold;
  text-decoration: underline;
  text-transform: uppercase;
  font-size: 10.5pt;
}

.doc-sig-title {
  font-size: 9.5pt;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
  border-left: 4px solid var(--primary);
}

.toast.toast-success {
  border-left-color: #10b981;
}

.toast.toast-error {
  border-left-color: #ef4444;
}

@keyframes slideIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Loading Overlay Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.25rem;
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.progress-bar-outer {
  background: var(--bg-subtle);
  height: 10px;
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar-inner {
  background: linear-gradient(to right, var(--primary), #3b82f6);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

/* Saved History Component Styles */
.btn-history {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-history:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.history-badge-count {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  line-height: 1.2;
}

.btn-save-history {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #ffffff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-weight: 700;
  transition: var(--transition);
}

.btn-save-history:hover {
  background: var(--primary-light);
}

.history-modal-card {
  max-width: 680px;
  width: 95%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.history-modal-header {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.history-icon-circle {
  width: 40px;
  height: 40px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(147, 197, 253, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  flex-shrink: 0;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-close-modal:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.history-list-container {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  max-height: calc(88vh - 150px);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: #f8fafc;
}

.history-card {
  background: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.history-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.35;
  flex: 1;
}

.history-time-badge {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
  white-space: nowrap;
  background: var(--bg-subtle);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.history-meta-tags {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.history-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
}

.history-tag.session-tag {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
  font-weight: 700;
}

.history-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-subtle);
}

.btn-load-history {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
}

.btn-download-history-zip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
}

.btn-delete-history {
  margin-left: auto;
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-delete-history:hover {
  color: #ef4444;
  background: #fee2e2;
  border-color: #fca5a5;
}

.history-empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.history-empty-state .empty-icon {
  width: 64px;
  height: 64px;
  background: #e2e8f0;
  color: #94a3b8;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.history-empty-state h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.history-empty-state p {
  font-size: 0.85rem;
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.5;
}

.history-modal-footer {
  padding: 0.85rem 1.5rem;
  background: #ffffff;
  border-top: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.feature-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feature-icon svg {
  width: 20px;
  height: 20px;
}

.feature-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}

.feature-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ========================================================
   Mobile & Tablet Responsiveness (@media <= 992px & <= 768px)
   ======================================================== */

/* Mobile View Toggle Bar */
.mobile-view-toggle {
  display: none;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  margin-bottom: 1rem;
  gap: 0.35rem;
}

.mobile-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.mobile-toggle-btn:hover {
  color: var(--primary);
}

.mobile-toggle-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 992px) {
  .mobile-view-toggle {
    display: flex;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .workspace-grid[data-mobile-view="editor"] .editor-panel {
    display: flex !important;
  }
  .workspace-grid[data-mobile-view="editor"] .preview-panel {
    display: none !important;
  }

  .workspace-grid[data-mobile-view="preview"] .editor-panel {
    display: none !important;
  }
  .workspace-grid[data-mobile-view="preview"] .preview-panel {
    display: flex !important;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
  }
  
  .header-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .brand-wrapper {
    width: 100%;
    justify-content: flex-start;
  }

  .brand-title {
    font-size: 1.18rem;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .hero-section {
    padding: 1.5rem 0.5rem;
  }

  .hero-title {
    font-size: 1.65rem;
    line-height: 1.25;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .app-main {
    padding: 1rem 0.75rem;
  }

  .upload-dropzone {
    padding: 1.5rem 1rem;
  }

  .upload-icon {
    width: 44px;
    height: 44px;
  }

  .upload-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .btn-upload, .btn-sample {
    width: 100%;
    justify-content: center;
  }

  .control-bar {
    padding: 1rem;
  }

  .control-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .control-bar-actions {
    flex-direction: column;
    width: 100%;
  }

  .btn-download-single {
    width: 100%;
    justify-content: center;
  }

  .generator-scope-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.85rem;
  }

  .scope-options-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .scope-radio-group {
    justify-content: space-around;
  }

  .quick-pills-group {
    justify-content: flex-start;
    gap: 0.35rem;
  }

  .execute-generate-btn {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
  }

  .tabs-container {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.35rem;
  }

  .tabs-container::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
  }

  .preview-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.75rem 0.85rem;
  }

  .preview-actions {
    justify-content: flex-end;
  }

  .preview-scroll-container {
    padding: 0.75rem 0.35rem;
    max-height: none;
    background: #cbd5e1;
  }

  .paper-page {
    padding: 1.25rem 0.65rem;
    font-size: 9.5pt;
    min-height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .doc-table th, .doc-table td {
    padding: 3px 5px;
    font-size: 8.5pt;
    line-height: 1.2;
  }

  .doc-col-label {
    width: 40%;
  }

  .doc-col-content {
    width: 60%;
  }

  .doc-dept {
    font-size: 10pt;
  }

  .doc-title {
    font-size: 11pt;
    margin-top: 0.5rem;
  }

  .doc-school {
    font-size: 10.5pt;
  }
}

@media (max-width: 640px) {
  .form-section-body div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .editor-body {
    padding: 0.75rem;
    max-height: none;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .modal-content {
    width: 94%;
    padding: 1.5rem 1rem;
  }

  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .toast {
    max-width: 100%;
  }
}

/* Print Stylesheet */
@media print {
  body {
    background: #ffffff;
  }
  .app-header, .upload-card, .control-bar, .tabs-container, .editor-panel, .preview-toolbar, .features-grid, .toast-container {
    display: none !important;
  }
  .workspace-grid {
    display: block !important;
  }
  .preview-panel {
    border: none !important;
    box-shadow: none !important;
  }
  .preview-scroll-container {
    background: transparent !important;
    padding: 0 !important;
  }
  .paper-page {
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}
