/* Fonts: local Poppins (fallbacks maintained). When extracting to standalone repo,
   copy TTFs under web_poc/fonts/ and update URLs accordingly. */
@font-face {
    font-family: 'Poppins';
    src: url('assets/fonts/Poppins-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Poppins';
    src: url('assets/fonts/Poppins-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Poppins';
    src: url('assets/fonts/Poppins-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Poppins';
    src: url('assets/fonts/Poppins-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Colors */
    --bg: #f9fafb; /* Light Gray */
    --info-bg: #ffffff; /* White */
    --text: #1f2937; /* Dark Gray */
    --text-weak: #6b7280; /* Medium Gray */
    --text-weak2: #9ca3af; /* Lighter Gray */
    --primary: #d97706; /* Amber */
    --primary-hover: #b45309; /* Darker Amber */
    --success: #16a34a; /* Green */
    --error: #dc2626; /* Red */
    --border: #e5e7eb; /* Light border color */

    /* Radii */
    --r-lg: 12px;
    --r-md: 6px;
    --r-sm: 4px;

    /* Spacing */
    --m-outer: 20px;
    --m-inner: 10px;

    /* Typography */
    --fs-title: 20px;
    --fs-body: 14px;
    --fs-small: 12px;
    --ls-title: -0.5px;
    --ls-body: 0.2px;
    --ls-button: 0.3px;

    /* Z-Index Hierarchy */
    --z-map-controls: 1000;
    --z-topbar: 1100;
    --z-modal: 2000;
    --z-toast: 3000;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: var(--fs-body);
    overflow: hidden; /* prevent viewport scrollbars */
}

/* Screen reader only content - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

#topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(120%) blur(10px);
    z-index: var(--z-topbar);
}

.brand {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: var(--ls-body);
}

.auth {
    display: flex;
    gap: 8px;
    align-items: center;
}

.auth-row { 
    display: flex; 
    gap: 8px; 
    align-items: center; 
}

.user-email { 
    color: var(--text-weak); 
}

/* Topbar sign-in button: outline, tiny fillet, no blue */
button.pill {
    height: 34px;
    padding: 0 12px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: var(--ls-button);
}
button.pill:hover {
    background: rgba(0,0,0,0.05);
    border-color: var(--text-weak);
}
button.pill:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Modal backdrop with blur */
#modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(10px) saturate(120%);
    z-index: 10;
}

/* Centered auth modal */
#auth-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    background: var(--info-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: 0 10px 28px rgba(0,0,0,0.15);
    padding: 20px;
    z-index: 11;
}
#auth-modal h2 {
    margin: 0 0 12px 0;
    font-size: var(--fs-title);
    letter-spacing: var(--ls-title);
}
#auth-modal .label { margin-top: 8px; }
#auth-modal input[type="email"],
#auth-modal input[type="password"] {
    width: 100%;
    height: 36px;
    padding: 6px 8px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    margin-top: 4px;
}
#auth-modal button.primary {
    margin-top: 14px;
    width: 100%;
    height: 38px;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
}
#auth-modal button.primary:hover {
    background: var(--primary-hover);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    color: var(--text-weak2);
    border: none;
    font-size: 22px;
    cursor: pointer;
}
.modal-close:hover { color: var(--text); }

/* Inputs inside the top bar: subtle translucent fields with white text */
#topbar input[type="email"],
#topbar input[type="password"] {
    height: 32px;
    padding: 6px 8px;
    background: rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
}
#topbar input::placeholder { color: var(--text-weak2); }

#controls {
    position: absolute;
    top: 15px;
    left: 15px;
    background-color: var(--info-bg);
    padding: 12px;
    border-radius: var(--r-md);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    border: 1px solid var(--border);
    z-index: 1;
    max-width: 400px;
}

/* --- Hillshade Blend Mode --- */
.multiply-blend-active .osm-layer {
    mix-blend-mode: multiply;
}

/* OpenLayers zoom control to top-right */
.ol-zoom {
    top: 116px; /* Position below layers button */
    left: auto;
    right: 15px;
    bottom: auto;
    /* z-index is relative to map container, but let's keep it in our system */
    z-index: var(--z-map-controls);
}

/* Zoom buttons: big, plain white symbols with a subtle shadow */
.ol-zoom button {
    width: 40px;
    height: 40px;
    line-height: 40px;
    font-size: 24px;
    color: var(--text);
    background: var(--info-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.ol-zoom button:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    border-color: #d1d5db;
}
.ol-zoom button:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

h1 {
    margin: 0 0 10px 0;
    font-size: var(--fs-title);
    letter-spacing: var(--ls-title);
    font-weight: 700;
}

p {
    margin: 0 0 10px 0;
    font-size: var(--fs-body);
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--text);
}

button {
    width: 100%;
    padding: 10px;
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: var(--fs-body);
    letter-spacing: var(--ls-button);
    font-weight: 600;
}

button:hover {
    background-color: var(--primary-hover);
}

/* Consistent Focus Styles */
button:focus-visible, input:focus-visible {
    outline: 2px solid var(--primary) !important;
    outline-offset: 2px;
    box-shadow: none !important;
}

.label {
    display: block;
    color: var(--text-weak);
    font-weight: 400;
    margin-bottom: 4px;
}

.status {
    margin-top: 6px;
    color: var(--text-weak2);
    font-size: var(--fs-small);
}

.section {
    margin-top: 12px;
}

.row {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    gap: 6px;
    margin: 6px 0;
}
.info-label { color: var(--text-weak); }
.info-value { color: var(--text); font-weight: 500; }

/* --- Info Panel (used for AOI) --- */
.info-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: var(--info-bg);
    padding: 12px;
    border-radius: var(--r-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    z-index: 1000;
    max-width: 250px;
}

.info-panel .panel-header {
    font-weight: 600;
    margin-bottom: 8px;
}

.aoi-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.aoi-control label {
    font-weight: 500;
    font-size: 0.9em;
    color: var(--text-weak);
}

.aoi-control input[type="range"] {
    width: 100%;
}

.aoi-control #aoi-size-value {
    text-align: right;
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text);
}

.info-panel button {
    width: 100%;
    padding: 6px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
}

.info-panel button:hover {
    background: #b91c1c; /* Darker Red */
}

/* Toast */
#toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast);
    background: var(--info-bg);
    color: var(--text);
    padding: 10px 14px;
    border-radius: var(--r-md);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 160ms ease, transform 160ms ease;
    pointer-events: none;
}
#toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* --- Login Page Styles --- */
.login-page-background {
    background-color: #fdfaf6; /* Soft off-white from reference */
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    text-align: center;
}

.login-card {
    background: #ffffff;
    padding: 40px 50px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
    width: 400px;
    max-width: 90%;
    display: inline-block;
    text-align: left;
}

.login-logo {
    display: block;
    margin: 0 auto 20px auto;
    width: 60px; /* Adjust size as needed */
    height: auto;
}

.login-card h2 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--text);
}

.login-subtitle {
    text-align: center;
    color: var(--text-weak);
    margin-bottom: 30px;
}

.login-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-weak);
}

.login-form input {
    height: 44px;
    margin-bottom: 15px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}
.login-form input:focus {
    border-color: var(--primary);
    outline: 2px solid transparent;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}


.login-form button {
    height: 44px;
    margin-top: 10px;
    background-color: #d97706; /* Amber from reference */
    font-weight: 700;
}
.login-form button:hover {
    background-color: #b45309;
}

.login-links {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    font-size: var(--fs-small);
}

.login-links a {
    color: #d97706;
    text-decoration: none;
    font-weight: 500;
}
.login-links a:hover {
    text-decoration: underline;
}

.login-links span {
    color: var(--text-weak);
}

.login-form button.wechat {
    background-color: #09b83e; /* WeChat Green */
}
.login-form button.wechat:hover {
    background-color: #089c34;
}

.auth-provider-switch {
    text-align: center;
    margin-top: 20px;
    font-size: var(--fs-small);
    color: var(--text-weak);
}

.auth-provider-switch a {
    color: #d97706;
    text-decoration: none;
    font-weight: 500;
}

.auth-provider-switch a:hover {
    text-decoration: underline;
}

/* --- Password Toggle --- */
.password-wrapper {
    position: relative;
}

.login-form .password-wrapper input {
    padding-right: 40px; /* Space for the icon */
}

.password-toggle-icon {
    position: absolute;
    top: 12px; /* Finetuned for vertical alignment */
    right: 12px;
    cursor: pointer;
    color: var(--text-weak2);
    user-select: none; /* Prevent text selection */
    transition: color 150ms ease;
    font-size: 20px !important; /* Force size */
    line-height: 1; /* Prevent extra vertical space */
}

.password-toggle-icon:hover {
    color: var(--text);
}

/* --- Generic Modal (for Create Project, etc.) --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(4px) saturate(120%);
    z-index: var(--z-modal);
}

.modal {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    background: var(--info-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: 0 10px 28px rgba(0,0,0,0.15);
    padding: 24px;
    z-index: calc(var(--z-modal) + 1);
}

.modal h2 {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: 700;
}

.modal label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-weak);
}

.modal input[type="text"] {
    height: 44px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}
.modal input[type="text"]:focus {
    border-color: var(--primary);
    outline: 2px solid transparent;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.modal p {
    margin: 0 0 20px 0;
    color: var(--text-weak);
}

.modal-actions button {
    width: auto;
    padding: 8px 16px;
    height: auto;
}

button.secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
button.secondary:hover {
    background: #f3f4f6; /* Slightly darker bg */
}

button.danger {
    background: var(--error);
}
button.danger:hover {
    background: #b91c1c; /* Darker Red */
}

/* --- Slide Panel (for Projects) --- */
.slide-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.20);
    backdrop-filter: blur(4px) saturate(120%);
    z-index: 20;
    opacity: 0;
    transition: opacity 250ms ease;
    pointer-events: none;
}
.slide-panel-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 90%;
    background: var(--info-bg);
    border-left: 1px solid var(--border);
    box-shadow: -5px 0 25px rgba(0,0,0,0.1);
    z-index: 21;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 250ms ease;
}
.slide-panel.visible {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.panel-close {
    background: transparent;
    border: none;
    color: var(--text-weak2);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: background-color 150ms ease, color 150ms ease;
}
.panel-close:hover {
    color: var(--text);
    background: var(--bg);
}

.panel-close .material-symbols-outlined {
    font-size: 24px;
}

.panel-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
}

.panel-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

#projects-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.project-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.project-item.active {
    background: #fdfaf6; /* Soft off-white */
    border-color: var(--primary);
    font-weight: 600;
}

.project-item-details {
    flex-grow: 1;
}

.project-item-name {
    font-weight: 500;
    color: var(--text);
}

.project-item-date {
    font-size: 12px;
    color: var(--text-weak);
    margin-top: 2px;
}

.no-projects-message {
    text-align: center;
    color: var(--text-weak);
    padding: 20px;
}

.delete-project-btn {
    background: transparent;
    border: none;
    color: var(--text-weak2);
    padding: 4px;
    margin-left: 8px;
    cursor: pointer;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
}

.delete-project-btn:hover {
    color: var(--error);
    background: transparent;
}

/* --- User Menu Dropdown --- */
.user-menu-button {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.user-menu-button:hover, .user-menu-button:focus {
    background-color: rgba(0,0,0,0.05);
    outline: none;
}

.user-menu-button .material-symbols-outlined {
    font-size: 20px;
    color: var(--text-weak);
}

.user-menu-dropdown {
    position: absolute;
    top: 52px;
    right: 16px;
    width: 200px;
    background: var(--info-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    /* z-index is relative to topbar, but let's keep it in our system */
    z-index: calc(var(--z-topbar) + 1);
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}

.user-menu-item {
    display: block;
    padding: 8px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: var(--fs-body);
}

.user-menu-item:hover {
    background-color: var(--bg);
}

.user-menu-divider {
    height: 1px;
    background-color: var(--border);
    margin: 8px 0;
}

/* --- Account Page --- */
.account-page-background {
    background-color: var(--bg);
    overflow-y: auto;
}

.content-wrapper {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.back-link:hover {
    text-decoration: underline;
}

.card {
    background: var(--info-bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.card-section {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}
.card-section:last-child {
    border-bottom: none;
}

.card-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.card-section p {
    color: var(--text-weak);
    margin-bottom: 16px;
}

button.disabled {
    background-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}
button.disabled:hover {
    background-color: #e5e7eb;
}

/* --- Dev Controls --- */
#dev-controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
}

#dev-controls button {
    width: auto;
    padding: 2px 8px;
    background: rgba(0,0,0,0.05);
    color: var(--text-weak);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
}

#dev-controls button:hover {
    background: rgba(0,0,0,0.1);
    color: var(--text);
}