/* =============================================
   Kolorystyka: Dark Graphite + Emerald Accent
   bg-dark: #1a1b23  bg-card: #22242e  bg-input: #2a2d38
   border: #353849    accent: #10b981   accent-hover: #059669
   text: #e8eaed      text-muted: #8b8fa3   text-dim: #5c6178
   ============================================= */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1b23;
    color: #e8eaed;
}

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

/* --- Panel boczny --- */
#sidebar {
    width: 25%;
    min-width: 300px;
    background: #22242e;
    padding: 24px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-right: 1px solid #353849;
    z-index: 1000;
}

#sidebar h1 {
    font-size: 1.3rem;
    color: #10b981;
    margin-bottom: 4px;
    font-weight: 700;
}

.step {
    background: #1a1b23;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #353849;
}

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

/* --- Wyszukiwarka --- */
.search-box {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.search-box input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #353849;
    border-radius: 8px;
    background: #2a2d38;
    color: #e8eaed;
    font-size: 0.9rem;
}

.search-box button {
    flex-shrink: 0;
    white-space: nowrap;
}

.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.15);
}

#search-results {
    margin-top: 8px;
    font-size: 0.85rem;
}

#search-results .result-item {
    padding: 8px 10px;
    background: #2a2d38;
    border-radius: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

#search-results .result-item:hover {
    background: #353849;
}

/* --- Przyciski --- */
button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

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

#search-btn:hover {
    background: #059669;
}

/* --- Przyciski rysowania (sidebar) --- */
#draw-btn {
    width: 100%;
    background: #2a2d38;
    color: #e8eaed;
    border: 1px solid #10b981;
}

#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; }
}

.btn-secondary {
    width: 100%;
    background: transparent;
    color: #8b8fa3;
    border: 1px solid #353849;
    margin-top: 8px;
}

.btn-secondary:hover {
    background: #353849;
    color: #e8eaed;
}

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

.manual-input-row input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #353849;
    border-radius: 8px;
    background: #2a2d38;
    color: #e8eaed;
    font-size: 0.9rem;
}

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

.manual-unit {
    color: #8b8fa3;
    font-size: 0.9rem;
    font-weight: 600;
}

#manual-apply-btn {
    width: 100%;
    background: #2a2d38;
    color: #e8eaed;
    border: 1px solid #10b981;
}

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

/* --- Hint --- */
.hint {
    font-size: 0.8rem;
    color: #5c6178;
    margin-bottom: 10px;
    line-height: 1.4;
}

/* --- Wynik powierzchni --- */
.result-box {
    background: #2a2d38;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    border: 1px solid #10b981;
}

.result-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #10b981;
}

.result-unit {
    font-size: 1rem;
    color: #8b8fa3;
    margin-left: 4px;
}

.result-hectares {
    text-align: center;
    font-size: 0.85rem;
    color: #5c6178;
    margin-top: 6px;
}

/* --- Warstwy --- */
.layer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    margin-bottom: 6px;
    cursor: pointer;
}

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

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

/* --- Overlay generowania wyceny --- */
#generating-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 27, 35, 0.8);
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.generating-box {
    background: #22242e;
    border: 2px solid #10b981;
    border-radius: 20px;
    padding: 40px 50px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.generating-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid #353849;
    border-top: 4px solid #10b981;
    border-right: 4px solid #10b981;
    border-radius: 50%;
    margin: 0 auto 20px auto;
    animation: spin 0.8s linear infinite;
}

.generating-text {
    color: #e8eaed;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.generating-sub {
    color: #5c6178;
    font-size: 0.85rem;
}

/* --- Loading mapy --- */
#map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #8b8fa3;
    font-size: 0.95rem;
    background: rgba(34, 36, 46, 0.95);
    padding: 24px 36px;
    border-radius: 12px;
    border: 1px solid #353849;
    pointer-events: none;
    transition: opacity 0.5s;
}

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

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #353849;
    border-top: 3px solid #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* 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;
}

/* --- Kalkulator wyceny --- */
.estimator-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.photo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.photo-option {
    background: #2a2d38;
    border: 2px solid #353849;
    border-radius: 10px;
    padding: 6px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}

.photo-option:hover {
    border-color: #8b8fa3;
}

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

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

.photo-option .photo-img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    margin-bottom: 4px;
}

.photo-option .photo-img-wrap::after {
    content: '🔍';
    position: absolute;
    bottom: 8px;
    right: 6px;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    padding: 2px 5px;
    pointer-events: none;
}

.photo-option .photo-label {
    font-size: 0.75rem;
    color: #8b8fa3;
    line-height: 1.3;
}

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

/* --- Powiększenie zdjęcia --- */
.photo-zoom-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 27, 35, 0.92);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    backdrop-filter: blur(6px);
}

.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: 1.1rem;
    margin-top: 14px;
    text-align: center;
    max-width: 500px;
}

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

.zoom-close {
    position: absolute;
    top: -14px;
    right: -14px;
    background: #ef4444;
    border: none;
    color: white;
    font-size: 1.4rem;
    width: 36px;
    height: 36px;
    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(42, 45, 56, 0.9);
    border: 1px solid #10b981;
    color: #10b981;
    font-size: 3rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0 16px;
    transition: background 0.2s;
    flex-shrink: 0;
    line-height: 1;
}

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

.zoom-select-btn {
    margin-top: 16px;
    padding: 12px 48px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.zoom-select-btn:hover {
    background: #059669;
}

/* --- Podsumowanie wyceny --- */
.estimate-summary {
    background: #2a2d38;
    border-radius: 10px;
    padding: 14px;
    border: 1px solid #353849;
}

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

.estimate-row.total {
    border-top: 1px solid #10b981;
    padding-top: 8px;
    margin-top: 8px;
    margin-bottom: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #10b981;
}

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

/* --- Formularz kontaktowy --- */
.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: #8b8fa3;
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #353849;
    border-radius: 8px;
    background: #2a2d38;
    color: #e8eaed;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}

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

.date-range-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.date-label {
    font-size: 0.75rem;
    color: #5c6178;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-field input[type="date"] {
    width: 100%;
    padding: 10px 10px;
    border: 1px solid #353849;
    border-radius: 8px;
    background: #2a2d38;
    color: #e8eaed;
    font-size: 0.9rem;
    font-family: inherit;
}

.date-field input[type="date"]:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

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

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

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

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

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

.btn-send {
    width: 100%;
    padding: 12px;
    background: #10b981;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    margin-top: 12px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.btn-send:hover:not(:disabled) {
    background: #059669;
}

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

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

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

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

/* Przycisk usuń */
.btn-danger {
    width: 100%;
    background: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    margin-top: 8px;
}

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

/* --- Overlay startowy --- */
#start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 27, 35, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

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

#start-box {
    background: #22242e;
    border: 1px solid #353849;
    border-radius: 16px;
    padding: 32px 36px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#start-box h2 {
    color: #10b981;
    font-size: 1.4rem;
    margin-bottom: 6px;
}

#start-box p {
    color: #8b8fa3;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

#start-box .search-box {
    display: flex;
    gap: 8px;
}

#start-box .search-box input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid #353849;
    border-radius: 8px;
    background: #1a1b23;
    color: #e8eaed;
    font-size: 1rem;
}

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

#start-box .search-box button {
    background: #10b981;
    color: white;
    padding: 12px 20px;
    font-size: 1rem;
}

#start-box .search-box button:hover {
    background: #059669;
}

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

#start-search-results .result-item {
    padding: 10px 12px;
    background: #1a1b23;
    border-radius: 8px;
    margin-bottom: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #e8eaed;
    transition: background 0.2s;
}

#start-search-results .result-item:hover {
    background: #353849;
}

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

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

    #sidebar {
        width: 100%;
        min-width: unset;
        height: auto;
        max-height: 45vh;
        border-right: none;
        border-bottom: 1px solid #353849;
    }

    #map {
        height: 55vh;
    }
}
