@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;600;700;800&display=swap');

/* ====================================================
   BASIC RESET & COMMON STYLES (From si_page.css)
   ==================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Sarabun', sans-serif;
    margin: 0;
    padding: 0;
    background: #f0f0f0;
}

/* Common Card & Component Styles */
.info-card {
    background: white;
    border-radius: 12px;
    padding: 12px 15px;
    border: 1px solid rgba(131, 197, 190, 0.3);
    box-shadow: 0 4px 10px rgba(0, 77, 77, 0.02);
}

.logo-card {
    display: flex;
    justify-content: center;
    align-items: center;
}

.side-logo {
    width: 80%;
    height: auto;
    max-height: 96px; /* ลดลงรวม 20% จาก 120px */
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

/* Legend Styles */
.legend-group { margin-bottom: 8px; }
.group-title {
    font-weight: 800;
    color: #006d77;
    font-size: 13px;
    margin-bottom: 6px;
    border-bottom: 1px solid #eef;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: #334e4e;
    margin-bottom: 5px;
}
.legend-item .box { width: 16px; height: 16px; border-radius: 4px; }
.legend-item .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid white; }

.rice { background: #2ecc71; }
.fruit { background: #f1c40f; }
.flower { background: #ff00e6; }
.normal { background: #009d41; }
.warning-1 { background: #f1c40f; }
.warning-2 { background: #e67e22; }
.danger { background: #e74c3c; }
.boundary-watch { width: 22px; height: 16px; border: 2px solid #e91e63; background: rgba(233, 30, 99, 0.08); }

/* Table Styles */
.table-card { display: flex; flex-direction: column; overflow: hidden; }
.table-card h4 { font-size: 13.5px; color: #004d4d; font-weight: 800; margin-bottom: 10px; }
.table-wrapper { flex: 1; overflow-y: hidden; border: 1px solid #eef3f3; border-radius: 8px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table th { background: #f8fbfa; padding: 6px; color: #006d77; border-bottom: 2px solid #83c5be; }
.mini-table td { padding: 6px; border-bottom: 1px solid #f4f8f8; text-align: center; }

/* Advice & Source */
.advice { font-size: 11px; background: #fff3cd; padding: 8px; border-radius: 8px; border-left: 4px solid #ffc107; margin-bottom: 5px; }
.source-box { background: #e5e5e5; border: 1px solid #777; padding: 6px; font-size: 10px; }
.source-title { font-weight: 800; text-decoration: underline; margin-bottom: 3px; }
.organizer { font-size: 11px; font-weight: 800; color: #333; margin-top: 5px; }

/* ====================================================
   A3 LANDSCAPE PRINT LAYOUT (CORE SETUP)
   ==================================================== */
:root {
  --a3-width: 420mm;
  --a3-height: 297mm;
}

body {
    background: #f0f0f0;
    display: flex;
    justify-content: center;
    overflow: auto !important;
}

.app {
    display: grid !important;
    grid-template-rows: 1fr !important; /* บังคับแถวเดียว ไม่มี Header */
    width: var(--a3-width) !important;
    height: var(--a3-height) !important;
    min-width: var(--a3-width) !important;
    max-width: var(--a3-width) !important;
    min-height: var(--a3-height) !important;
    max-height: var(--a3-height) !important;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    margin: 20px 0;
    overflow: hidden;
}

.dashboard-main {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    padding: 10mm !important;
    gap: 8mm !important;
}

.map-container {
    flex: 1 !important;
    position: relative;
    border-radius: 8px !important;
    border: 1px solid #ccc !important;
    overflow: hidden;
    background: #f9f9f9;
}

#map {
    width: 100%;
    height: 100%;
}

.map-title-overlay {
    width: 100%;
    text-align: center;
    padding: 12px 0;
    font-weight: 800;
    font-size: 32px !important;
    color: #004d4d;
    line-height: 1.2;
    z-index: 1000;
}

.info-sidebar {
    width: 120mm !important;
    display: flex;
    flex-direction: column;
    gap: 4mm !important;
    height: 100% !important;
    overflow-y: hidden !important;
}

/* ====================================================
   PRINT SPECIFIC (MEDIA PRINT)
   ==================================================== */
@media print {
    @page {
        size: A3 landscape;
        margin: 0;
    }
    body {
        background: white;
        padding: 0;
        margin: 0;
    }
    .app {
        margin: 0 !important;
        box-shadow: none !important;
    }
    #floating_print_btn, 
    #login_overlay, 
    #contact_overlay, 
    .resizer-v {
        display: none !important;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* =========================
   MODAL & PROCESSING STYLES
========================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.processing-card {
    background: white;
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
}

.modern-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #008080;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.proc-title {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.proc-status {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.btn-cancel-modal {
    margin-top: 10px;
    background: #f8f8f8;
    color: #888;
    border: 1px solid #eee;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Floating Button */
#floating_print_btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 5000;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #006d77;
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
