@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=Sarabun:wght@300;400;600;700&display=swap');

:root {
    --bg-dark: #0a0f1d;
    --card-bg: rgba(255, 255, 255, 0.03);
    --accent-teal: #00f2ff;
    --accent-purple: #bc00ff;
    --text-dim: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    font-family: 'Outfit', 'Sarabun', sans-serif;
    color: white;
    min-height: 100vh;
}

/* Main App Container */
.container {
    display: flex;
    min-height: 100vh;
}

/* Auth Layout (จัดกึ่งกลางสวยๆ สำหรับหน้า Login/Register) */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #1e293b, var(--bg-dark));
    padding: 20px;
}

.auth-card {
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.auth-card:hover {
    border-color: rgba(0, 242, 255, 0.3);
    box-shadow: 0 30px 60px -12px rgba(0, 242, 255, 0.1);
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    padding: 30px;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

/* Scrollbar thinner for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.logo {
    font-size: var(--fs-logo);
    /* Standardized */
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-teal);
    margin-bottom: 50px;
}

.nav-item {
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-dim);
}

.nav-item:hover,
.nav-item.active {
    background: rgba(0, 242, 255, 0.1);
    color: white;
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 40px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-purple));
    border: none;
    padding: 12px 25px;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: scale(1.05);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 40px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 25px;
    backdrop-filter: blur(10px);
}

.card-value {
    font-size: var(--fs-stat);
    /* Standardized */
    font-weight: 700;
}

.trend-up {
    color: #10b981;
    font-size: 13px;
}

/* --- Modal Styles (ซ่อมแซมให้ Scroll ได้) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: #111a2e;
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 30px;
    width: 100%;
    max-width: 600px;

    /* Safeguard for interactivity */
    pointer-events: auto;
    z-index: 1001;
    /* Ensure card is above overlay if new context */
    max-height: 90vh;
    /* จำกัดความสูง */
    overflow-y: auto;
    /* ให้ Scroll ได้ */
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

/* ปรับแต่ง Scrollbar ของ Modal ให้สวยงาม */
.modal-card::-webkit-scrollbar {
    width: 6px;
}

.modal-card::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dim);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    outline: none;
    transition: all 0.2s;
}

.form-group select option {
    background: #111a2e;
    color: white;
}

.form-group input:focus {
    border-color: var(--accent-teal);
    background: rgba(255, 255, 255, 0.08);
}

/* --- Smart Address Suggestions --- */
.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a2236;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 2000;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    margin-top: 5px;
}

.suggestion-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
    transition: all 0.2s;
}

.suggestion-item:hover {
    background: var(--accent-teal);
    color: #000;
}

.suggestion-item strong {
    color: var(--accent-teal);
}

.suggestion-item:hover strong {
    color: #000;
}

/* --- Image Preview System (ทำให้เป็น Grid เล็กๆ) --- */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 15px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 15px;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    transition: transform 0.2s, opacity 0.2s;
    cursor: grab;
}

.preview-item:active {
    cursor: grabbing;
}

.preview-item.dragging {
    opacity: 0.5;
    transform: scale(0.9);
    border: 2px solid var(--accent-teal);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    /* ป้องกันการลากรูปภาพดั้งเดิมของ Browser */
}

.delete-img-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: #ff4d4d;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* --- Toast Notification --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    padding: 16px 24px;
    background: rgba(17, 26, 46, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    animation: slideIn 0.3s ease forwards;
}

.toast.success {
    border-left: 4px solid var(--accent-teal);
}

.toast.error {
    border-left: 4px solid #ff4d4d;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* --- Property Cards (Updated for Badge) --- */
.property-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.prop-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    transition: 0.3s;
}

.prop-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-teal);
}

.prop-img-container {
    position: relative;
    height: 180px;
    width: 100%;
}

.prop-img-placeholder {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.img-count-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.prop-info {
    padding: 20px;
}

.prop-tag {
    background: var(--accent-teal);
    color: #0c121e;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: bold;
}

.prop-price-tag {
    font-size: 20px;
    font-weight: bold;
    margin: 10px 0;
}

.prop-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- Modern Property Card Actions --- */
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
}

.btn-card {
    border-radius: 14px;
    padding: 10px 15px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    outline: none;
}

.btn-card-edit {
    background: rgba(0, 242, 255, 0.05);
    border: 1px solid rgba(0, 242, 255, 0.2);
    color: var(--accent-teal);
    flex: 1.5;
}

.btn-card-edit:hover {
    background: var(--accent-teal);
    color: #0a0f1d;
    border-color: var(--accent-teal);
    box-shadow: 0 0 25px rgba(0, 242, 255, 0.3);
    transform: translateY(-2px);
}

.btn-card-pdf {
    background: rgba(255, 255, 255, 0.95);
    color: #0a0f1d;
    flex: 1;
    border: 1px solid white;
}

.btn-card-pdf:hover {
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(255, 255, 255, 0.15);
}

.btn-card-delete {
    background: rgba(255, 77, 77, 0.05);
    border: 1px solid rgba(255, 77, 77, 0.2);
    color: #ff4d4d;
    min-width: 44px;
    padding: 10px 0;
}

.btn-card-delete:hover {
    background: #ff4d4d;
    color: white;
    border-color: #ff4d4d;
    box-shadow: 0 0 25px rgba(255, 77, 77, 0.3);
    transform: translateY(-2px);
}

.btn-card-compare {
    width: 100%;
    margin-top: 12px;
    background: linear-gradient(135deg, #bc00ff, #7000ff);
    color: white;
    border: none;
    font-size: 12px;
    font-weight: 800;
    padding: 14px;
    box-shadow: 0 10px 20px rgba(188, 0, 255, 0.15);
}

.btn-card-compare:hover {
    filter: brightness(1.1);
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(188, 0, 255, 0.3);
}

.btn-card:active {
    transform: scale(0.95);
}





@keyframes gateSlideIn {
    from {
        transform: translateX(120%) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

.gate-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(0, 242, 255, 0.5));
}

.gate-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    font-weight: 800;
    color: var(--accent-teal);
}

.gate-card p {
    color: #cbd5e1;
    line-height: 1.5;
    font-size: 0.9rem;
    margin-bottom: 20px;
}