/* ─── Reset & Variables ─── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0066ff;
    --primary-hover: #0052cc;
    --danger: #ef4444;
    --success: #10b981;
    --bg: #ffffff;
    --surface: #f9fafb;
    --border: #e5e7eb;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --toolbar-h: 56px;
}

/* Prevent visible seams between tiles when upscaling past native zoom */
.leaflet-tile {
    outline: 1px solid transparent;
}

/* Hide default Leaflet controls (we use our own) */
.leaflet-control-zoom,
.leaflet-control-attribution,
.leaflet-control-layers {
    display: none !important;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ═══════════════════════════════════════
   LANDING OVERLAY — Floor Plan style
   ═══════════════════════════════════════ */
.landing-overlay {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: var(--bg);
    overflow-y: auto;
    padding: 0.5rem 0;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

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

.landing-content {
    padding: 0.75rem 1rem;
    max-width: 440px;
    width: 100%;
}

.landing-card {
    text-align: center;
}

/* ─── Search Section ─── */
.landing-search-section {
    margin-bottom: 0;
}

.landing-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 102, 255, 0.06);
    margin-bottom: 0.6rem;
}

.landing-icon-wrap i {
    font-size: 1.2rem;
    color: var(--primary);
}

.landing-card-title {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    letter-spacing: -0.01em;
}

.landing-card-subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.85rem;
}

.landing-badges {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.15rem;
}

.landing-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 0.15rem 0.45rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 5px;
}

.landing-badge i {
    color: var(--primary);
    font-size: 0.55rem;
}

/* ─── Divider ─── */
.landing-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.landing-divider::before,
.landing-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ─── Upload Section (Floor Plan style) ─── */
.landing-upload-section {
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border: 1.5px solid #e0e7ff;
    border-radius: 16px;
    padding: 1.25rem 1.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.landing-upload-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(0, 102, 255, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

.landing-upload-section:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eff4ff 0%, #e8efff 100%);
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.08), 0 8px 24px rgba(0, 102, 255, 0.06);
    transform: translateY(-1px);
}

.landing-upload-section.dragover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #e8efff 0%, #dbe4ff 100%);
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.12), 0 12px 32px rgba(0, 102, 255, 0.1);
    transform: translateY(-2px);
}

.upload-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 102, 255, 0.06);
    margin-bottom: 0.5rem;
}

.upload-icon-wrap i {
    font-size: 1rem;
    color: var(--primary);
}

.upload-title {
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
    letter-spacing: -0.01em;
}

.upload-subtitle {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-bottom: 0.6rem;
}

.browse-link {
    color: var(--primary);
    font-weight: 600;
    border-bottom: 1.5px solid rgba(0, 102, 255, 0.3);
    padding-bottom: 1px;
    transition: all 0.15s ease;
}

.browse-link:hover {
    border-bottom-color: var(--primary);
}

.upload-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.upload-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #6b7280;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
}

.upload-privacy {
    font-size: 0.625rem;
    color: var(--text-secondary);
    opacity: 0.65;
    letter-spacing: 0.02em;
}

.upload-privacy i {
    font-size: 0.575rem;
    margin-right: 0.2rem;
}

/* ─── Search Box (shared) ─── */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}

.search-icon {
    padding: 0 0.85rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    padding: 0.75rem 0;
    color: var(--text);
    background: transparent;
    min-width: 0;
}

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

/* Landing search */
.landing-search-box {
    margin-bottom: 0.4rem;
    border-radius: 10px;
    border: 1.5px solid var(--border);
}

.landing-search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.landing-search-box .search-icon {
    padding: 0 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.landing-search-box .search-input {
    padding: 0.6rem 0;
    font-size: 0.875rem;
}

.search-go-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 3px;
    border-radius: 8px;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.search-go-btn:hover {
    background: var(--primary-hover);
}

.search-go-btn:active {
    transform: scale(0.95);
}

/* Toolbar search — match tool-btn height */
.toolbar-search-box {
    border-radius: var(--radius);
    height: 34px;
    width: 100%;
}

.toolbar-search-box .search-input {
    padding: 0.35rem 0;
    font-size: 0.8rem;
}

.toolbar-search-box .search-icon {
    padding: 0 0.6rem;
    font-size: 0.75rem;
}

/* ─── Suggestions Dropdown ─── */
.suggestions-dropdown {
    display: none;
    z-index: 2000;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.suggestions-dropdown.show {
    display: block;
}

.landing-suggestions {
    position: relative;
    margin-bottom: 0.5rem;
}

.toolbar-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
}

.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f3f4f6;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f0f5ff;
}

.suggestion-item i {
    color: #64748b;
    margin-top: 2px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.suggestion-text {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.35;
}

/* ═══════════════════════════════
   TOOLBAR
   ═══════════════════════════════ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
}

/* Desktop: rows behave as inline sections */
.toolbar-row {
    display: contents;
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Desktop order: tools (left) → search (center) → right controls */
.toolbar-tools {
    order: 1;
    flex-shrink: 0;
}

.toolbar-search-section {
    order: 2;
    flex: 1;
    min-width: 140px;
    position: relative;
    z-index: 10000;
}

.toolbar-right {
    order: 3;
    flex-shrink: 0;
}

/* Tool buttons */
.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tool-btn:hover {
    background: var(--surface);
    color: var(--text);
    border-color: #d1d5db;
}

.tool-btn.active {
    background: #eff6ff;
    color: var(--primary);
    border-color: #bfdbfe;
}

.tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tool-btn:disabled:hover {
    background: var(--bg);
    color: var(--text-secondary);
    border-color: var(--border);
}

.tool-btn i {
    font-size: 0.85rem;
}

/* Zoom toggle */
.zoom-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-right: 0.35rem;
}

.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.75rem;
}

.zoom-btn + .zoom-btn {
    border-left: 1px solid var(--border);
}

.zoom-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.zoom-btn:active {
    background: #eff6ff;
    color: var(--primary);
}

/* Layer toggle (satellite / road) */
.layer-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.layer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
}

.layer-btn + .layer-btn {
    border-left: 1px solid var(--border);
}

.layer-btn.active {
    background: #eff6ff;
    color: var(--primary);
}

.layer-btn:not(.active):hover {
    background: var(--surface);
}

/* Unit toggle (in measurements panel) */
.unit-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-right: 0.25rem;
}

.unit-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.unit-btn+.unit-btn {
    border-left: 1px solid var(--border);
}

.unit-btn.active {
    background: var(--primary);
    color: white;
}

.unit-btn:not(.active):hover {
    background: var(--surface);
}

/* ═══════════════════════════════
   MAP + MEASUREMENTS LAYOUT
   ═══════════════════════════════ */
.map-layout {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
}

.map-area {
    flex: 1;
    position: relative;
    min-width: 0;
}

.map {
    width: 100%;
    height: 100%;
}

/* Crosshair cursor when drawing */
.map-drawing .leaflet-grab {
    cursor: crosshair !important;
}

.map-drawing .leaflet-interactive {
    cursor: crosshair !important;
}

/* Zoom-area cursor */
.map-zoom-area .leaflet-grab {
    cursor: zoom-in !important;
}

/* ─── Zoom Area Rectangle ─── */
.zoom-rect {
    position: absolute;
    border: 2px dashed var(--primary);
    background: rgba(0, 102, 255, 0.1);
    border-radius: 3px;
    z-index: 900;
    pointer-events: none;
}

/* ═══════════════════════════════
   MEASUREMENTS PANEL — Desktop: right sidebar
   ═══════════════════════════════ */
.measurements-panel {
    width: 280px;
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

/* Panel handle — mobile only (collapsed bar) */
.panel-handle {
    display: none;
}

/* Panel body — always visible on desktop */
.panel-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.measurements-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 0.5rem;
}

.measurements-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.measurements-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.btn-icon-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.72rem;
}

.btn-icon-action:hover {
    background: var(--surface);
    color: var(--text-secondary);
}

.btn-icon-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.72rem;
}

.btn-icon-clear:hover {
    background: #fef2f2;
    color: var(--danger);
}

.measurements-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-content: flex-start;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 1.5rem 0.5rem;
    line-height: 1.5;
    width: 100%;
}

/* Measurement item — card style */
.measurement-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.1s;
    border: 1px solid var(--border);
    background: var(--bg);
    min-width: 0;
    flex: 0 0 100%;
    max-width: 100%;
}

.measurement-item:hover {
    background: var(--surface);
    border-color: #d1d5db;
}

.measurement-item.selected {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.measurement-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.measurement-info {
    flex: 1;
    min-width: 0;
}

.measurement-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.measurement-area {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.measurement-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.measurement-item:hover .measurement-actions {
    opacity: 1;
}

.measurement-edit,
.measurement-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.6rem;
    transition: all 0.15s;
    flex-shrink: 0;
}

.measurement-edit:hover {
    background: #eff6ff;
    color: var(--primary);
}

.measurement-delete:hover {
    background: #fef2f2;
    color: var(--danger);
}

/* Totals section */
.totals-section {
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    padding: 0;
    display: flex;
}

.total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.85rem;
    flex: 1 1 0;
    min-width: 0;
}

.total-row + .total-row {
    border-left: 1px solid var(--border);
}

.total-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    margin-right: 0.5rem;
}

.total-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
}

/* Minimize button — hidden on desktop, visible on mobile */
.btn-icon-action.btn-minimize {
    display: none !important;
}

/* ─── Panel Credit ─── */
.panel-credit {
    padding: 0.5rem 0.85rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    text-align: center;
    flex-shrink: 0;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.panel-credit a {
    color: var(--text-secondary);
    text-decoration: none;
}

.panel-credit a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ─── Panel Handle (mobile collapsed bar) ─── */
.panel-handle-pill {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
    margin: 0 auto 0.4rem;
}

.panel-handle-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.panel-handle-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.panel-handle-count {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--primary);
}

/* ─── Drawing Hint ─── */
.drawing-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 800;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

/* ─── Area Label Tooltip on Map ─── */
.area-tooltip {
    background: rgba(0, 0, 0, 0.72) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 4px !important;
    padding: 3px 8px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(2px);
    white-space: nowrap !important;
}

.area-tooltip::before {
    display: none !important;
}

/* Vertex markers */
.first-vertex-icon {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22c55e;
    border: 2.5px solid #fff;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.vertex-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #0066ff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ─── Modal ─── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 90%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.modal-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.modal-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    outline: none;
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 1.25rem;
}

.modal-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}

.modal-buttons {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
}

.btn {
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #f3f4f6;
}

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

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: white;
    padding: 0.65rem 1.25rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 3000;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast i {
    color: var(--success);
}

/* ─── Drop Overlay ─── */
.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(0, 102, 255, 0.12);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-content {
    background: var(--bg);
    border: 3px dashed var(--primary);
    border-radius: 20px;
    padding: 3rem 4rem;
    text-align: center;
    color: var(--primary);
}

.drop-content i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.drop-content p {
    font-size: 1rem;
    font-weight: 500;
}

/* ═══════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════ */
@media (max-width: 768px) {
    .btn-text {
        display: none;
    }

    .tool-btn {
        padding: 0.45rem 0.55rem;
    }

    /* ─── Two-row toolbar on mobile ─── */
    .toolbar {
        flex-wrap: wrap;
        padding: 0;
        gap: 0;
    }

    .toolbar-row {
        display: flex;
        width: 100%;
        align-items: center;
        gap: 0.4rem;
        padding: 0.35rem 0.6rem;
    }

    .toolbar-row-search {
        border-bottom: 1px solid var(--border);
    }

    .toolbar-search-section {
        flex: 1;
        min-width: 0;
    }

    .toolbar-tools {
        flex: 1;
        justify-content: flex-start;
    }

    /* ─── Measurements panel: bottom sheet on mobile ─── */
    .map-layout {
        flex-direction: column;
    }

    .measurements-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 38vh;
        min-height: 0;
        transition: max-height 0.25s ease;
        overflow: hidden;
    }

    /* Show the handle on mobile only when collapsed */
    .panel-handle {
        display: none;
        padding: 0.45rem 1rem 0.3rem;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .measurements-panel.collapsed .panel-handle {
        display: block;
    }

    /* Hide panel body when collapsed */
    .measurements-panel.collapsed {
        max-height: 48px;
    }

    .measurements-panel.collapsed .panel-body {
        display: none;
    }

    /* Expanded: full body visible */
    .panel-body {
        flex: 1;
        min-height: 0;
    }

    .measurements-header {
        padding: 0.4rem 0.6rem;
    }

    .measurements-header h3 {
        font-size: 0.78rem;
    }

    /* Push minimize to far right with auto margin */
    .btn-icon-action.btn-minimize {
        display: flex !important;
        margin-left: auto;
    }

    .measurements-list {
        max-height: none;
        flex: 1;
        overflow-y: auto;
        padding: 0.3rem;
        gap: 0.25rem;
    }

    .measurement-item {
        padding: 0.35rem 0.45rem;
        gap: 0.4rem;
        flex: 0 1 calc(50% - 0.15rem);
        max-width: calc(50% - 0.15rem);
    }

    .measurement-name {
        font-size: 0.7rem;
    }

    .measurement-area {
        font-size: 0.65rem;
    }

    .measurement-color {
        width: 8px;
        height: 8px;
        border-radius: 2px;
    }

    .measurement-actions {
        opacity: 1;
    }

    .measurement-edit,
    .measurement-delete {
        width: 18px;
        height: 18px;
        font-size: 0.55rem;
    }

    .total-row {
        padding: 0.3rem 0.6rem;
    }

    .total-label {
        font-size: 0.7rem;
    }

    .total-value {
        font-size: 0.72rem;
    }

    .panel-credit {
        padding: 0.3rem 0.6rem;
        font-size: 0.55rem;
    }

    /* ─── Landing page mobile ─── */
    .landing-content {
        padding: 1rem;
    }

    .landing-icon-wrap {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .landing-icon-wrap i {
        font-size: 1rem;
    }

    .landing-card-title {
        font-size: 0.875rem;
    }

    .landing-card-subtitle {
        font-size: 0.75rem;
    }

    .landing-upload-section {
        padding: 1rem 1rem 0.85rem;
    }

    .upload-icon-wrap {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .upload-icon-wrap i {
        font-size: 0.875rem;
    }

    .upload-title {
        font-size: 0.8rem;
    }

    .upload-subtitle {
        font-size: 0.72rem;
    }
}

@media (max-width: 480px) {
    .toolbar-row {
        padding: 0.3rem 0.5rem;
        gap: 0.25rem;
    }

    .measurements-panel {
        max-height: 32vh;
    }

    .measurements-panel.collapsed {
        max-height: 44px;
    }

    .panel-handle {
        padding: 0.35rem 0.85rem 0.25rem;
    }

    .panel-handle-label {
        font-size: 0.75rem;
    }

    .panel-handle-count {
        font-size: 0.68rem;
    }

    .landing-content {
        padding: 1rem;
    }

    .landing-divider {
        margin: 1rem 0;
    }
}
