@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Bengali:wght@400;500;700&display=swap');

:root {
    --primary-color: #007bff;
    --primary-dark: #0056b3;
    --footer-bg-color: #004080;
    --footer-border-color: #0056b3;
    --secondary-color: #6c757d;
    --surface-color: #ffffff;
    --background-color: #f4f7f9;
    --border-color: #dee2e6;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --font-family: 'Noto Sans Bengali', Arial, sans-serif;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 8px;
}

/* --- Base & Layout --- */
* { box-sizing: border-box; }
html { height: 100%; }
body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: #343a40;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}
.container {
    flex-grow: 1;
    width: 100%;
    max-width: 1600px;
    margin: 10px auto;
    background: var(--surface-color);
    box-shadow: var(--shadow);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.main-content {
    flex-grow: 1;
}

/* --- Header --- */
.site-header { background: #fff; }
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, #0056b3, #007bff);
    color: #fff;
    padding: 10px 30px;
    font-size: 0.9em;
}
.top-nav a { color: #fff; text-decoration: none; margin-right: 20px; font-weight: bold; transition: opacity 0.3s; }
.top-nav a:hover { opacity: 0.8; }
.contact-details span { margin-left: 20px; display: inline-flex; align-items: center; }
.contact-details span::before { content: ''; display: inline-block; width: 16px; height: 16px; margin-right: 8px; background-repeat: no-repeat; background-size: contain; }
.contact-details .phone::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.02.74-.25 1.02l-2.2 2.2z"/></svg>'); }
.contact-details .email::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>'); }
.page-header { text-align: center; padding: 25px 20px 15px; }
.header-logo { width: 280px; margin-bottom: 15px; }
.header-title { font-size: 1.3em; color: #333; font-weight: 700; text-transform: uppercase; margin: 0; }

/* --- Trending News Ticker --- */
.trending-news-container { background-color: #fff3cd; border: 1px solid #ffeeba; color: #ff1100; padding: 10px 0; overflow: hidden; white-space: nowrap; box-sizing: border-box; }
.trending-news-scroll { display: inline-block; padding-left: 100%; animation: trending-news-scroll 95s linear infinite; }
@keyframes trending-news-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

/* --- Main Content --- */
.main-content { padding: 30px; }
h1 { font-size: 1.6em; color: #0056b3; text-align: center; margin-bottom: 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 25px; background-color: #f8f9fa; border: 1px solid var(--border-color); border-radius: var(--border-radius); margin: 25px 0; }
.filter-group { position: relative; }
.filter-group label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--secondary-color); }
.filter-group select, .filter-group input { width: 100%; padding: 12px; border: 1px solid #ced4da; border-radius: 5px; font-size: 1em; font-family: inherit; transition: border-color 0.3s, box-shadow 0.3s; }
.filter-group select:disabled { background-color: #e9ecef; cursor: not-allowed; }
.filter-group select:focus, .filter-group input:focus { border-color: var(--primary-color); box-shadow: 0 0 5px rgba(0, 123, 255, 0.25); outline: none; }
.bangla-typing-button { position: absolute; top: 0; right: 0; background: #007bff; color: white; border: none; padding: 4px 8px; font-size: 0.8em; border-radius: 4px; cursor: pointer; transition: background-color 0.3s; }
.bangla-typing-button:hover { background-color: #0056b3; }

/* --- Search & Print Button Styles --- */
.search-button-container { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 20px; margin-bottom: 30px; }
.search-button { background: var(--primary-color); color: white; border: none; padding: 15px 45px; font-size: 1.1em; font-weight: bold; border-radius: 5px; cursor: pointer; transition: background-color 0.3s, transform 0.2s; }
.search-button:hover { background-color: var(--primary-dark); transform: translateY(-2px); }

/* --- NEW STYLE FOR THE SHOW PDF BUTTON --- */
#showPdfButton {
    background-color: #de0073; /* This is a yellow color. Change it to any color you like! */
}
#showPdfButton:hover {
    background-color: #e0a800; /* A darker shade for the hover effect */
}
/* --- END OF NEW STYLE --- */

.print-options { display: flex; align-items: center; gap: 15px; background-color: #f0f0f0; padding: 8px 20px; border-radius: var(--border-radius); }
.print-options span { font-weight: 500; font-size: 1.1em; color: #333; }
.print-options span b { color: var(--primary-color); }
.print-selected-button { background: var(--success-color); color: white; border: none; padding: 12px 20px; font-size: 1em; font-weight: bold; border-radius: 5px; cursor: pointer; transition: background-color 0.3s, transform 0.2s; }
.print-selected-button:hover { background-color: #218838; transform: translateY(-2px); }
.print-selected-button:disabled { background-color: #aaa; cursor: not-allowed; transform: none; box-shadow: none; }

/* --- Results Area --- */
#results-area { position: relative; min-height: 200px; }
#results-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #eef5ff;
    border: 1px solid #b8d6ff;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 1.1em;
}
#polling-station-name, #total-voters-count {
    font-weight: bold;
    color: var(--primary-dark);
}
#results { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.record-card { background: var(--surface-color); border: 1px solid var(--border-color); border-radius: var(--border-radius); animation: fadeIn 0.5s ease-in-out; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: transform 0.3s, box-shadow 0.3s; overflow: hidden; }
.record-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.card-header { background-color: #f8f9fa; padding: 10px 15px; border-bottom: 1px solid var(--border-color); font-weight: bold; display: flex; align-items: center; gap: 10px; }
.voter-select-checkbox { transform: scale(1.3); cursor: pointer; }
.card-body { padding: 15px; }
.card-body p { margin: 10px 0; font-size: 1em; line-height: 1.6; }
.card-body p strong { display: inline-block; width: 150px; color: #495057; }
.card-footer { padding: 15px; background-color: #f8f9fa; text-align: right; border-top: 1px solid var(--border-color); }
.print-receipt-button { background-color: #17a2b8; color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; }
.print-receipt-button:hover { background-color: #138496; }
.loader { display: none; border: 5px solid #f3f3f3; border-top: 5px solid var(--primary-color); border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 100px auto; }
#status-message { text-align: center; color: var(--secondary-color); padding: 50px; font-size: 1.2em; }

#pagination-container { text-align: center; margin-top: 30px; }
#pagination-container-top { text-align: center; margin-bottom: 20px; }

.pagination-button { display: inline-block; padding: 8px 16px; margin: 0 4px; border: 1px solid #dee2e6; border-radius: 4px; cursor: pointer; color: #007bff; background-color: #ffffff; font-weight: bold; transition: background-color 0.3s, color 0.3s; }
.pagination-button:hover { background-color: #e9ecef; }
.pagination-button.active { background-color: #007bff; color: white; border-color: #007bff; cursor: default; }
.pagination-button.disabled { cursor: not-allowed; color: #adb5bd; background-color: #f8f9fa; }

/* --- Modal & Input Tools --- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); }
.modal-content { background-color: #fefefe; margin: 5% auto; padding: 30px; border: 1px solid #888; width: 90%; max-width: 700px; border-radius: 10px; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }
.modal-footer { text-align: right; margin-top: 30px; }
.print-button { background-color: var(--success-color); color: white; padding: 12px 25px; border: none; border-radius: 5px; cursor: pointer; font-size: 1.1em; transition: background-color 0.3s; }
#inputToolsModal .modal-content { width: 95%; max-width: 1000px; height: 80vh; }
#inputToolsIframe { width: 100%; height: 100%; border: none; }

/* --- MODIFIED: Updated styles for the new PDF Viewer Modal --- */
#pdfModal {
    align-items: center;
    justify-content: center;
}

#pdfModal .modal-content {
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    padding: 15px;
    display: flex;
    flex-direction: column;
    margin: 0; /* Remove default margin to allow centering */
}

#pdfModal .close {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%; /* Makes it a circle */
    background-color: rgba(255, 255, 255, 0.9); /* Semi-transparent white background */
    color: #333; /* Dark grey 'x' symbol */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    line-height: 1; /* Helps with vertical alignment */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); /* Adds depth */
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

#pdfModal .close:hover {
    background-color: #ffffff; /* Becomes solid white on hover */
    transform: scale(1.1);   /* Slightly enlarges on hover */
}

#pdfFrame {
    flex-grow: 1; /* Allows the iframe to fill the available space */
    width: 100%;
    height: 100%;
    border: none;
}
/* --- End of new styles --- */

/* --- Original Footer Styles --- */
.site-footer {
    background-color: var(--footer-bg-color);
    color: #e9ecef;
    padding: 50px 30px 0;
    font-size: 1em;
    margin-top: auto;
}
.footer-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
}
.footer-column h4 {
    color: #ffffff;
    font-weight: 700;
    font-size: 1.2em;
    margin-top: 0;
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--footer-border-color);
    position: relative;
}
.footer-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.footer-column ul li {
    margin-bottom: 12px;
}
.footer-column ul li a {
    color: #e9ecef;
    text-decoration: none;
    transition: color 0.3s;
}
.footer-column ul li a:hover {
    color: #ffffff;
}
.footer-contact-info p {
    display: flex;
    align-items: center;
    margin: 0 0 15px 0;
}
.footer-contact-info i {
    margin-right: 15px;
    font-size: 1.1em;
    width: 20px;
    text-align: center;
}
.footer-social-icons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}
.footer-social-icons a {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-decoration: none;
    font-size: 1.1em;
    transition: background-color 0.3s;
}
.footer-social-icons a:hover {
    background-color: var(--primary-color);
}
.footer-bottom {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--footer-border-color);
    text-align: center;
    font-size: 0.9em;
    color: #adb5bd;
}
.footer-bottom p {
    margin: 8px 0;
}

/* --- Responsive Design --- */
@media (max-width: 992px) { .filter-grid { grid-template-columns: repeat(2, 1fr); } .footer-container { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    body { padding: 0; } .container { border-radius: 0; margin: 0; } .main-content { padding: 15px; }
    .filter-grid { grid-template-columns: 1fr; padding: 15px; } .top-nav { flex-direction: column; gap: 10px; padding: 15px; }
    .top-nav-left, .top-nav-right { text-align: center; width: 100%; } .contact-details { margin-top: 10px; }
    .contact-details span { margin: 0 10px; } .header-logo { width: 200px; } h1 { font-size: 1.4em; }
    .record-card p strong { width: 120px; } .footer-container { grid-template-columns: 1fr; }
    .search-button-container { flex-direction: column; }
}

/*
==========================================================================
--- ON-SCREEN & PRINT STYLES ---
==========================================================================
*/

/* --- STYLES FOR ON-SCREEN MODAL PREVIEW --- */
#receiptModal .modal-content.multi-print-preview { max-width: 1200px; width: 95%; }
#receiptModal .print-page-4 {
    display: grid; grid-template-columns: 1fr 1fr; gap: 15px;
    background: #f4f4f4; padding: 20px; border-radius: 5px;
}
#receiptModal .voter-slip {
    background: #fff; padding: 15px; border: 1px solid #e0e0e0; border-radius: 5px;
}
#receiptModal .voter-slip-header { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #ccc; padding-bottom: 10px; margin-bottom: 10px; }
#receiptModal .voter-slip-header img { width: 60px; height: auto; }
#receiptModal .voter-slip-header-text { flex-grow: 1; text-align: center; }
#receiptModal .voter-slip-title { font-size: 1em; font-weight: bold; }
#receiptModal .voter-slip-subtitle { font-size: 0.8em; }
#receiptModal .voter-slip-details { display: flex; flex-direction: column; gap: 8px; font-size: 0.9em; }
#receiptModal .detail-row { display: flex; justify-content: space-between; border-bottom: 1px dotted #d0d0d0; padding-bottom: 8px; }
#receiptModal .detail-row:last-child { border-bottom: none; }
#receiptModal .detail-label { color: #555; }
#receiptModal .detail-value { font-weight: 500; text-align: right; }

#receiptModal .receipt-header { text-align: center; margin-bottom: 25px; border-bottom: 2px solid #eee; padding-bottom: 15px; }
#receiptModal .receipt-header img { width: 150px; margin-bottom: 10px; }
#receiptModal .receipt-title { font-size: 1.6em; font-weight: bold; color: #333; }
#receiptModal .receipt-subtitle { text-align: center; font-size: 1.2em; color: #444; margin: -10px 0 20px 0; font-weight: bold; }
#receiptModal .receipt-details p { margin: 12px 0; font-size: 1.1em; border-bottom: 1px dashed #ccc; padding-bottom: 12px; }
#receiptModal .receipt-details strong { display: inline-block; width: 200px; color: #555; }

/*
==========================================================================
--- STYLES FOR PRINTING ---
==========================================================================
*/
@media print {
    /* 1. Define a named page rule for single prints that HAS margins */
    @page single-with-margin {
        size: A4;
        margin: 20mm 15mm; /* Top/Bottom: 20mm, Left/Right: 15mm. Adjust as needed. */
    }

    /* 2. Define the default page rule for everything else (e.g., multi-print) */
    @page {
        size: A4;
        margin: 0; /* NO MARGINS */
    }

    /* General print setup */
    body, html {
        background-color: #fff;
        -webkit-print-color-adjust: exact;
    }
    body > *:not(.printable-content) { display: none; }

    .printable-content, .printable-content .modal-content {
        display: block !important; position: static; width: 100%; height: 100%;
        overflow: visible; background-color: transparent; margin: 0; padding: 0;
        border: none; box-shadow: none;
    }
    .close, .modal-footer { display: none !important; }
    
    /* 3. Apply the named page with margins ONLY to the single receipt */
    .modal-content.single-print-preview {
        page: single-with-margin;
    }
    
    /* Styles for the content inside the single print view */
    .receipt-header { text-align: center; margin-bottom: 25px; border-bottom: 2px solid #eee; padding-bottom: 15px; }
    .receipt-header img { width: 120px !important; margin-bottom: 10px; }
    .receipt-title { font-size: 16pt; font-weight: bold; color: #333; }
    .receipt-subtitle { text-align: center; font-size: 14pt; color: #444; margin: -10px 0 20px 0; font-weight: bold; }
    .receipt-details p { margin: 12px 0; font-size: 12pt; border-bottom: 1px dashed #ccc; padding-bottom: 12px; }
    .receipt-details strong { display: inline-block; width: 200px; color: #555; }
    
    
    /* 4. The multi-voter print will automatically use the default @page rule (no margin) */
    .modal-content.multi-print-preview {
        padding: 0; /* This has no effect on margins, but is good practice */
    }
    .voter-slip {
        display: flex; flex-direction: column; background-color: #fff;
        padding: 5mm; border: 0.5px solid #ccc; /* Thin border between slips */
        box-sizing: border-box;
    }
    .voter-slip-header { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #ccc; padding-bottom: 3mm; margin-bottom: 3mm; }
    .voter-slip-header img { width: 15mm !important; height: auto; }
    .voter-slip-header-text { flex-grow: 1; text-align: center; }
    .voter-slip-details { display: flex; flex-direction: column; }
    .detail-row { display: flex; justify-content: space-between; border-bottom: 1px dotted #d0d0d0; }
    .detail-row:last-child { border-bottom: none; }
    .detail-label { color: #555; } .detail-value { color: #000; font-weight: 500; text-align: right; }
    
    .print-page-4 {
        display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
        gap: 0; /* No gap between slips */
        width: 210mm; height: 297mm; /* Full A4 dimensions */
        padding: 0; /* No padding on the page itself */
        page-break-after: always; box-sizing: border-box; overflow: hidden;
    }
    .print-page-4:last-child { page-break-after: auto; }
    .print-page-4 .voter-slip-title { font-size: 11pt; }
    .print-page-4 .voter-slip-subtitle { font-size: 8pt; }
    .print-page-4 .voter-slip-details { font-size: 9pt; gap: 1.5mm; }
    .print-page-4 .detail-row { padding-bottom: 1.5mm; }
}