/* ==========================================================================
   Ward Sifaris / Application Generator — Stylesheet
   Extends the site's design system (styles.css variables)
   Mukta font for Nepali UI; Tiro Devanagari Nepali for the letter body
   ========================================================================== */

/* ---- Font override for this page ---- */
body {
    font-family: 'Mukta', 'Segoe UI', Tahoma, sans-serif;
}

/* Top site navigation header — not sticky on this page so it scrolls away when scrolled */
header {
    position: static !important;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.rag-main {
    min-height: calc(100vh - 120px);
    padding-bottom: 60px;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.rag-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    padding-bottom: 4px;
    flex-wrap: wrap;
    gap: 14px;
}

/* ============================================================
   LANGUAGE SWITCHER — matches file-manipulators & ward-secretary
   ============================================================ */
.lang-switch {
    display: inline-flex;
    background-color: var(--card, #ffffff);
    border: 1px solid #d1d5db;
    padding: 3px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.lang-btn {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted, #6b7280);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border: none;
    background: transparent;
    font-family: inherit;
    line-height: 1.4;
}

.lang-btn:hover {
    color: var(--text, #222222);
    background: #f1f5f9;
}

.lang-btn.active {
    background-color: var(--primary, #0077b5);
    color: #ffffff !important;
    box-shadow: 0 2px 6px rgba(0, 119, 181, 0.3);
}

.rag-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary, #0077b5);
    background: #ffffff;
    border: 1px solid #dbeafe;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.rag-back-link:hover {
    background: var(--primary, #0077b5);
    color: #ffffff;
    border-color: var(--primary, #0077b5);
    transform: translateX(-3px);
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.rag-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 2px 0 8px;
    flex-wrap: wrap;
    text-align: center;
}

.rag-hero-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary, #0077b5), var(--accent, #0062a8));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(0, 119, 181, 0.25);
}

.rag-hero-text {
    flex: 0 1 auto;
    text-align: center;
}

.rag-hero-text h1 {
    font-size: clamp(1.4rem, 1.2rem + 1vw, 2rem);
    font-weight: 800;
    color: var(--accent, #0062a8);
    margin: 0;
    line-height: 1.25;
    letter-spacing: -0.5px;
    text-align: center;
}

.rag-hero-sub {
    font-size: 0.92rem;
    color: var(--muted, #6b7280);
    margin: 0;
    line-height: 1.5;
    text-align: center;
}

/* Hidden variant — element kept in DOM but invisible */
.rag-hero-sub--hidden {
    display: none;
}

.rag-privacy-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
}

.rag-privacy-pill i {
    color: #15803d;
}

/* ============================================================
   PERSISTENT OFFICE DETAILS BAR
   One-line compact strip below the hero, saved in cookies for 1 year
   ============================================================ */
.rag-office-bar {
    margin-bottom: 20px;
}

.rag-office-bar-inner {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #ffffff;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    padding: 0 16px;
    box-shadow: 0 2px 10px rgba(0, 119, 181, 0.05);
    position: relative;
    overflow-x: auto;
}

/* Each horizontal row inside the bar */
.rag-ob-row {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 8px 0;
}

/* Row 2 gets a subtle top separator */
.rag-ob-row--type {
    border-top: 1px solid #e2e8f0;
}

.rag-ob-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
}

.rag-ob-group-title {
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--primary, #0077b5);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    letter-spacing: -0.2px;
    flex-shrink: 0;
}

.rag-ob-group-title i {
    font-size: 0.72rem;
    color: var(--primary, #0077b5);
}

.rag-ob-group-fields {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
}

.rag-ob-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 65px;
    flex: 0 0 auto;
    padding: 0 6px;
}

.rag-ob-field--wide {
    flex: 1 1 140px;
}

/* Toggle field (letterhead checkbox) in the office bar */
.rag-ob-field--toggle {
    flex: 0 0 auto;
    padding: 0 4px;
}

.rag-ob-field--toggle .rag-toggle-label {
    padding: 5px 10px;
    margin: 0;
    border-radius: 6px;
    font-size: 0.8rem;
    gap: 7px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    white-space: nowrap;
}

.rag-ob-field--toggle .rag-toggle-text {
    font-size: 0.78rem;
    white-space: nowrap;
}

/* Custom role field — conditionally shown when 'others' selected */
.rag-ob-field--custom-role {
    display: none;
    min-width: 100px;
    animation: fadeIn 0.2s ease;
}

.rag-ob-field--custom-role.is-visible {
    display: flex;
}

.rag-ob-label {
    font-size: 0.67rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.rag-ob-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.92rem;
    font-family: 'Mukta', inherit;
    font-weight: 600;
    color: var(--text, #1e293b);
    padding: 0;
    width: 100%;
    min-width: 60px;
}

.rag-ob-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.85rem;
}

.rag-ob-input:focus {
    color: var(--primary, #0077b5);
}

.rag-ob-select {
    cursor: pointer;
    appearance: auto;
    padding-right: 2px;
}

.rag-ob-divider {
    width: 1px;
    height: 30px;
    background: #e2e8f0;
    flex-shrink: 0;
    margin: 0 2px;
}

.rag-ob-divider--major {
    width: 2px;
    height: 34px;
    background: #cbd5e1;
    margin: 0 4px;
}

/* Saved indicator */
.rag-ob-save-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    padding: 3px 9px;
    white-space: nowrap;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.rag-ob-save-indicator.is-visible {
    opacity: 1;
    transform: scale(1);
}

@media (max-width: 992px) {
    .rag-ob-row {
        flex-wrap: wrap;
        gap: 10px;
    }
    .rag-ob-divider--major {
        display: none;
    }
    .rag-ob-group {
        flex: 1 1 100%;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .rag-ob-group-fields {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .rag-ob-divider {
        display: none;
    }
    .rag-ob-field {
        padding: 0;
        min-width: calc(50% - 6px);
    }
    .rag-ob-input {
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 2px;
    }
}

/* ============================================================
   WORKSPACE — SPLIT LAYOUT
   ============================================================ */
.rag-workspace {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 28px;
    align-items: start;
}

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

/* ============================================================
   FORM PANEL
   ============================================================ */
.rag-form-panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow, 0 10px 30px rgba(0,0,0,0.05));
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}

.rag-form-panel::-webkit-scrollbar {
    width: 4px;
}
.rag-form-panel::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.rag-form-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f1f5f9;
}

.rag-form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Extra fields section — hidden by default; JS adds .is-visible to show */
.rag-extra-section {
    display: none;
}

.rag-extra-section.is-visible {
    display: block;
}

/* ============================================================
   LETTERHEAD TOGGLE — "We have our own letterhead" checkbox
   ============================================================ */
.rag-letterhead-toggle-wrap {
    margin-top: 10px;
}

.rag-toggle-label {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
    padding: 9px 13px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.rag-toggle-label:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.rag-toggle-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary, #0077b5);
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

.rag-toggle-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    line-height: 1.4;
}

/* When checked — highlight the label */
.rag-toggle-checkbox:checked + .rag-toggle-text {
    color: var(--primary, #0077b5);
}

.rag-toggle-label:has(.rag-toggle-checkbox:checked) {
    background: #eff6ff;
    border-color: #93c5fd;
}

/* ---- Hide letter-header-wrap, meta block, red rule and rag-letter-page-footer when hide-letterhead class applied ---- */
.rag-letter.hide-letterhead .rag-letter-header-wrap,
.rag-letter.hide-letterhead .rag-letter-meta-block,
.rag-letter.hide-letterhead .rag-letter-rule,
.rag-letter.hide-letterhead .rag-letter-page-footer {
    display: none !important;
}

/* Also hide in print when no-letterhead mode active */
@media print {
    .rag-letter.hide-letterhead .rag-letter-header-wrap,
    .rag-letter.hide-letterhead .rag-letter-meta-block,
    .rag-letter.hide-letterhead .rag-letter-rule,
    .rag-letter.hide-letterhead .rag-letter-page-footer {
        display: none !important;
    }
}

.rag-section-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--primary, #0077b5);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 14px;
}

.rag-section-heading i {
    font-size: 0.85rem;
}

.rag-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
}

.rag-optional {
    font-weight: 400;
    color: #9ca3af;
    font-size: 0.78rem;
}

.rag-field {
    margin-bottom: 12px;
}

.rag-field:last-child {
    margin-bottom: 0;
}

.rag-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.rag-input,
.rag-select,
.rag-textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.5;
    font-family: 'Mukta', inherit;
    color: var(--text, #222222);
    background: #f9fafb;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    outline: none;
    box-sizing: border-box;
}

.rag-input:focus,
.rag-select:focus,
.rag-textarea:focus {
    border-color: var(--primary, #0077b5);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 119, 181, 0.12);
}

.rag-input::placeholder {
    color: #c4c9d1;
    font-size: 0.92rem;
}

.rag-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.55;
}

.rag-select {
    cursor: pointer;
    appearance: auto;
}

/* Action Buttons */
.rag-actions {
    display: flex;
    gap: 10px;
    flex-direction: column;
    margin-top: 8px;
}

.rag-btn-print {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--primary, #0077b5), var(--accent, #0062a8));
    color: #ffffff;
    border: none;
    padding: 13px 22px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Mukta', inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 119, 181, 0.28);
    width: 100%;
}

.rag-btn-print:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 119, 181, 0.36);
}

.rag-btn-print:active {
    transform: translateY(0);
}

.rag-btn-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Mukta', inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.rag-btn-reset:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

/* ============================================================
   PREVIEW PANEL
   ============================================================ */
.rag-preview-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.rag-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary, #0077b5);
    color: #ffffff;
    padding: 10px 18px;
    border-radius: 12px 12px 0 0;
}

.rag-preview-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.95;
}

.rag-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Info / Help tooltip (lightbulb on right hand side) ---- */
.rag-info-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.rag-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    color: #fef08a;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.rag-info-btn:hover,
.rag-info-btn:focus-visible,
.rag-info-btn.is-active {
    background: rgba(255, 255, 255, 0.28);
    color: #fde047;
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(253, 224, 71, 0.45);
    outline: none;
}

.rag-info-bubble {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 310px;
    background: #0f172a;
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 0.8rem;
    line-height: 1.6;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
    z-index: 300;
    pointer-events: none;
    text-align: left;
}

/* Arrow pointing up towards the lightbulb icon */
.rag-info-bubble::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 11px;
    width: 12px;
    height: 12px;
    background: #0f172a;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    transform: rotate(45deg);
    border-radius: 2px;
}

.rag-info-wrap:hover .rag-info-bubble,
.rag-info-bubble.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.rag-info-bubble-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.84rem;
    color: #38bdf8;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.rag-info-bubble ul {
    margin: 0;
    padding-left: 16px;
    list-style-type: disc;
}

.rag-info-bubble li {
    margin-bottom: 6px;
    color: #e2e8f0;
}

.rag-info-bubble li:last-child {
    margin-bottom: 0;
}

.rag-info-bubble li strong {
    color: #ffffff;
}

.rag-info-bubble strong {
    color: #f8fafc;
}


/* Preview header action buttons — icon + text */
.rag-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Mukta', inherit;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rag-action-btn:hover {
    background: rgba(255,255,255,0.28);
    transform: translateY(-1px);
}

.rag-action-btn:active {
    transform: translateY(0);
}

/* Word download variant — distinct tint */
.rag-action-btn--word {
    background: rgba(29, 95, 166, 0.4);
    border-color: rgba(255,255,255,0.3);
}

.rag-action-btn--word:hover {
    background: rgba(29, 95, 166, 0.6);
}

/* Keep legacy icon-only btn class for fallback */
.rag-icon-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ffffff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.rag-icon-btn:hover {
    background: rgba(255,255,255,0.28);
    transform: translateY(-1px);
}

.rag-icon-btn--word {
    background: rgba(29, 95, 166, 0.35);
    border-color: rgba(255,255,255,0.3);
}

.rag-icon-btn--word:hover {
    background: rgba(29, 95, 166, 0.55);
}

/* Letter wrapper (the A4-like paper) */
.rag-letter-wrapper {
    background: #e8edf3;
    padding: 28px 20px;
    border-radius: 0 0 12px 12px;
    min-height: 500px;
}

/* ============================================================
   THE LETTER (Printable)
   ============================================================ */
.rag-letter {
    background: #ffffff;
    border: 1px solid #dde3ea;
    border-radius: 4px;
    padding: 44px 48px 8px;
    max-width: 700px;
    min-height: 980px;
    margin: 0 auto;
    font-family: 'Tiro Devanagari Nepali', 'Mukta', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.85;
    color: #1a1a1a;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

/* Letterhead wrap — emblem col on left, text centered, spacer col on right for symmetrical centering */
.rag-letter-header-wrap {
    display: grid;
    grid-template-columns: 72px 1fr 72px;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.rag-letter-emblem-col {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.rag-letter-emblem {
    width: 68px;
    height: auto;
    object-fit: contain;
}

.rag-letter-header-spacer {
    width: 72px;
    /* Invisible spacer balancing the emblem so title is mathematically centered */
}

/* Letter Header */
.rag-letter-header {
    text-align: center;
    margin-bottom: 0;
}

.rag-letter-govt-text {
    font-size: 0.88rem;
    color: #555;
    margin-bottom: 2px;
    font-weight: 400;
}

.rag-letter-nepal {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.rag-letter-palika {
    font-size: 1.15rem;
    font-weight: 800;
    color: #b91c1c;
    margin-bottom: 2px;
    line-height: 1.35;
}

.rag-letter-ward-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #b91c1c;
    margin-bottom: 2px;
    line-height: 1.35;
}

.rag-letter-address {
    font-size: 0.92rem;
    color: #4b5563;
    font-weight: 500;
    margin-bottom: 0;
    line-height: 1.4;
}

/* Full-width Meta Block: पत्र संख्या, चलानी नं. (बायाँ), मिति (दायाँ) */
.rag-letter-meta-block {
    width: 100%;
    margin-top: 14px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #111827;
}

.rag-letter-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    line-height: 1.85;
    gap: 16px;
}

.rag-letter-meta-left {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    text-align: left;
    white-space: nowrap;
}

.rag-letter-meta-right {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    text-align: right;
    white-space: nowrap;
    margin-left: auto;
}

.rag-meta-label {
    font-weight: 700;
    color: #111827;
    letter-spacing: 0.2px;
}

.rag-meta-val {
    font-weight: 500;
    color: #1f2937;
    letter-spacing: 0.5px;
}

/* Divider */
.rag-letter-rule {
    border: none;
    border-top: 2px solid #dc2626;
    margin: 8px 0 16px;
}

/* Subject */
.rag-letter-subject {
    font-weight: 700;
    font-size: 1rem;
    margin: 14px 0 12px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Body */
.rag-letter-body {
    font-size: 1rem;
    line-height: 2;
    text-align: justify;
    text-justify: inter-word;
}

.rag-letter-body p {
    margin: 0 0 12px 0;
}

.rag-letter-body .rag-placeholder {
    color: #dc2626;
    font-style: italic;
    background: #fff5f5;
    border-radius: 3px;
    padding: 0 3px;
}

/* Letter Footer */
.rag-letter-footer {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    margin-top: 32px;
}

.rag-letter-footer-right {
    text-align: right;
    min-width: 200px;
}

.rag-signature-line {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 4px;
    letter-spacing: 0.05em;
}

.rag-signature-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1a1a1a;
    line-height: 1.4;
}

.rag-signature-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    line-height: 1.4;
}

.rag-sig-role {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    display: inline-block;
}

.rag-signature-office {
    font-size: 0.82rem;
    color: #555;
    margin-top: 2px;
}

/* Charkilla table */
.rag-charkilla-table {
    border-collapse: collapse;
    margin: 10px 0 14px;
    font-size: 0.95rem;
    width: auto;
}

.rag-charkilla-table td {
    padding: 4px 18px 4px 0;
    vertical-align: top;
    line-height: 1.7;
}

.rag-charkilla-table td:first-child {
    white-space: nowrap;
    color: #374151;
    min-width: 80px;
}

/* Tips bar — removed from HTML; kept hidden in case referenced elsewhere */
.rag-tips { display: none; }

/* ============================================================
   LETTER BOTTOM OFFICIAL STRIP (Anchored to bottom of letter)
   ============================================================ */
.rag-letter-page-footer {
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 6px;
    padding-bottom: 0;
    border-top: 1.5px dotted #dc2626;
    font-size: 0.88rem;
    color: #4b5563;
    text-align: center;
    width: 100%;
}

/* ============================================================
   MOBILE: Stack panels
   ============================================================ */
@media (max-width: 900px) {
    .rag-form-panel {
        position: static;
        max-height: none;
        border-radius: 12px;
    }

    .rag-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }

    .rag-letter {
        padding: 28px 22px;
    }

    .rag-letter-footer {
        flex-direction: column;
        align-items: center;
    }

    .rag-letter-footer-right {
        width: 100%;
    }

    .rag-workspace {
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .rag-field-row {
        grid-template-columns: 1fr;
    }

    .rag-hero-text h1 {
        font-size: 1.4rem;
    }

    .rag-letter {
        padding: 20px 14px;
        font-size: 0.92rem;
    }

    .rag-letter-header-wrap {
        grid-template-columns: 52px 1fr 52px;
        gap: 8px;
    }

    .rag-letter-emblem {
        width: 48px;
    }

    .rag-letter-header-spacer {
        width: 52px;
    }

    .rag-info-bubble {
        width: min(290px, calc(100vw - 36px));
        right: -6px;
    }
}

@media print {
    html,
    body {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    /* 1. Layout hierarchy for the printable letter */
    .rag-main,
    .rag-workspace,
    .rag-workspace.container,
    .rag-preview-panel,
    .rag-letter-wrapper {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        gap: 0 !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* 2. Hide all non-printable UI elements (header, nav, top bar, hero, form, buttons) */
    header,
    footer,
    nav,
    .site-nav,
    .nav-container,
    .rag-top-bar,
    .rag-hero,
    .rag-office-bar,
    .rag-form-panel,
    .rag-preview-header,
    .rag-tips,
    .rag-preview-actions,
    .lang-switch,
    .rag-info-wrap,
    .rag-info-bubble {
        display: none !important;
        visibility: hidden !important;
    }

    .rag-letter {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        min-height: calc(297mm - 0.75in - 2mm) !important;
        /* Clean margins without extra padding */
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .rag-letter-footer {
        margin-top: 24px !important;
    }

    .rag-letter-rule {
        border-top: 2px solid #dc2626 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rag-letter-page-footer {
        margin-top: auto !important;
        margin-bottom: 0 !important;
        border-top: 1.5px dotted #dc2626 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        padding-top: 4px !important;
        padding-bottom: 0 !important;
        font-size: 0.84rem !important;
        color: #374151 !important;
        text-align: center !important;
        width: 100% !important;
    }

    @page {
        size: A4 portrait;
        margin: 0.45in 0.5in 0.3in 0.5in;
    }
}

/* Word (.doc) download button */
.rag-btn-doc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #1d5fa6, #1a4f8f);
    color: #ffffff;
    border: none;
    padding: 11px 22px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Mukta', inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(29, 95, 166, 0.28);
    width: 100%;
}

.rag-btn-doc:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(29, 95, 166, 0.38);
}

.rag-btn-doc:active {
    transform: translateY(0);
}
