/* ==============================================
   APP - Landmax Web Application
   ============================================== */

/* Full viewport layout */
html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

/* ==============================================
   AUTH STATE SWITCHING
   ============================================== */

body[data-auth-state="logged-out"] .app-shell {
    display: none;
}

body[data-auth-state="logged-out"] .login-overlay {
    display: flex;
}

body[data-auth-state="logged-in"] .app-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
}

body[data-auth-state="logged-in"] .login-overlay {
    display: none;
}

/* ==============================================
   LOGIN OVERLAY
   ============================================== */

.login-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--bg-base);
    background-image:
        radial-gradient(circle at 20% 80%, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, color-mix(in srgb, var(--accent) 5%, transparent) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: var(--pad-xl);
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: var(--pad-lg);
}

.login-header .logo {
    font-size: 1.5rem;
    margin: 0 0 8px 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--pad);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.form-field input {
    padding: 10px 12px;
    background: var(--bg-base);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--text-bright);
    font-size: 0.9375rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.form-field input::placeholder {
    color: var(--text-muted);
}

.login-links {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 0.8125rem;
    margin-top: 8px;
}

.login-links a {
    color: var(--accent);
    text-decoration: none;
}

.login-links a:hover {
    text-decoration: underline;
}

.login-links .divider {
    color: var(--text-muted);
}

.login-footer {
    text-align: center;
    margin-top: var(--pad-lg);
    padding-top: var(--pad);
    border-top: 1px solid var(--line);
}

/* ==============================================
   APP SHELL
   ============================================== */

.app-shell {
    height: 100%;
}

main {
    flex: 1 1 0%;
    min-height: 0;
    display: flex;
}

/* App Header */
.app-header {
    display: flex;
    align-items: center;
    gap: var(--pad);
    padding: var(--pad-sm) var(--pad);
    background: var(--bg-deep);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--pad-sm);
}

.header-center {
    flex: 1;
    justify-content: center;
}

.header-right {
    position: relative;
}

.logo {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-bright);
}

.logo-suffix {
    color: var(--accent);
    font-weight: 400;
}

/* Search Bar */
.search-bar {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-bar input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg-hover);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text-bright);
    font-size: 0.875rem;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

/* Footer */
.app-footer {
    display: flex;
    justify-content: space-between;
    padding: var(--pad-sm) var(--pad);
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--success);
}

/* ==============================================
   BUTTONS
   ============================================== */

button {
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: var(--bg-hover);
    color: var(--text-bright);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
}

button:hover {
    background: var(--line-strong);
    border-color: var(--accent);
}

button:active {
    background: var(--bg-base);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    padding: 12px 16px;
    font-size: 0.9375rem;
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 85%, #fff);
    border-color: color-mix(in srgb, var(--accent) 85%, #fff);
}

.btn-secondary {
    width: 100%;
    margin-top: 8px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-sm {
    width: 28px;
    height: 28px;
    font-size: 1rem;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-avatar {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.avatar-initials {
    font-size: 0.875rem;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 100;
    overflow: hidden;
}

.user-dropdown.open {
    display: block;
}

.dropdown-header {
    padding: 12px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    word-break: break-all;
}

.user-dropdown hr {
    margin: 0;
    border: none;
    border-top: 1px solid var(--line);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 0;
    background: none;
    text-align: left;
    font-size: 0.875rem;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.text-danger {
    color: var(--danger);
}

/* ==============================================
   SIDEBAR
   ============================================== */

#sidebar {
    --panel-basis: 200px;
    min-width: 56px;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-raised);
    overflow-y: auto;
}

.nav-section {
    padding: var(--pad-sm);
}

.nav-section-bottom {
    margin-top: auto;
    border-top: 1px solid var(--line);
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
}

.nav-list a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-list a:hover {
    background: var(--bg-hover);
    color: var(--text-bright);
}

.nav-list a.active {
    background: color-mix(in srgb, var(--accent) 15%, var(--bg-hover));
    color: var(--accent);
}

/* ==============================================
   MAP PANEL
   ============================================== */

.map-container {
    position: relative;
    height: 100%;
}

.map-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--bg-base);
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 40px 40px;
}

.map-placeholder-content {
    text-align: center;
    padding: var(--pad-lg);
}

.map-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: var(--pad);
}

.map-placeholder-content h2 {
    margin: 0 0 8px 0;
    color: var(--text-bright);
}

.map-controls {
    position: absolute;
    top: var(--pad);
    right: var(--pad);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-control-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 1.125rem;
    background: var(--bg-raised);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ==============================================
   TOOLS PANEL
   ============================================== */

#tools-panel {
    --panel-basis: 260px;
    min-width: 200px;
}

.tools-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-raised);
    overflow-y: auto;
}

.tools-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--pad);
    border-bottom: 1px solid var(--line);
}

.tools-header h2 {
    margin: 0;
    font-size: 0.9375rem;
}

.tool-section {
    padding: var(--pad);
    border-bottom: 1px solid var(--line);
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section h3 {
    margin: 0 0 12px 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.875rem;
    cursor: pointer;
}

.toggle-item input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ==============================================
   UTILITIES
   ============================================== */

.muted {
    color: var(--text-muted);
}