/* Maadekaart — põhistiilid */

:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --secondary: #3b82f6;
    --border: #e5e7eb;
    --bg: #f8fafc;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-w: 280px;
    --panel-w: 360px;
    --header-h: 48px;
    --toolbar-h: 42px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg); }

/* Layout */
.app-container { display: flex; flex-direction: column; height: 100vh; }
.main-content { display: flex; flex: 1; overflow: hidden; position: relative; }
.map-container { flex: 1; z-index: 0; }

/* Header */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    height: var(--header-h); padding: 0 16px;
    background: var(--primary); color: white;
}
.app-header h1 { font-size: 16px; font-weight: 700; margin-right: 16px; }
.header-left { display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-info .role { opacity: 0.7; font-size: 11px; }

/* Company selector */
.company-selector { position: relative; }
.company-btn {
    background: rgba(255,255,255,0.15); border: none; color: white;
    padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.company-btn:hover { background: rgba(255,255,255,0.25); }
.company-arrow { font-size: 10px; margin-left: 4px; }
.company-dropdown {
    position: absolute; top: 100%; left: 0; margin-top: 4px;
    background: white; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 280px; z-index: 1000; overflow: hidden;
}
.company-dropdown input {
    width: 100%; padding: 10px 12px; border: none; border-bottom: 1px solid var(--border);
    font-size: 14px; outline: none;
}
.company-result {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; cursor: pointer; font-size: 13px;
}
.company-result:hover { background: #f0fdf4; }
.company-result.active { background: #dcfce7; font-weight: 600; }
.company-result-code { color: var(--text-muted); font-size: 11px; font-family: monospace; }

/* Toolbar */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--toolbar-h); padding: 0 12px;
    background: white; border-bottom: 1px solid var(--border);
}
.toolbar-center { display: flex; gap: 2px; }
.view-btn {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
    background: white; cursor: pointer; font-size: 13px; font-weight: 500;
    transition: all 0.15s;
}
.view-btn:hover { background: #f0fdf4; border-color: var(--primary); }
.view-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.year-nav { display: flex; align-items: center; gap: 4px; }
.year-btn { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 14px; }
.year-display { font-weight: 700; font-size: 16px; min-width: 50px; text-align: center; }
.toolbar-btn { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 16px; }

/* Sidebar left (stats) */
.sidebar-left {
    width: var(--sidebar-w); background: var(--bg); border-right: 1px solid var(--border);
    overflow-y: auto; padding: 12px; flex-shrink: 0;
}
.stats-panel h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }

/* Sidebar right (field panel) */
.sidebar-right {
    width: var(--panel-w); background: var(--bg); border-left: 1px solid var(--border);
    overflow-y: auto; flex-shrink: 0; position: absolute; right: 0; top: 0; bottom: 0; z-index: 500;
    box-shadow: -2px 0 8px rgba(0,0,0,0.08);
}
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--border); background: white;
    position: sticky; top: 0; z-index: 1;
}
.panel-header h3 { font-size: 14px; margin: 0; }
.panel-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 0 4px; }
.panel-content { padding: 12px 16px; }

/* Legend */
.legend { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.legend-item { display: flex; align-items: center; gap: 6px; padding: 2px 0; font-size: 12px; }

/* Field labels */
.field-name-label {
    color: #fff; font-size: 12px; font-weight: 600;
    font-family: -apple-system, sans-serif; text-align: center; white-space: nowrap;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9), -1px -1px 2px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.8);
    pointer-events: none;
}
.part-label {
    color: #333; font-size: 11px; font-weight: 600; text-align: center;
    background: rgba(255,255,255,0.8); border-radius: 3px; padding: 1px 4px;
    pointer-events: none; border: 1px solid rgba(0,0,0,0.15);
}
.kataster-label {
    color: #FFD700; font-size: 10px; font-weight: 500; text-align: center;
    font-family: monospace; white-space: nowrap;
    text-shadow: 0 0 4px rgba(0,0,0,0.8), 0 0 2px rgba(0,0,0,0.9);
    pointer-events: none; display: none;
}
.naaber-label {
    color: #888; font-size: 10px; font-weight: 500; text-align: center;
    text-shadow: 0 0 3px rgba(255,255,255,0.8); pointer-events: none;
}

/* Buttons */
.btn { padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 13px; background: white; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #f0fdf4, #ecfdf5); }
.login-card { background: white; padding: 40px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 100%; max-width: 380px; }
.login-card h1 { font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-muted); }
.form-group input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,0.1); }
.error-msg { color: #dc2626; font-size: 13px; margin-top: 12px; padding: 8px; background: #fef2f2; border-radius: 4px; }

/* List overlay */
.list-overlay { position: fixed; inset: 0; background: white; z-index: 2000; display: flex; flex-direction: column; }
.list-header { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
.list-search { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.list-content { flex: 1; overflow-y: auto; }
.list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.list-table th { text-align: left; padding: 8px 10px; background: var(--bg); font-weight: 600; font-size: 11px; text-transform: uppercase; color: var(--text-muted); position: sticky; top: 0; white-space: nowrap; }
.list-table td { padding: 6px 10px; border-bottom: 1px solid #f5f5f5; }
.list-table th:nth-child(1), .list-table td:nth-child(1) { width: 20%; }
.list-table th:nth-child(2), .list-table td:nth-child(2) { width: 15%; }
.list-table th:nth-child(3), .list-table td:nth-child(3) { width: 14%; }
.list-table th:nth-child(4), .list-table td:nth-child(4) { width: 8%; text-align: right; }
.list-table th:nth-child(5), .list-table td:nth-child(5) { width: 6%; text-align: center; }
.list-table th:nth-child(6), .list-table td:nth-child(6) { width: 20%; }
.list-table tr:hover { background: #f0fdf4; cursor: pointer; }
.list-table th.sortable { cursor: pointer; }

/* S2 badge */
.s2-date-badge { pointer-events: none; }

/* Mobile */
@media (max-width: 768px) {
    .sidebar-left { display: none; position: absolute; left: 0; top: 0; bottom: 0; z-index: 600; }
    .sidebar-left.open { display: block; }
    .sidebar-right { width: 100%; }
    .toolbar-center { overflow-x: auto; }
    .view-btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
    .header-right .user-info { display: none; }
}

.sidebar-toggle {
    display: none; position: absolute; top: 8px; left: 8px; z-index: 700;
    background: white; border: 1px solid var(--border); border-radius: 4px;
    padding: 4px 8px; font-size: 16px; cursor: pointer;
}
@media (max-width: 768px) {
    .sidebar-toggle { display: block; }
}
