/* =============================================
   Kalkulator wyceny — Modern Dark + Emerald
   Plus Jakarta Sans, glass morphism, compact
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0f1017;
    color: #e8eaed;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Sidebar — kompaktowy --- */
#sidebar {
    width: 320px;
    min-width: 280px;
    background: rgba(18, 19, 28, 0.95);
    backdrop-filter: blur(12px);
    padding: 16px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-right: 1px solid rgba(255,255,255,0.06);
    z-index: 1000;
}

#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.3);
    border-radius: 2px;
}

.sidebar-header h1 {
    font-size: 1.1rem;
    color: #10b981;
    font-weight: 700;
    margin: 2px 0;
}

.sidebar-hint {
    font-size: 0.72rem;
    color: #5c6178;
    margin-bottom: 4px;
}

.back-link {
    font-size: 0.75rem;
    color: #5c6178;
    text-decoration: none;
    transition: color 0.2s;
}

.back-link:hover {
    color: #10b981;
}

/* --- Steps — compact cards --- */
.step {
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.06);
}

.step.compact {
    padding: 10px 12px;
}

.step h2 {
    font-size: 0.72rem;
    color: #8b8fa3;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

/* --- Info banner --- */
.estimate-info-banner {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.7rem;
    color: #8b8fa3;
    line-height: 1.4;
}

.estimate-info-banner .info-icon { flex-shrink: 0; font-size: 0.8rem; }
.estimate-info-banner strong { color: #10b981; }

/* --- Search --- */
.search-box {
    display: flex;
    gap: 6px;
}

.search-box input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: #e8eaed;
    font-size: 0.82rem;
    font-family: inherit;
}

.search-box input::placeholder { color: #5c6178; }

.search-box input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.12);
}

#search-results { margin-top: 6px; font-size: 0.8rem; }

#search-results .result-item {
    padding: 7px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    margin-bottom: 3px;
    cursor: pointer;
    transition: background 0.2s;
}

#search-results .result-item:hover { background: rgba(255,255,255,0.08); }

/* --- Buttons --- */
button {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
}

#search-btn, #start-search-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

#search-btn:hover, #start-search-btn:hover {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

/* --- Draw row — inline --- */
.draw-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.draw-or {
    font-size: 0.75rem;
    color: #5c6178;
}

#draw-btn {
    background: rgba(255,255,255,0.04);
    color: #e8eaed;
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 7px 12px;
    font-size: 0.8rem;
}

#draw-btn:hover { background: #10b981; color: white; }

#draw-btn.drawing {
    background: #10b981;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

.manual-input-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.manual-input-row input {
    width: 80px;
    padding: 7px 8px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    color: #e8eaed;
    font-size: 0.82rem;
    font-family: inherit;
}

.manual-input-row input:focus {
    outline: none;
    border-color: #10b981;
}

#manual-apply-btn {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 7px 10px;
    font-size: 0.8rem;
}

#manual-apply-btn:hover { background: #10b981; color: white; }

.manual-unit { display: none; }

.hint {
    font-size: 0.72rem;
    color: #5c6178;
    margin-bottom: 4px;
    line-height: 1.3;
}

.draw-hint {
    color: #10b981;
    background: rgba(16, 185, 129, 0.06);
    padding: 6px 8px;
    border-radius: 6px;
    margin-top: 6px;
    margin-bottom: 0;
}

.btn-danger {
    width: 100%;
    background: transparent;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    margin-top: 6px;
    font-size: 0.78rem;
    padding: 6px;
}

.btn-danger:hover { background: #ef4444; color: white; }

/* --- Result inline --- */
.result-inline {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.result-label {
    font-size: 0.75rem;
    color: #8b8fa3;
}

.result-value-inline {
    font-size: 1.4rem;
    font-weight: 800;
    color: #10b981;
}

.result-unit-inline {
    font-size: 0.85rem;
    color: #8b8fa3;
}

.result-hectares-inline {
    font-size: 0.75rem;
    color: #5c6178;
}

/* Legacy compatibility */
.result-box { display: none; }
.result-value { display: none; }
.result-unit { display: none; }
.result-hectares { display: none; }

/* --- Photo grid — compact 4-col / 3-col --- */
.compact-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.compact-grid.three-col {
    grid-template-columns: repeat(3, 1fr);
}

.photo-option {
    background: rgba(255,255,255,0.03);
    border: 2px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 3px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    position: relative;
}

.photo-option:hover { border-color: rgba(255,255,255,0.15); }

.photo-option.selected {
    border-color: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.photo-option .photo-img-wrap {
    position: relative;
    cursor: zoom-in;
}

.photo-option .photo-img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
    display: block;
}

.photo-option .photo-img-wrap::after {
    content: '🔍';
    position: absolute;
    bottom: 3px;
    right: 3px;
    font-size: 0.65rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    padding: 1px 3px;
    pointer-events: none;
}

.photo-option .photo-label {
    font-size: 0.62rem;
    color: #8b8fa3;
    line-height: 1.2;
    margin-top: 2px;
}

.photo-option.selected .photo-label {
    color: #10b981;
    font-weight: 600;
}

.estimator-label {
    font-size: 0.72rem;
    color: #8b8fa3;
    margin-bottom: 6px;
}

/* --- Estimate compact --- */
.estimate-compact {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.06);
}

.estimate-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 3px;
    color: #8b8fa3;
}

.estimate-row.total {
    border-top: 1px solid rgba(16, 185, 129, 0.3);
    padding-top: 6px;
    margin-top: 4px;
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #10b981;
}

.estimate-disclaimer {
    font-size: 0.65rem;
    color: #5c6178;
    margin-top: 4px;
    text-align: center;
    font-style: italic;
}

/* Legacy estimate summary compat */
.estimate-summary { display: none; }

/* --- Form compact --- */
.form-compact {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-compact input,
.form-compact textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: #e8eaed;
    font-size: 0.82rem;
    font-family: inherit;
    resize: vertical;
}

.form-compact input:focus,
.form-compact textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.12);
}

.form-compact input::placeholder,
.form-compact textarea::placeholder {
    color: #5c6178;
}

/* Legacy form-group compat */
.form-group { margin-bottom: 6px; }
.form-group label { display: block; font-size: 0.72rem; color: #8b8fa3; margin-bottom: 3px; }
.form-group input, .form-group textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
    background: rgba(255,255,255,0.04); color: #e8eaed;
    font-size: 0.82rem; font-family: inherit;
}

.date-range-row { display: flex; gap: 8px; }
.date-field { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.date-label { font-size: 0.65rem; color: #5c6178; text-transform: uppercase; letter-spacing: 0.5px; }

.date-field input[type="date"] {
    width: 100%; padding: 7px 8px;
    border: 1px solid rgba(255,255,255,0.08); border-radius: 6px;
    background: rgba(255,255,255,0.04); color: #e8eaed;
    font-size: 0.8rem; font-family: inherit;
}

.date-field input[type="date"]:focus {
    outline: none; border-color: #10b981;
}

.date-field input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7); cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.68rem;
    color: #5c6178;
    cursor: pointer;
    line-height: 1.3;
}

.checkbox-label input[type="checkbox"] {
    accent-color: #10b981;
    width: 14px; height: 14px;
    margin-top: 1px; flex-shrink: 0;
}

.checkbox-label a { color: #10b981; }

.rodo-group { margin-top: 4px; }

.btn-send {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-send:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

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

#send-status {
    margin-top: 6px;
    font-size: 0.78rem;
    text-align: center;
}

#send-status.success { color: #10b981; }
#send-status.error { color: #ef4444; }

/* --- Layers — collapsed --- */
.layers-details {
    cursor: pointer;
}

.layers-details summary {
    font-size: 0.72rem;
    color: #5c6178;
    list-style: none;
}

.layers-details summary::before {
    content: '▸ ';
}

.layers-details[open] summary::before {
    content: '▾ ';
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    margin: 4px 0;
    cursor: pointer;
    color: #8b8fa3;
}

.layer-toggle input[type="checkbox"] {
    accent-color: #10b981;
    width: 14px; height: 14px;
}

/* --- Map --- */
#map {
    flex: 1;
    height: 100vh;
    position: relative;
}

/* --- Loading --- */
#map-loading {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #8b8fa3;
    font-size: 0.85rem;
    background: rgba(15, 16, 23, 0.9);
    backdrop-filter: blur(8px);
    padding: 20px 32px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    pointer-events: none;
    transition: opacity 0.5s;
}

#map-loading.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
    width: 28px; height: 28px;
    border: 3px solid rgba(255,255,255,0.06);
    border-top: 3px solid #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Generating overlay --- */
#generating-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 16, 23, 0.8);
    z-index: 2500;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}

.generating-box {
    background: rgba(18, 19, 28, 0.95);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 16px;
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.generating-spinner {
    width: 48px; height: 48px;
    border: 3px solid rgba(255,255,255,0.06);
    border-top: 3px solid #10b981;
    border-right: 3px solid #10b981;
    border-radius: 50%;
    margin: 0 auto 16px auto;
    animation: spin 0.8s linear infinite;
}

.generating-text { color: #e8eaed; font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.generating-sub { color: #5c6178; font-size: 0.8rem; }

/* Leaflet draw toolbar */
.leaflet-draw-toolbar a { font-size: 0; }
.leaflet-editing-icon {
    width: 4px !important; height: 4px !important;
    margin-left: -2px !important; margin-top: -2px !important;
}

/* --- Photo zoom overlay --- */
.photo-zoom-overlay {
    display: none; position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 16, 23, 0.92);
    z-index: 3000;
    align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
}

.photo-zoom-overlay.visible { display: flex; flex-direction: row; }

.zoom-center {
    display: flex; flex-direction: column; align-items: center; max-width: 80vw;
}

.photo-zoom-overlay img {
    max-width: 75vw; max-height: 60vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border: 2px solid #10b981;
}

.photo-zoom-overlay .zoom-label {
    color: #e8eaed; font-size: 1rem; margin-top: 12px;
    text-align: center; max-width: 500px;
}

.photo-zoom-inner { position: relative; display: inline-block; }

.zoom-close {
    position: absolute; top: -12px; right: -12px;
    background: #ef4444; border: none; color: white;
    font-size: 1.2rem; width: 32px; height: 32px;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; line-height: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1; transition: background 0.2s;
}

.zoom-close:hover { background: #dc2626; }

.zoom-nav {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    font-size: 2.5rem;
    width: 48px; height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; margin: 0 14px;
    transition: all 0.2s;
    flex-shrink: 0; line-height: 1;
}

.zoom-nav:hover { background: #10b981; color: white; }

.zoom-select-btn {
    margin-top: 14px;
    padding: 10px 40px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none; border-radius: 8px;
    font-size: 1rem; font-weight: 700;
    cursor: pointer; transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.zoom-select-btn:hover {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

/* --- Start overlay --- */
#start-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 16, 23, 0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

#start-overlay.hidden { display: none; }

#start-box {
    background: rgba(18, 19, 28, 0.95);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 28px 32px;
    max-width: 440px; width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
}

#start-box h2 { color: #10b981; font-size: 1.2rem; margin-bottom: 4px; }
#start-box p { color: #8b8fa3; font-size: 0.85rem; margin-bottom: 14px; }

#start-box .search-box input {
    flex: 1; padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    color: #e8eaed; font-size: 0.9rem;
}

#start-box .search-box input:focus {
    outline: none; border-color: #10b981;
}

#start-search-results {
    margin-top: 8px; max-height: 180px; overflow-y: auto;
}

#start-search-results .result-item {
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    margin-bottom: 3px;
    cursor: pointer;
    font-size: 0.82rem;
    color: #e8eaed;
    transition: background 0.2s;
}

#start-search-results .result-item:hover { background: rgba(255,255,255,0.08); }

/* Sidebar hidden on start */
#sidebar.hidden { display: none; }

/* --- Progress bar --- */
.progress-bar {
    display: flex; align-items: center; gap: 0; padding: 4px 0;
}

.progress-step {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    border: 2px solid rgba(255,255,255,0.08);
    color: #5c6178;
    font-size: 0.65rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.3s;
}

.progress-step.active { background: #10b981; border-color: #10b981; color: white; }
.progress-step.done { background: #059669; border-color: #059669; color: white; }

.progress-line {
    flex: 1; height: 2px;
    background: rgba(255,255,255,0.06);
    transition: background 0.3s;
}

.progress-line.done { background: #10b981; }

/* --- Responsive --- */
@media (max-width: 768px) {
    #app { flex-direction: column; }

    #sidebar {
        width: 100%; min-width: unset;
        height: auto; max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }

    #map { height: 50vh; }

    .compact-grid { grid-template-columns: repeat(4, 1fr); }
    .compact-grid.three-col { grid-template-columns: repeat(3, 1fr); }

    .photo-option .photo-img { height: 50px; }
}
