
/* =========================================
   1. ROOT VARIABLES
========================================= */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f1f5f9;
    --surface: #fff;
    --text: #172033;
    --muted: #64748b;
    --border: #dbe2ea;
    --success: #16a34a;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(15, 23, 42, .06);
}


/* =========================================
   2. GLOBAL RESET & BASE STYLES
========================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}


/* =========================================
   3. APP HEADER
========================================= */

.app-header {
    background: #0f172a;
    color: #fff;
    padding: 22px 24px;
}

.header-inner {
    max-width: 1440px;
    margin: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: #2563eb;
    display: grid;
    place-items: center;
    font-size: 23px;
}

.app-header h1 {
    font-size: 22px;
    margin: 0;
    font-weight: 750;
}

.app-header p {
    color: #cbd5e1;
    margin: 4px 0 0;
    font-size: 13px;
}


/* =========================================
   4. MAIN CONTAINER & LAYOUT
========================================= */

.container {
    max-width: 1440px;
    margin: 24px auto;
    padding: 0 18px;
}

.top-grid {
    display: grid;
    grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}


/* =========================================
   5. PANEL / CARD STYLES
========================================= */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 16px;
    margin: 0;
}

.panel-header p {
    font-size: 12px;
    color: var(--muted);
    margin: 5px 0 0;
}

.panel-body {
    padding: 20px;
}


/* =========================================
   6. SECTION TITLES & FORM FIELDS
========================================= */

.section-title {
    font-size: 13px;
    font-weight: 700;
    margin: 0 0 13px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-weight: 650;
    font-size: 12px;
    margin-bottom: 6px;
}

.field input[type=text],
.field input[type=number],
.field select,
.field textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 10px 11px;
    background: #fff;
    outline: none;
    transition: border .2s, box-shadow .2s;
}

.field textarea {
    resize: vertical;
    min-height: 80px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}


/* =========================================
   7. FILE UPLOAD SECTION
========================================= */

.file-drop {
    border: 2px dashed #bfcee1;
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: .2s;
}

.file-drop:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.file-drop .drop-icon {
    font-size: 30px;
    margin-bottom: 6px;
}

.file-drop strong {
    display: block;
    font-size: 13px;
}

.file-drop span {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-top: 5px;
}

.file-drop input {
    display: none;
}

.selected-files {
    font-size: 12px;
    color: #475569;
    margin-top: 8px;
    overflow-wrap: anywhere;
}


/* =========================================
   8. BUTTONS
========================================= */

.btn {
    border: 0;
    border-radius: 9px;
    padding: 11px 15px;
    font-weight: 650;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    transition: .2s;
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
}

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

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

.btn-secondary {
    background: #eaf0f8;
    color: #1e293b;
}

.btn-secondary:hover {
    background: #dce6f3;
}

.btn-success {
    background: #15803d;
    color: white;
}

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

.btn-dark {
    background: #0f172a;
    color: white;
}

.btn-dark:hover {
    background: #1e293b;
}

.btn-outline {
    background: #fff;
    color: #334155;
    border: 1px solid var(--border);
}

.btn-danger {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.btn-warning {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.btn-block {
    width: 100%;
}

.button-stack {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
}


/* =========================================
   9. SETTINGS & HELPERS
========================================= */

.divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 10px 0;
    font-size: 12px;
}

.checkbox-row input {
    margin-top: 3px;
}


/* =========================================
   10. STATISTICS
========================================= */

.stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.stat {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 650;
}


/* =========================================
   11. PHOTO ENTRIES LIST
========================================= */

.entries-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.entry-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px 112px;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px;
    background: #fff;
}

.entry-info {
    min-width: 0;
}

.entry-title {
    font-size: 12px;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.entry-remark {
    color: #64748b;
    font-size: 11px;
    overflow-wrap: anywhere;
    margin-top: 3px;
}

.entry-row img {
    width: 88px;
    height: 62px;
    object-fit: cover;
    border-radius: 7px;
    background: #f1f5f9;
    margin-left: -40px;
}

.entry-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.entry-actions .btn {
    font-size: 10px;
    padding: 6px 5px;
}


/* =========================================
   12. EMPTY STATE
========================================= */

.empty-state {
    padding: 36px 15px;
    text-align: center;
    color: #94a3b8;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
}

.empty-state .empty-icon {
    font-size: 34px;
    margin-bottom: 8px;
}

.empty-state strong {
    display: block;
    color: #64748b;
    margin-bottom: 4px;
}


/* =========================================
   13. PREVIEW PANEL & TOOLBAR
========================================= */

.preview-panel {
    margin-top: 20px;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.preview-toolbar .toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.preview-toolbar h2 {
    font-size: 16px;
    margin: 0;
}

.preview-area {
    background: #dfe6ee;
    padding: 22px 12px;
    overflow: auto;
}

.preview-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}


/* =========================================
   14. A4 REPORT PAGE
========================================= */

.report-page {
    width: 210mm;
    height: 297mm;
    background: white;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    color: #111827;
    box-shadow: 0 5px 24px rgba(15, 23, 42, .15);
    display: flex;
    flex-direction: column;
}


/* =========================================
   15. PAGE BORDER
========================================= */

.page-border {
    position: absolute;
    inset: 8mm;
    pointer-events: none;
    z-index: 4;
}

.border-none .page-border {
    border: none;
}

.border-thin .page-border {
    border: .4pt solid #333;
}

.border-medium .page-border {
    border: 1.1pt solid #222;
}

.border-thick .page-border {
    border: 2.2pt solid #111;
}

.border-double .page-border {
    border: 3pt double #222;
}


/* =========================================
   16. REPORT HEADER & FOOTER
========================================= */

.report-header {
    flex-shrink: 0;
    text-align: center;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 13mm 14mm 5mm;
    font-weight: 700;
    font-size: 12pt;
}

.report-footer {
    flex-shrink: 0;
    text-align: center;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 4mm 14mm 12mm;
    font-size: 9pt;
    color: #333;
}


/* =========================================
   17. REPORT CONTENT GRID
========================================= */

.report-content {
    flex: 1;
    min-height: 0;
    padding: 4mm 13mm;
    display: grid;
    gap: 4mm;
}


/* =========================================
   18. REPORT PHOTO ITEMS
========================================= */

.report-item {
    border: .5pt solid #b8b8b8;
    border-radius: 1mm;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    break-inside: avoid;
}

.report-item-title {
    background: #f3f4f6;
    font-weight: 700;
    font-size: 10pt;
    text-align: center;
    padding: 2mm 3mm;
    overflow-wrap: anywhere;
    flex-shrink: 0;
}

.report-image-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2mm;
    overflow: hidden;
}

.report-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.fit-cover .report-image {
    object-fit: cover;
}

.fit-contain .report-image {
    object-fit: contain;
}


/* =========================================
   19. PHOTO REMARKS
========================================= */

.report-remark {
    padding: 2mm 3mm;
    border-top: .5pt solid #ccc;
    font-size: 9pt;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    flex-shrink: 0;
}

.report-remark-label {
    font-weight: 700;
}


/* =========================================
   20. PAGE NUMBER
========================================= */

.page-number {
    font-size: 8pt;
    color: #666;
    text-align: right;
    padding-right: 14mm;
    padding-bottom: 2mm;
    flex-shrink: 0;
}


/* =========================================
   21. APP FOOTER
========================================= */

.app-footer {
    text-align: center;
    padding: 25px 15px;
    color: #64748b;
    font-size: 12px;
    clear: both;
}


/* =========================================
   22. RESPONSIVE DESIGN - TABLET
========================================= */

@media (max-width: 1000px) {
    .top-grid {
        grid-template-columns: 1fr;
    }

    .container {
        margin: 14px auto;
    }
}


/* =========================================
   23. RESPONSIVE DESIGN - MOBILE
========================================= */

@media (max-width: 600px) {
    .app-header {
        padding: 16px;
    }

    .app-header h1 {
        font-size: 19px;
    }

    .container {
        padding: 0 10px;
    }

    .panel-body {
        padding: 15px;
    }

    .settings-grid {
        grid-template-columns: 1fr 1fr;
        gap: 9px;
    }

    .preview-area {
        padding: 12px 6px;
    }

    .entry-row {
        grid-template-columns: minmax(0, 1fr) 66px 100px;
        gap: 6px;
    }

    .entry-row img {
        width: 66px;
        height: 52px;
    }

    .entry-actions .btn {
        font-size: 9px;
        padding: 6px 3px;
    }

    .preview-toolbar {
        align-items: flex-start;
    }

    .toolbar-left {
        flex-wrap: wrap;
    }
}


/* =========================================
   24. PRINT STYLES
========================================= */

@media print {
    body {
        background: white;
    }

    .report-page {
        box-shadow: none;
    }
}
