:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --card-bg: rgba(255, 255, 255, 0.8);
    --border-color: rgba(226, 232, 240, 0.8);
    --danger-color: #ef4444;
    --success-color: #10b981;
}

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

html {
    overscroll-behavior-y: none;
}

body {
    overscroll-behavior-y: none;
    font-family: 'Noto Sans Thai', 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,0.05) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.05) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.05) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

/* Glassmorphism Classes */
.glass-header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.glass-modal {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Header */
.header-container {
    max-width: 96%;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-area i {
    font-size: 2rem;
    color: var(--primary-color);
}

.logo-area h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.logo-area p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Main Container */
.main-container {
    max-width: 96%;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Upload Section */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    transition: opacity 0.5s ease;
}

.drop-zone {
    width: 100%;
    max-width: 600px;
    border: 2px dashed var(--primary-color);
    border-radius: 1rem;
    background: var(--card-bg);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
}

.drop-zone:hover, .drop-zone.dragover {
    background: rgba(37, 99, 235, 0.05);
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.upload-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.drop-zone h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.drop-zone p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.btn-small {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.4rem 0.8rem;
    border-radius: 0.3rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Dashboard */
.data-section {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stat-card i {
    font-size: 2rem;
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    padding: 1rem;
    border-radius: 0.5rem;
}

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

.stat-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--card-bg);
}

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

/* Table */
.table-container {
    background: var(--card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    overflow: auto;
    min-height: 400px;
    max-height: calc(100vh - 130px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

thead {
    background-color: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

th, td {
    padding: 0.25rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: top;
}

.th-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.th-content:hover {
    color: var(--primary-color);
}

.th-content i {
    font-size: 0.75rem;
    opacity: 0.3;
}

.th-content i.active {
    opacity: 1;
    color: var(--primary-color);
}

.column-filter {
    width: 100%;
    min-width: 60px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-family: inherit;
    background: var(--card-bg);
    transition: border-color 0.2s;
}

.column-filter:focus {
    outline: none;
    border-color: var(--primary-color);
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: rgba(248, 250, 252, 0.8);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    gap: 0.5rem;
}

.page-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: bold;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 2rem;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-container {
    width: 100%;
    max-width: 1000px;
    max-height: 90vh;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    transform: scale(1);
    transition: transform 0.3s ease;
}

.modal-overlay.hidden .modal-container {
    transform: scale(0.95);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.close-modal {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-modal:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .modal-body {
        grid-template-columns: 1fr;
    }
}

.detail-group {
    margin-bottom: 1.5rem;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.detail-value {
    font-size: 1rem;
    font-weight: 500;
}

.modal-images {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-image-container {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #fff;
}

.modal-image-container img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.modal-image-title {
    padding: 0.75rem;
    background: rgba(241, 245, 249, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.ocr-box {
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.2);
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.btn-map {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--success-color);
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
    margin-top: 0.5rem;
}

.btn-map:hover {
    background-color: #059669;
}

.hidden {
    display: none !important;
}

/* Table Inputs */
.table-input {
    width: 100px;
    padding: 0.2rem 0.3rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-family: inherit;
    font-size: 0.85rem;
    background: #fff;
    transition: border-color 0.2s ease;
}

.table-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.table-textarea {
    width: 150px;
    min-height: 40px;
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-family: inherit;
    font-size: 0.85rem;
    background: #fff;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.table-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.star-rating {
    display: flex;
    gap: 0.25rem;
    font-size: 1.1rem;
    min-width: 100px;
}

/* Multi-select filter */
.multi-select {
    position: relative;
    width: 100%;
    min-width: 80px;
}

.multi-select-btn {
    width: 100%;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
}

.multi-select-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
}

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 200px;
    max-height: 250px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    margin-top: 2px;
}

.multi-select-search {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.multi-select-search input {
    width: 100%;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.multi-select-options {
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.multi-select-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 400;
    text-transform: none;
    color: var(--text-main);
}

.multi-select-options label:hover {
    color: var(--primary-color);
}

/* Range filter */
.range-filter {
    display: flex;
    width: 100%;
    min-width: 90px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    overflow: hidden;
    transition: border-color 0.2s;
}

.range-filter:focus-within {
    border-color: var(--primary-color);
}

.range-operator {
    background: rgba(241, 245, 249, 0.8);
    border: none;
    border-right: 1px solid var(--border-color);
    padding: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    outline: none;
    color: var(--text-main);
}

.range-input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-family: inherit;
    outline: none;
    background: transparent;
}

/* Livinginsider Popup Styles */
.li-hover {
    cursor: help;
    border-bottom: 1px dashed var(--primary-color);
    display: inline-block;
}

.li-popup {
    position: absolute;
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    z-index: 1000;
    max-height: 300px;
    width: 600px;
    overflow-y: auto;
    display: none;
}

.li-popup-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.li-popup-table th {
    background: var(--bg-color);
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 2px solid var(--border-color);
}

.li-popup-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.li-popup-table tr:hover {
    background-color: var(--row-hover);
}

.li-popup-table a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.li-popup-table a:hover {
    text-decoration: underline;
}
