/* 
 * Style Sheet for Letter Generator & A4 Document Engine
 * letter.2.edu.vn
 */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Dancing+Script:wght@600;700&family=Montserrat:wght@600;700;800;900&family=Alex+Brush&display=swap');

:root {
    --primary: #f2721c;
    --primary-dark: #d95a07;
    --primary-light: #fff7ed;
    --secondary: #0284c7;
    --text-main: #1e293b;
    --text-muted: #475569;
    --border-color: #e2e8f0;
    --bg-app: #f1f5f9;
    --a4-width: 794px;
    --a4-height: 1123px;
}

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

body {
    font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Header & Navigation */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    height: 36px;
    width: auto;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    border: 1px solid #fed7aa;
}

/* Main Layout */
.app-container {
    display: flex;
    height: calc(100vh - 61px);
    overflow: hidden;
}

/* Left Sidebar (Editor) */
.editor-sidebar {
    width: 480px;
    min-width: 380px;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 50;
    transition: all 0.2s ease;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary-dark);
    background: #f1f5f9;
}

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

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.form-control, .form-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: #ffffff;
    color: var(--text-main);
    transition: border-color 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(242, 114, 28, 0.15);
}

textarea.form-control {
    resize: vertical;
    font-family: inherit;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    user-select: none;
}

.form-check-input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Right Pane (Preview Area) */
.preview-pane {
    flex: 1;
    background: #e2e8f0;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 20px;
    position: relative;
}

.preview-toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-radius: 9999px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.775rem;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-success {
    background: #10b981;
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-blue {
    background: #0284c7;
    color: #ffffff;
}

.btn-blue:hover {
    background: #0369a1;
}

/* ===================================================
   A4 SHEET CANVAS (PRECISION MATCHING WORD TEMPLATE)
   =================================================== */

.a4-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
}

.a4-page {
    width: var(--a4-width);
    min-height: var(--a4-height);
    background: #ffffff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    position: relative;
    padding: 38px 46px 20px 46px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    color: #1e293b;
    box-sizing: border-box;
}

/* Top Decorative Header */
.letter-header {
    display: flex;
    align-items: center;
    position: relative;
    margin-bottom: 24px;
    z-index: 2;
}

.header-logo-wrap {
    flex-shrink: 0;
    margin-right: 14px;
}

.header-logo {
    height: 52px;
    width: auto;
    display: block;
}

.header-title-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.header-main-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 23px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #000000;
    line-height: 1.1;
    text-transform: uppercase;
}

.header-sub-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #475569;
    margin-top: 4px;
    text-transform: uppercase;
}

.header-orange-bar {
    height: 9px;
    background: #f2721c;
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    border-radius: 1px;
}

/* Modern orange bar styling matching the sample */
.header-bar-container {
    position: absolute;
    bottom: 2px;
    left: 175px;
    right: -46px;
    height: 9px;
    background: #f2721c;
}

/* Document Body Content */
.letter-body {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 15px;
}

.doc-title {
    font-size: 18px;
    font-weight: 700;
    color: #000000;
    text-align: center;
    margin-bottom: 14px;
    line-height: 1.35;
}

.doc-date {
    text-align: right;
    font-size: 13.5px;
    color: #334155;
    margin-bottom: 14px;
}

.doc-salutation {
    font-size: 14.5px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 12px;
}

.doc-text-paragraph {
    font-size: 14px;
    line-height: 1.55;
    color: #1e293b;
    margin-bottom: 14px;
    text-align: justify;
}

.doc-text-paragraph p {
    margin-bottom: 10px;
}

/* Sections & Links */
.doc-section {
    margin-bottom: 14px;
}

.doc-section-heading {
    font-size: 14.5px;
    font-weight: 700;
    color: #000000;
    margin-bottom: 4px;
}

.doc-section-subtext {
    font-size: 13.5px;
    color: #334155;
    margin-bottom: 8px;
    line-height: 1.5;
    white-space: pre-line;
}

.doc-link-list {
    list-style: none;
    padding-left: 28px;
    margin-bottom: 10px;
}

.doc-link-item {
    font-size: 13.5px;
    margin-bottom: 6px;
    color: #1e293b;
    line-height: 1.4;
}

.doc-link-item .link-btn {
    font-weight: 700;
    text-decoration: none;
    margin-left: 4px;
}

/* Account Credential Box */
.account-card-box {
    background: #f8fafc;
    border: 1.5px solid #fed7aa;
    border-left: 5px solid #f2721c;
    border-radius: 8px;
    padding: 14px 18px;
    margin: 12px 0 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    box-shadow: 0 2px 6px rgba(242, 114, 28, 0.06);
}

.account-info-left {
    flex: 1;
}

.account-course-title {
    font-size: 15px;
    font-weight: 700;
    color: #c2410c;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.account-row {
    display: flex;
    align-items: center;
    font-size: 13.5px;
    margin-bottom: 5px;
}

.account-label {
    width: 125px;
    font-weight: 600;
    color: #475569;
}

.account-value {
    font-weight: 700;
    color: #0f172a;
    background: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
}

.account-note {
    font-size: 12px;
    color: #64748b;
    margin-top: 8px;
    font-style: italic;
}

.account-qr-right {
    margin-left: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.qr-caption {
    font-size: 10.5px;
    font-weight: 600;
    color: #64748b;
    margin-top: 4px;
    text-align: center;
}

/* Support & Closing Text */
.doc-support-box {
    font-size: 13.5px;
    line-height: 1.5;
    color: #1e293b;
    margin-top: 10px;
    margin-bottom: 12px;
}

.doc-closing-box {
    font-size: 13.5px;
    line-height: 1.5;
    color: #1e293b;
    margin-bottom: 16px;
}

/* Cursive Signature Area */
.signature-area {
    margin-top: 10px;
    margin-bottom: 20px;
}

.signature-font {
    font-family: 'Dancing Script', 'Alex Brush', cursive;
    font-size: 34px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    transform: rotate(-2deg);
    display: inline-block;
}

.signer-title {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
    font-style: italic;
}

/* ===================================================
   FOOTER (CONTACT ICONS + ORANGE MAP BACKGROUND)
   =================================================== */

.letter-footer {
    position: relative;
    z-index: 2;
    margin-top: auto;
    padding-bottom: 16px;
    min-height: 110px;
    display: flex;
    align-items: flex-end;
}

.footer-contact-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    position: relative;
    z-index: 10;
    max-width: 320px;
}

.footer-contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-icon-circle {
    width: 24px;
    height: 24px;
    background: #000000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 11px;
    flex-shrink: 0;
}

.contact-text-box {
    font-size: 11px;
    line-height: 1.35;
    color: #334155;
    font-weight: 500;
}

.contact-text-box a {
    color: #334155;
    text-decoration: none;
}

/* World Map Orange Wave Background */
.footer-bg-map {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 110px;
    background-image: url('../images/sss.edu.vn_paper_foot.png'), url('../../sss.edu.vn_paper_foot.png'), url('../sss.edu.vn_paper_foot.png'), url('/sss.edu.vn_paper_foot.png');
    background-repeat: no-repeat;
    background-position: bottom center;
    background-size: 100% auto;
    z-index: 1;
    pointer-events: none;
}

/* Batch Toolbar & Grid */
.batch-status-bar {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.batch-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.batch-item-card {
    position: relative;
    margin-bottom: 30px;
}

.batch-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 8px;
    width: var(--a4-width);
}

/* ===================================================
   PRINT STYLESHEET (PERFECT A4 MARGINLESS OUTPUT)
   =================================================== */

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    html, body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        height: 297mm !important;
    }

    .no-print, .app-header, .editor-sidebar, .preview-toolbar, .batch-card-actions, .batch-status-bar {
        display: none !important;
    }

    .app-container {
        height: auto !important;
        overflow: visible !important;
        display: block !important;
    }

    .preview-pane {
        padding: 0 !important;
        background: transparent !important;
        overflow: visible !important;
        display: block !important;
    }

    .a4-container {
        gap: 0 !important;
        display: block !important;
    }

    .a4-page {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 38px 46px 20px 46px !important;
        width: 210mm !important;
        height: 297mm !important;
        max-height: 297mm !important;
        page-break-after: always !important;
        page-break-inside: avoid !important;
        break-after: page !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .footer-bg-map {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
