/* ==========================================================================
   Base & App Styles
   ========================================================================== */
   :root {
    --bg-color: #f3f4f6;
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.1);
    --primary-color: #003087;
    --primary-hover: #002266;
    --text-main: #1f2937;
    --text-muted: #6b7280;
  }
  
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
  }
  
  /* App Layout */
  .app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
  }
  
  /* Sidebar */
  .sidebar {
    width: 380px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 2px 0 15px rgba(0,0,0,0.05);
  }
  
  .sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
  }
  
  .sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
  }
  
  .sidebar-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
  }

  .header-links {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
  }

  .creator-credit {
    font-size: 0.8rem !important;
    color: var(--primary-color) !important;
    background: #e2e8f0;
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    margin: 0;
  }
  .creator-credit strong {
    font-weight: 700;
  }

  .github-link {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 600;
    background: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s, transform 0.1s;
  }
  
  .github-link:hover {
    background: #cbd5e1;
  }
  .github-link:active {
    transform: scale(0.95);
  }
  
  #generator-form {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  /* Custom Scrollbar for form */
  #generator-form::-webkit-scrollbar {
    width: 6px;
  }
  #generator-form::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
  }
  
  .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  
  .form-row {
    display: flex;
    gap: 12px;
  }
  
  .form-row .form-group {
    flex: 1;
    min-width: 0;
  }
  
  label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #fff;
  }
  
  input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.1);
  }
  
  .sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .btn-primary, .btn-secondary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    border: none;
  }

  .btn-primary {
    background: var(--primary-color);
    color: #fff;
  }
  
  .btn-primary:hover {
    background: var(--primary-hover);
  }

  .btn-secondary {
    background: #e2e8f0;
    color: var(--text-main);
  }

  .btn-secondary:hover {
    background: #cbd5e1;
  }
  
  .btn-primary:active, .btn-secondary:active {
    transform: scale(0.98);
  }
  
  /* Preview Area */
  .preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  .preview-toolbar {
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
  }
  
  .zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
  }
  
  .zoom-controls button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
  }
  
  .zoom-controls button:hover {
    background: #e2e8f0;
  }
  
  .preview-wrapper {
    flex: 1;
    overflow: auto;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }
  
  /* ==========================================================================
     Template Styles (Scoped to #template-root)
     ========================================================================== */
  
  #template-root {
    /* Define a container that can be scaled */
    transform-origin: top center;
    transition: transform 0.2s ease;
    /* A4 Box shadow to look like a paper */
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  }
  
  #template-root .page {
    width: 794px;
    min-height: 1123px;
    background: #fff;
    display: flex;
    flex-direction: column;
    position: relative;
    font-family: Arial, sans-serif;
    color: #000;
  }
  
  /* ── Header ── */
  #template-root .header {
    padding: 18px 30px 0 30px;
    display: flex;
    align-items: center;
    gap: 18px;
  }
  
  #template-root .logo {
    width: 95px;
    height: 95px;
    flex-shrink: 0;
  }
  
  #template-root .college-info {
    flex: 1;
  }
  
  #template-root .trust-name {
    font-size: 11px;
    color: #333;
    margin-bottom: 2px;
    font-style: italic;
  }
  
  #template-root .college-name {
    font-size: 42px;
    font-weight: 900;
    color: #003087;
    line-height: 1;
    letter-spacing: 1px;
  }
  
  #template-root .college-name span {
    color: #e8a000;
  }
  
  #template-root .institute-name {
    font-size: 20px;
    font-weight: 700;
    color: #003087;
    letter-spacing: 2px;
    margin-top: 2px;
  }
  
  #template-root .address {
    font-size: 12px;
    color: #e8a000;
    font-weight: 600;
    margin-top: 3px;
  }
  
  #template-root .autonomous-badge {
    display: inline-block;
    background: #e8a000;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    margin-top: 5px;
    letter-spacing: 1px;
  }
  
  /* ── Gold bar ── */
  #template-root .gold-bar {
    height: 14px;
    background: #e8a000;
    margin-top: 14px;
  }
  
  /* ── Department ── */
  #template-root .department {
    text-align: center;
    color: #003087;
    font-size: 13px;
    font-weight: 600;
    margin-top: 22px;
    letter-spacing: 0.5px;
  }
  
  /* ── Assignment title ── */
  #template-root .assignment-title {
    text-align: center;
    margin-top: 28px;
  }
  
  #template-root .assignment-title h1 {
    font-size: 52px;
    font-weight: 900;
    color: #003087;
    letter-spacing: 2px;
  }
  
  #template-root .subject-line {
    text-align: center;
    font-size: 14px;
    color: #333;
    margin-top: 8px;
    line-height: 1.7;
  }
  
  /* ── Divider ── */
  #template-root .divider {
    border: none;
    border-top: 2px solid #e8a000;
    margin: 22px 30px 0 30px;
  }
  
  /* ── Info table ── */
  #template-root .info-table {
    margin: 0 30px;
    border-collapse: collapse;
    width: calc(100% - 60px);
  }
  
  #template-root .info-table tr {
    border-bottom: 1px solid #ddd;
  }
  
  #template-root .info-table tr:first-child {
    border-top: none;
  }
  
  #template-root .info-table td {
    padding: 13px 16px;
    font-size: 13px;
  }
  
  #template-root .info-table td:first-child {
    font-weight: 700;
    color: #003087;
    width: 38%;
  }
  
  #template-root .info-table td:last-child {
    color: #333;
  }
  
  /* ── Bottom divider ── */
  #template-root .bottom-divider {
    border: none;
    border-top: 2px solid #e8a000;
    margin: 0 30px;
  }
  
  #template-root .institute-footer-address {
    text-align: center;
    font-size: 12px;
    color: #666;
    margin-top: 8px;
  }
  
  /* ── Spacer ── */
  #template-root .spacer { flex: 1; }
  
  /* ── Footer ── */
  #template-root .footer {
    background: #003087;
    color: #fff;
    text-align: center;
    font-size: 10px;
    padding: 9px 20px;
    letter-spacing: 0.3px;
  }
  
  /* ==========================================================================
     Print Styles
     ========================================================================== */
  @media print {
    /* Hide the application UI */
    .no-print, .sidebar, .preview-toolbar {
      display: none !important;
    }
  
    /* Reset body and layout for printing */
    body {
      background: none;
      height: auto;
      overflow: visible;
    }
  
    .app-container {
      display: block;
      height: auto;
    }
  
    .preview-area {
      display: block;
      overflow: visible;
    }
  
    .preview-wrapper {
      padding: 0;
      overflow: visible;
      display: block;
    }
  
    #template-root {
      transform: none !important;
      box-shadow: none;
      margin: 0;
    }
  
    #template-root .page {
      width: 100%;
      min-height: 297mm;
      margin: 0;
    }
    
    @page {
      size: A4 portrait;
      margin: 0;
    }
  }

  /* ==========================================================================
     Mobile Responsiveness
     ========================================================================== */
  @media screen and (max-width: 768px) {
    .app-container {
      flex-direction: column;
      overflow-y: auto;
    }

    /* Override body hidden overflow on mobile */
    body {
      overflow-y: auto;
    }

    .sidebar {
      width: 100%;
      border-right: none;
      border-bottom: 1px solid var(--border-color);
      /* Make sidebar take normal flow space instead of flex taking full height */
      flex: none;
    }

    #generator-form {
      /* Remove scrolling inside form, let the whole page scroll */
      overflow-y: visible;
    }

    .preview-area {
      /* Let preview area flow normally */
      flex: none;
      overflow: visible;
    }

    .preview-wrapper {
      padding: 20px;
      overflow-x: auto;
      justify-content: flex-start;
      /* Ensure zooming still works but scrolls horizontally if too big */
    }

    /* Make zoom slightly smaller by default on mobile */
    #template-root {
      transform-origin: top left;
    }
  }
