/* CSS Design System for DaenChamPa Construction App (Light Mode) */

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

@font-face {
    font-family: 'PhetsarathOT';
    src: url('PhetsarathOT.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Lao_Handwriting17';
    src: url('Lao_Muangthong.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Lao_Muangthong';
    src: url('Lao_Muangthong.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    /* Color Palette */
    --primary: #c29d53;       /* Luxury Gold */
    --primary-rgb: 194, 157, 83;
    --primary-hover: #b0893a;
    --secondary: #002d62;     /* Deep Royal Blue */
    --secondary-rgb: 0, 45, 98;
    --dark-bg: #ffffff;       /* Pure White Background */
    --card-bg: #ffffff;       /* White Card Background */
    --card-border: rgba(194, 157, 83, 0.18);
    --card-border-hover: rgba(194, 157, 83, 0.35);
    
    /* Text Colors */
    --text-main: #0f172a;     /* Dark Slate Text */
    --text-muted: #475569;    /* Muted Slate */
    --text-gold: #aa7c11;     /* Bronze/Gold for headers */
    --text-pen: #010da4;       /* Pen Blue */
    
    /* Status Colors */
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;

    /* Transitions & Shadows */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --glow: 0 0 15px rgba(194, 157, 83, 0.1);
}

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

body {
    font-family: 'PhetsarathOT', 'Outfit', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 45, 98, 0.015) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(194, 157, 83, 0.015) 0%, transparent 45%);
    background-attachment: fixed;
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(194, 157, 83, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(194, 157, 83, 0.6);
}

/* Layout Container */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-container {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--glow);
}

.logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-title-container h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.header-title-container p {
    font-size: 0.8rem;
    color: var(--text-gold);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: 'PhetsarathOT', sans-serif;
    font-size: 0.95rem;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.04);
}

.tab-btn.active {
    color: var(--text-main);
    background: rgba(194, 157, 83, 0.15);
    border-color: var(--primary);
    box-shadow: var(--glow);
}

/* Tab Content */
.tab-content {
    display: none;
}

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

/* Dashboard Panel Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
}

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

/* Glassmorphism Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--card-border-hover);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-gold);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 10px;
}

/* Form Styles */
.form-section {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.form-group.full-width {
    grid-column: span 2;
}

label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

input, select, textarea {
    background: #ffffff;
    border: 1px solid rgba(194, 157, 83, 0.4);
    border-radius: 8px;
    color: var(--text-main);
    padding: 10px 14px;
    font-family: 'PhetsarathOT', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(194, 157, 83, 0.25);
    background: #ffffff;
}

/* Weather Checkbox Container */
.weather-container {
    display: flex;
    gap: 16px;
    margin-top: 4px;
}

.weather-box {
    flex: 1;
    position: relative;
}

.weather-box input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.weather-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.weather-box input[type="radio"]:checked + .weather-label {
    background: rgba(194, 157, 83, 0.12);
    border-color: var(--primary);
    box-shadow: var(--glow);
}

.weather-box input[type="radio"]:checked + .weather-label .weather-icon {
    transform: scale(1.1);
    color: var(--text-gold);
}

.weather-icon {
    font-size: 1.5rem;
    transition: var(--transition);
}

/* Work Item Tree CSS */
.work-item-tree {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.6);
}

.category-node {
    margin-bottom: 12px;
}

.category-header {
    font-weight: 700;
    color: var(--secondary);
    font-size: 0.95rem;
    padding: 6px 8px;
    background: rgba(194, 157, 83, 0.12);
    border-radius: 6px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.subcategory-node {
    margin-left: 16px;
    margin-bottom: 8px;
}

.subcategory-header {
    font-weight: 600;
    color: var(--text-gold);
    font-size: 0.9rem;
    padding: 4px 6px;
    margin-bottom: 4px;
    border-left: 2px solid var(--primary);
    padding-left: 8px;
}

.items-list {
    margin-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
    cursor: pointer;
}

.item-row:hover {
    background: rgba(0, 0, 0, 0.03);
}

.item-row.selected {
    background: rgba(194, 157, 83, 0.12);
}

.item-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    margin-top: 3px;
}

.item-label-content {
    display: flex;
    flex-direction: column;
    font-size: 0.88rem;
}

.item-desc {
    color: var(--text-main);
}

.item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    gap: 8px;
}

.order-badge {
    background: var(--primary);
    color: #ffffff;
    border-radius: 4px;
    padding: 0px 5px;
    font-weight: 700;
    font-size: 0.72rem;
    display: inline-block;
}

/* Numeric Selection Boxes */
.counter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.counter-btn {
    background: rgba(194, 157, 83, 0.15);
    border: 1px solid var(--primary);
    color: var(--text-gold);
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-weight: bold;
}

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

.counter-value {
    font-size: 1.1rem;
    font-weight: 600;
    width: 40px;
    text-align: center;
}

/* Volume Formulas Box */
.calc-container {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 16px;
    margin-top: 10px;
}

.calc-formula-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.formula-btn {
    flex: 1;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-muted);
    padding: 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-weight: 600;
}

.formula-btn.active {
    background: rgba(194, 157, 83, 0.15);
    border-color: var(--primary);
    color: var(--text-main);
}

.formula-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.formula-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.formula-input-group label {
    font-size: 0.75rem;
}

.formula-input-group input {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.calc-result-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(194, 157, 83, 0.08);
    border: 1px dashed var(--primary);
    padding: 10px 14px;
    border-radius: 8px;
}

.calc-result-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.calc-result-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-gold);
}

/* Logged Tasks Table */
.logged-table-container {
    margin-top: 20px;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.logged-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.logged-table th {
    background: rgba(194, 157, 83, 0.15);
    color: var(--secondary);
    padding: 12px 14px;
    font-weight: 700;
}

.logged-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.logged-table tr:hover td {
    background: rgba(0, 0, 0, 0.015);
}

.action-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

.action-icon-btn.delete { color: var(--danger); }
.action-icon-btn.delete:hover { transform: scale(1.2); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: 'PhetsarathOT', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #b08c45);
    border: none;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(194, 157, 83, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(194, 157, 83, 0.3);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.06);
}

.btn-full {
    width: 100%;
}

/* Preview Side Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 24px;
    align-self: start;
    height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
}

.preview-panel > .card {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-form-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.preview-tab {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 8px 4px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.preview-tab:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.04);
}

.preview-tab.active {
    border-color: var(--primary);
    background: rgba(194, 157, 83, 0.15);
    color: var(--text-gold);
}

.pdf-viewer-container {
    position: relative;
    flex: 1;
    min-height: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    background: #e2e8f0;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.pdf-canvas-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 16px 16px 40px 16px;
    position: relative;
    gap: 20px;
}

#pdf-preview-canvas {
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    max-width: 100%;
}

/* PDF Tuning Controls Drawer */
.tuning-container {
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid rgba(194, 157, 83, 0.3);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
}

.tuning-inputs {
    display: flex;
    gap: 12px;
    align-items: center;
}

.tuning-input {
    width: 60px;
    padding: 4px 6px;
    font-size: 0.8rem;
    text-align: center;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.15);
}

.pdf-actions-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    width: 100%;
    flex-wrap: wrap;
}

/* Monthly Tab CSS */
.monthly-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.monthly-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 900px) {
    .monthly-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.stat-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow);
}

.stat-val {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-gold);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.monthly-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

.chart-card {
    height: 370px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chart-container-box {
    position: relative;
    flex: 1;
    width: 100%;
}

.boq-progress-table-container {
    margin-top: 12px;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

/* Fallback Loader modal */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader-overlay.active {
    display: flex;
}

.loader-card {
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    box-shadow: var(--shadow);
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(194, 157, 83, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

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

/* File Upload fallback dropzone style */
.upload-dropzone {
    border: 2px dashed rgba(194, 157, 83, 0.4);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.8);
}

.upload-dropzone:hover {
    border-color: var(--primary);
    background: rgba(194, 157, 83, 0.05);
}

.upload-dropzone p {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.upload-dropzone .dropzone-icon {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 8px;
}


/* Design Mode Draggable Overlay */
#design-drag-overlay {
    border: 1px dashed var(--primary);
    box-sizing: border-box;
}

.design-handle {
    position: absolute;
    background: rgba(194, 157, 83, 0.35);
    border: 1.5px solid var(--primary);
    border-radius: 4px;
    color: var(--text-pen);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 6px;
    cursor: move;
    pointer-events: auto;
    user-select: none;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%); /* Center handle on the coordinate */
}

.design-handle:hover {
    background: rgba(194, 157, 83, 0.55);
    border-color: var(--secondary);
    z-index: 999;
}

.design-handle.active-drag {
    background: rgba(0, 45, 98, 0.4);
    border-color: var(--success);
}

/* --- Word Inspector Preview Styles --- */
.word-a4-page {
    width: 650px;
    height: 919px; /* A4 aspect ratio scaled to width 650px */
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12), 0 1px 8px rgba(0,0,0,0.06);
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    font-family: 'PhetsarathOT', sans-serif;
    color: var(--text-main);
}

.word-preview-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px dashed rgba(194, 157, 83, 0.2);
}

.word-preview-header h3 {
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.4;
    color: #475569;
    text-align: justify;
}

.word-preview-metadata {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    background: rgba(194, 157, 83, 0.03);
    padding: 14px;
    border-radius: 8px;
    border: 1px solid rgba(194, 157, 83, 0.1);
}

.word-meta-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.3;
}

.word-meta-label {
    font-weight: bold;
    color: var(--text-gold);
    font-size: 0.85rem;
    white-space: nowrap;
}

.word-meta-val {
    color: var(--text-main);
    font-size: 0.85rem;
    word-break: break-all;
}

.word-preview-photo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    flex: 1;
    min-height: 480px;
}

.word-photo-cell {
    border: 2px dashed #ED7D31; /* Bright orange theme border */
    border-radius: 8px;
    background: rgba(237, 125, 49, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.word-photo-cell:hover {
    background: rgba(237, 125, 49, 0.06);
    border-color: #d8621d;
    transform: scale(1.01);
}

.word-photo-cell.empty {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
}

.word-photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #ED7D31;
}

.word-photo-icon {
    font-size: 2rem;
}

.word-photo-text {
    font-size: 0.72rem;
    font-weight: 600;
}

/* Page Selector Sidebar Items */
.word-page-item {
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid rgba(194, 157, 83, 0.15);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition);
    margin-bottom: 8px;
}

.word-page-item:hover {
    border-color: var(--primary);
    background: rgba(194, 157, 83, 0.04);
}

.word-page-item.active {
    background: rgba(194, 157, 83, 0.12);
    border-color: var(--primary);
    box-shadow: var(--glow);
}

.word-page-title {
    font-weight: 700;
    color: var(--text-gold);
    font-size: 0.8rem;
}

.word-page-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Thumbnail Manager Styles */
.word-photo-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(194, 157, 83, 0.3);
    background: #0f172a;
    transition: transform 0.2s, box-shadow 0.2s;
}

.word-photo-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.word-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.word-photo-thumb-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    font-family: Arial, sans-serif;
    font-weight: bold;
}

.word-photo-thumb-delete:hover {
    background: #dc2626;
}

/* Word Inspector Download Dropdown Menu */
.download-dropdown {
    position: relative;
    display: inline-block;
}

.download-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #ffffff;
    min-width: 340px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(194, 157, 83, 0.25);
    z-index: 1000;
    overflow: hidden;
    margin-top: 8px;
    padding: 6px 0;
    animation: dropdownSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.download-dropdown-content button {
    color: var(--text-main);
    padding: 12px 18px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: 'PhetsarathOT', sans-serif;
    transition: var(--transition);
    gap: 2px;
}

.download-dropdown-content button:hover {
    background-color: rgba(194, 157, 83, 0.08);
}

.download-dropdown-content .menu-title {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.download-dropdown-content .menu-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 26px;
    line-height: 1.4;
}

.download-dropdown-divider {
    height: 1px;
    background-color: rgba(194, 157, 83, 0.12);
    margin: 4px 0;
}

/* Toggle dropdown visibility active class */
.download-dropdown.active .download-dropdown-content {
    display: block;
}

/* Volume Sheet Dropdown in BOQ tree metadata */
.item-volume-sheet-select {
    padding: 2px 6px;
    font-size: 0.8rem;
    background: #ffffff;
    border: 1px solid rgba(194, 157, 83, 0.4);
    border-radius: 4px;
    font-family: inherit;
    outline: none;
    color: var(--text-main);
    margin-left: 4px;
    cursor: pointer;
}
.item-volume-sheet-select:focus {
    border-color: var(--primary);
}

.volume-sheet-mapping {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Reusable modal styles for main app */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-card {
    background: #ffffff;
    border: 2px solid var(--primary);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border-radius: 12px;
    width: 90%;
    max-width: 550px;
    padding: 24px;
    position: relative;
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(194, 157, 83, 0.15);
    padding-bottom: 8px;
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--primary);
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: #dc2626;
}

/* Manage Routes Row */
.route-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.route-row input {
    padding: 6px 10px;
    font-size: 0.9rem;
}
.route-row .btn-danger {
    padding: 6px 10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}
.route-row .btn-danger:hover {
    background: #dc2626;
}

/* Edit Item Button Styling */
.btn-edit-item {
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.15rem;
    padding: 4px 8px;
    margin-left: auto;
    color: var(--text-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
}
.btn-edit-item:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* --- Simulated Login System --- */
.login-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #0f172a 0%, #020617 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.login-card {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(194, 157, 83, 0.3);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    text-align: center;
    color: #f1f5f9;
}
.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px auto;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--primary);
    box-shadow: 0 0 15px rgba(194, 157, 83, 0.4);
    background: #020617;
}
.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.login-card h2 {
    color: var(--text-gold);
    font-size: 1.5rem;
    margin-bottom: 6px;
    font-weight: 700;
}
.login-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 30px;
}
.login-card .form-group {
    text-align: left;
    margin-bottom: 20px;
}
.login-card label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-gold);
    display: block;
    margin-bottom: 6px;
}
.login-card input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(194, 157, 83, 0.3);
    background: rgba(15, 23, 42, 0.8);
    color: #f1f5f9;
    font-size: 0.95rem;
    transition: all 0.2s ease-in-out;
}
.login-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(194, 157, 83, 0.4);
}
.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #c29d53 0%, #a27f39 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 15px;
    box-shadow: 0 4px 15px rgba(194, 157, 83, 0.3);
    transition: all 0.2s;
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(194, 157, 83, 0.5);
}
.quick-logins {
    margin-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 20px;
    text-align: left;
}
.quick-logins p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-align: center;
}
.quick-login-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.btn-quick-login {
    padding: 10px;
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}
.btn-quick-admin {
    background: rgba(194, 157, 83, 0.15);
    color: var(--text-gold);
    border-color: rgba(194, 157, 83, 0.3);
}
.btn-quick-admin:hover {
    background: rgba(194, 157, 83, 0.3);
    color: #fff;
}
.btn-quick-staff {
    background: rgba(30, 41, 59, 0.5);
    color: #94a3b8;
}
.btn-quick-staff:hover {
    background: rgba(30, 41, 59, 0.8);
    color: #fff;
}

/* --- Role-Based Access Control --- */
body.role-staff .btn-edit-item,
body.role-staff #btn-import-boq {
    display: none !important;
}



