/* ========== গ্লোবাল স্টাইল ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e40af;
    --secondary-color: #f59e0b;
    --border-dark: #000;
    --text-dark: #1f2937;
    --text-muted: #6b7280;
    --bg-light: #f9fafb;
    --watermark-color: rgba(0, 0, 0, 0.05);
    
    /* A4 Page Dimensions */
    --a4-width: 210mm;
    --a4-height: 297mm;
    
    /* Reduced Margins (50% smaller) */
    --page-margin-top: 10mm;      /* was 20mm */
    --page-margin-bottom: 10mm;   /* was 20mm */
    --page-margin-left: 10mm;     /* was 20mm */
    --page-margin-right: 10mm;    /* was 20mm */
    --footer-space: 8mm;          /* was 15mm */
}

html, body {
    height: 100%;
    font-family: 'Noto Sans Bengali', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px;
}

/* ========== মেইন কন্টেইনার ========== */
.container {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 20px;
    max-width: 1900px;
    margin: 0 auto;
    height: auto;
    min-height: calc(100vh - 30px);
}

/* ========== বাম প্যানেল: ইনপুট ========== */
.input-panel {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    max-height: calc(100vh - 30px);
}

.panel-header {
    text-align: center;
    margin-bottom: 25px;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 20px;
}

.panel-header h1 {
    color: var(--primary-color);
    font-size: 26px;
    margin-bottom: 8px;
}

.panel-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ========== ফর্ম স্টাইল ========== */
.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 700;
    margin-bottom: 7px;
    color: var(--text-dark);
    font-size: 13px;
}

.required {
    color: #ef4444;
    font-weight: bold;
}

.form-group input[type="text"],
.form-group textarea {
    padding: 11px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-family: 'Noto Sans Bengali', sans-serif;
    font-size: 13px;
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 180px;
    white-space: pre-wrap;
}

.hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* ========== ফন্ট সাইজ কন্ট্রোল ========== */
.form-divider {
    height: 2px;
    background: #e5e7eb;
    margin: 20px 0;
}

.section-title {
    color: var(--primary-color);
    font-size: 15px;
    margin: 15px 0 12px 0;
    font-weight: 700;
}

.font-size-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.font-size-group label {
    font-weight: 700;
    margin-bottom: 7px;
    color: var(--text-dark);
    font-size: 12px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.font-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.font-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.font-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.font-size-value {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 12px;
    min-width: 45px;
    text-align: right;
}

/* ========== অ্যাকশন বাটন ========== */
.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 25px;
}

.btn {
    padding: 11px 18px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: 'Noto Sans Bengali', sans-serif;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1e3a8a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 64, 175, 0.3);
}

.btn-secondary {
    background: var(--text-muted);
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}
/* ========== ডান প্যানেল: প্রিভিউ ========== */
.preview-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 30px);
}

.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

.preview-controls h2 {
    color: var(--text-dark);
    font-size: 17px;
    font-weight: 700;
}

.export-buttons {
    display: flex;
    gap: 10px;
}

.btn-export {
    padding: 9px 15px;
    font-size: 12px;
    border-radius: 5px;
}

.btn-png {
    background: #3b82f6;
    color: white;
}

.btn-png:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
}

.btn-jpg {
    background: #f59e0b;
    color: white;
}

.btn-jpg:hover {
    background: #d97706;
    transform: translateY(-2px);
}

/* ========== প্রিভিউ কন্টেইনার (মাল্টি-পেজ) ========== */
.preview-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f3f4f6;
    border-radius: 8px;
}

.placeholder-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.placeholder-message p {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

/* ========== A4 পেজ স্টাইল (EXACT সাইজ + 50% Reduced Margins) ========== */
.a4-page {
    background: white;
    width: var(--a4-width);
    height: var(--a4-height);
    padding-top: var(--page-margin-top);
    padding-bottom: var(--page-margin-bottom);
    padding-left: var(--page-margin-left);
    padding-right: var(--page-margin-right);
    margin: 0 auto 20px auto;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    page-break-after: always;
    font-family: 'Noto Sans Bengali', sans-serif;
    overflow: hidden;
    box-sizing: border-box;
}

.a4-page:last-child {
    margin-bottom: 0;
}

/* ========== Debug Mode: Show Printable Area ========== */
.a4-page.debug-mode::before {
    content: '';
    position: absolute;
    top: var(--page-margin-top);
    left: var(--page-margin-left);
    right: var(--page-margin-right);
    bottom: var(--page-margin-bottom);
    border: 2px dashed rgba(255, 0, 0, 0.3);
    pointer-events: none;
    z-index: 9999;
}

.a4-page.debug-mode::after {
    content: 'Debug Mode: Printable Area';
    position: absolute;
    top: calc(var(--page-margin-top) + 5px);
    left: calc(var(--page-margin-left) + 5px);
    font-size: 10px;
    color: rgba(255, 0, 0, 0.6);
    font-weight: bold;
    pointer-events: none;
    z-index: 9999;
}

/* ========== Content Wrapper (respects margins) ========== */
.page-content-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* ========== টাইটেল স্টাইল ========== */
.titles-container {
    margin-bottom: 10px;
}

.page-title {
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 3px 0;
    padding: 0;
    text-align: center;
    line-height: 1.3;
    word-wrap: break-word;
    border: none;
}

.page-title.last-title {
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 3px solid var(--border-dark);
}

/* ========== বিষয়বস্তু স্টাইল ========== */
.page-content {
    text-align: justify;
    font-size: 13px;
    line-height: 1.2;
}

.page-content p {
    margin: 0 0 5px 0;
    padding: 0;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.page-content ul,
.page-content ol {
    margin: 0 0 6px 0;
    padding-left: 20px;
}

.page-content li {
    margin: 0 0 3px 0;
    padding: 0;
}

.page-content strong {
    font-weight: 700;
    color: var(--text-dark);
}

/* ========== Content Block (never split) ========== */
.content-block {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 8px;
  }
/* ========== ওয়াটারমার্ক স্টাইল ========== */
.watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 60px;
    font-weight: 700;
    color: var(--watermark-color);
    opacity: 0.3;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    z-index: 1;
    text-transform: uppercase;
    letter-spacing: 5px;
}

/* ========== ফুটার স্টাইল ========== */
.page-footer {
    position: absolute;
    bottom: var(--page-margin-bottom);
    left: var(--page-margin-left);
    right: var(--page-margin-right);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding-top: 5px;
    border-top: 1px solid #d1d5db;
    z-index: 3;
}

/* ========== স্ক্রলবার ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== রেসপন্সিভ ডিজাইন ========== */
@media (max-width: 1400px) {
    .container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 900px) {
    html, body {
        padding: 10px;
    }

    .input-panel,
    .preview-panel {
        padding: 20px;
    }

    .panel-header h1 {
        font-size: 20px;
    }

    .a4-page {
        width: 100%;
        height: auto;
        min-height: var(--a4-height);
    }

    .export-buttons {
        flex-direction: column;
        width: 100%;
    }

    .btn-export {
        width: 100%;
    }

    .preview-controls {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

/* ========== প্রিন্ট স্টাইল ========== */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        margin: 0;
        padding: 0;
    }

    .a4-page {
        margin: 0;
        box-shadow: none;
        page-break-after: always;
        width: var(--a4-width);
        height: var(--a4-height);
    }

    .a4-page:last-child {
        page-break-after: auto;
    }

    .a4-page.debug-mode::before,
    .a4-page.debug-mode::after {
        display: none;
    }
  }
