/* ============================================
   MAPeczkA — Style System
   Light, Warm, Human Design
   Modern rounded corners, soft shadows, solid colors
   ============================================ */

/* ── CSS Variables ── */
:root {
    --bg-dark: #F7F7F9; /* Warm off-white background */
    --bg-card: #FFFFFF;
    --bg-card-hover: #F0F2F5;
    --bg-glass: rgba(255, 255, 255, 0.9);

    --text-primary: #222222; /* Soft black */
    --text-secondary: #717171; /* Medium gray */
    --text-muted: #B0B0B0;

    --accent-primary: #FF5A5F; /* Warm coral (Airbnb style) */
    --accent-primary-glow: rgba(255, 90, 95, 0.2);
    --accent-secondary: #00A699; /* Pleasant teal */
    --accent-secondary-glow: rgba(0, 166, 153, 0.2);

    --cat-atrakcja: #9C72FF;
    --cat-jedzenie: #FFB347;
    --cat-rozrywka: #FF6B6B;
    --cat-inne: #00CEC9;

    --success: #00b894;
    --danger: #ff6b6b;
    --warning: #feca57;

    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 50px;
    --radius-circle: 50%;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

    --border-color: rgba(0, 0, 0, 0.08);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    --z-map: 1;
    --z-controls: 100;
    --z-sheet: 200;
    --z-modal: 500;
    --z-toast: 600;
    --z-loading: 700;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Reset & Base ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
}

/* ── Map ── */
#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-map);
}

.leaflet-control-attribution {
    font-size: 9px !important;
    background: rgba(255,255,255,0.7) !important;
    padding: 2px 6px !important;
    border-radius: 4px 0 0 0 !important;
    color: var(--text-secondary) !important;
}

.leaflet-control-zoom {
    display: none !important;
}

/* ── Header / Logo ── */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-controls);
    padding: 12px 16px;
    pointer-events: none;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    pointer-events: auto;
}

.logo-icon {
    font-size: 20px;
}

.logo-text {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo-accent {
    color: var(--accent-primary);
}

/* ── Map Controls ── */
#map-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-controls);
    padding: 0 16px;
    padding-bottom: calc(150px + var(--safe-bottom));
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

#map-controls > * {
    pointer-events: auto;
}

/* Base button styles */
.glass-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-md);
    font-family: inherit;
    font-weight: 600;
}

.glass-btn:active {
    transform: scale(0.95);
    background: var(--bg-card-hover);
}

/* Pill button - Find Nearest */
.pill-btn {
    padding: 14px 28px;
    border-radius: var(--radius-pill);
    font-size: 15px;
    position: absolute;
    bottom: calc(145px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: var(--shadow-md);
}

.pill-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.pill-btn svg {
    color: var(--accent-primary);
}

/* Circle button - Locate */
.circle-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-circle);
    color: var(--text-secondary);
}

/* Right Controls Stack */
#right-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    position: absolute;
    right: 16px;
    bottom: calc(160px + var(--safe-bottom));
}

/* FAB Button */
.fab-btn {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-circle);
    border: none;
    background: var(--accent-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px var(--accent-primary-glow);
    transition: all var(--transition-spring);
    font-family: inherit;
}

.fab-btn:active {
    transform: scale(0.9);
    background: #FF474D;
}

/* ── Bottom Sheet ── */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sheet);
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(calc(100% - 130px));
    transition: transform var(--transition-spring);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.bottom-sheet.expanded {
    transform: translateY(0);
}

.sheet-handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 8px;
    cursor: grab;
}

.handle-bar {
    width: 48px;
    height: 5px;
    border-radius: 4px;
    background: #DFDFDF;
    transition: background var(--transition-fast);
}

.sheet-handle:active .handle-bar {
    background: #C4C4C4;
}

.sheet-header {
    padding: 0 20px 16px;
}

.sheet-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

/* Category Filter Chips */
.category-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
}

.category-filters::-webkit-scrollbar {
    display: none;
}

.cat-chip {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.cat-chip.active {
    background: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

/* Sheet Content / Places List */
.sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
    padding-bottom: calc(20px + var(--safe-bottom));
}

.empty-state {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 15px;
}

/* Place Card in list */
.place-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    animation: cardSlideIn 0.3s ease-out;
}

.place-card:active {
    transform: scale(0.98);
    background: var(--bg-card-hover);
}

.place-card.visited {
    opacity: 0.65;
}

@keyframes cardSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.place-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.place-card-icon[data-cat="atrakcja"] { background: rgba(156, 114, 255, 0.15); }
.place-card-icon[data-cat="jedzenie"] { background: rgba(255, 179, 71, 0.15); }
.place-card-icon[data-cat="rozrywka"] { background: rgba(255, 107, 107, 0.15); }
.place-card-icon[data-cat="inne"] { background: rgba(0, 206, 201, 0.15); }

.place-card-info {
    flex: 1;
    min-width: 0;
}

.place-card-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.place-card-address {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

.place-card-distance {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-secondary);
    flex-shrink: 0;
    text-align: right;
}

/* ── Modals ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
}

.modal-overlay.showing {
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: var(--shadow-lg);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 12px;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-circle);
    border: none;
    background: var(--bg-dark);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.modal-close:active {
    background: #E8E8E8;
}

/* ── Form Styles ── */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 24px 24px;
    padding-bottom: calc(24px + var(--safe-bottom));
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 1px solid transparent;
    font-size: 15px;
    transition: all var(--transition-fast);
    outline: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    -webkit-appearance: none;
    appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-primary-glow);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Address Grid */
.address-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.addr-city, .addr-street {
    grid-column: 1 / -1;
}

/* Category Select */
.category-select {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

.cat-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.cat-option:active {
    transform: scale(0.97);
}

.cat-option.active {
    background: var(--bg-card);
    border-color: var(--text-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.cat-emoji {
    font-size: 20px;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-primary);
    flex: 1;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    flex: 2;
}

.btn-primary:active {
    background: #E0484D;
}

.btn-tag {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-tag:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-dark);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent-secondary);
    font-weight: 700;
    font-size: 13px;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
}

/* ── Tags Container ── */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.tag-chip {
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tag-chip.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.tag-chip.active-all {
    background: var(--text-primary);
    color: white;
    border-color: var(--text-primary);
}

/* ── Map Picker Banner ── */
#map-picker-banner {
    position: fixed;
    top: calc(80px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-controls);
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

#map-picker-banner.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-20px);
}

.picker-text {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

/* ── Detail Modal ── */
.detail-modal {
    max-height: 85vh;
}

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 16px;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.detail-row-content {
    flex: 1;
    min-width: 0;
}

.detail-row-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-row-value {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

.detail-row-value a {
    color: var(--accent-secondary);
    text-decoration: none;
    font-weight: 600;
}

.detail-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    background: var(--bg-dark);
}

/* Detail Actions */
.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 24px;
    padding-bottom: calc(16px + var(--safe-bottom));
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.detail-actions-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

.btn-visited {
    flex: 2;
    background: var(--bg-dark);
    color: var(--text-primary);
}

.btn-visited.is-visited {
    background: rgba(0, 184, 148, 0.1);
    color: var(--success);
}

.btn-danger {
    background: rgba(255, 107, 107, 0.1);
    color: var(--danger);
    flex: 1;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    padding: 14px 28px;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    white-space: nowrap;
    animation: toastIn 0.3s ease-out;
}

.toast.hidden { display: none; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Loading Overlay ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-loading);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.loading-overlay.hidden { display: none; }

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Custom Map Markers ── */
.custom-marker {
    background: none;
    border: none;
}

.marker-pin {
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: markerBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: white;
    border: 3px solid;
}

.marker-pin[data-cat="atrakcja"] { border-color: var(--cat-atrakcja); }
.marker-pin[data-cat="jedzenie"] { border-color: var(--cat-jedzenie); }
.marker-pin[data-cat="rozrywka"] { border-color: var(--cat-rozrywka); }
.marker-pin[data-cat="inne"] { border-color: var(--cat-inne); }

.marker-pin .marker-emoji {
    transform: rotate(45deg);
    font-size: 20px;
}

.marker-pin.visited {
    opacity: 0.7;
    filter: grayscale(0.8);
}

@keyframes markerBounce {
    0% { transform: rotate(-45deg) scale(0) translateY(-20px); opacity: 0; }
    60% { transform: rotate(-45deg) scale(1.1) translateY(0); opacity: 1; }
    100% { transform: rotate(-45deg) scale(1) translateY(0); }
}

/* Distance label above marker */
.marker-distance {
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}

/* User location marker */
.user-marker {
    width: 20px;
    height: 20px;
    background: var(--accent-secondary);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(0, 166, 153, 0.2), var(--shadow-sm);
    animation: userPulse 2s ease-in-out infinite;
}

@keyframes userPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(0, 166, 153, 0.2), var(--shadow-sm); }
    50% { box-shadow: 0 0 0 12px rgba(0, 166, 153, 0.05), var(--shadow-sm); }
}

/* Route line styling */
.route-line {
    stroke: var(--accent-primary);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 12 8;
    animation: routeDash 1s linear infinite;
}

@keyframes routeDash {
    to { stroke-dashoffset: -20; }
}
