/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: Arial, sans-serif;
    background: #f0f2f5;
    color: #333;
}

/* ============================================================
   PASSWORD OVERLAY
   ============================================================ */
.password-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.password-container {
    background: #fff;
    padding: 36px 32px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    text-align: center;
}

.password-container h2 {
    margin-bottom: 10px;
    font-size: 22px;
    color: #222;
}

.password-container p {
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
}

.password-input-group {
    display: flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ccc;
    margin-bottom: 10px;
}

.password-input-group input {
    flex: 1;
    padding: 10px 14px;
    border: none;
    font-size: 15px;
    outline: none;
}

.password-input-group button {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.password-input-group button:hover {
    background: #1b5e20;
}

.password-error {
    color: #c62828;
    font-size: 13px;
    min-height: 18px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-6px); }
    30%, 60%, 90% { transform: translateX(6px); }
}
.shake { animation: shake 0.45s ease both; }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal.active { display: flex; }

.modal-content {
    background: #fff;
    padding: 28px 24px;
    border-radius: 10px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.modal-content h2 { margin-bottom: 12px; font-size: 18px; }
.modal-content p  { margin-bottom: 14px; color: #555; font-size: 14px; }

.modal-content input[type="text"],
.modal-content textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    margin-bottom: 14px;
    outline: none;
}

.modal-content textarea { resize: vertical; }

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-content button {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.modal-content button:hover { background: #1b5e20; }
#issue-cancel { background: #c62828 !important; }
#issue-cancel:hover { background: #7f0000 !important; }

/* Share modal */
.share-option { margin-bottom: 18px; }
.share-option h3 { font-size: 14px; margin-bottom: 8px; color: #444; }

.share-link-container {
    display: flex;
    gap: 8px;
}

.share-link-container input {
    flex: 1;
    margin-bottom: 0;
    font-size: 12px;
    background: #f5f5f5;
}

.copy-btn { background: #1565c0 !important; }
.copy-btn:hover { background: #0d47a1 !important; }

/* ============================================================
   APP WRAPPER — full-height column layout
   ============================================================ */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
    background: #1b5e20;
    color: #fff;
    padding: 0 16px;
    flex-shrink: 0;
}

header h1 {
    font-size: 20px;
    padding: 10px 0 6px;
    letter-spacing: 0.5px;
}

/* ============================================================
   SESSION BAR (inside header)
   ============================================================ */
.session-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.session-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

#session-id {
    font-family: monospace;
    background: rgba(255,255,255,0.2);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
}

.session-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.session-controls button {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.session-controls button:hover { background: rgba(255,255,255,0.35); }
.session-controls button:disabled { opacity: 0.45; cursor: not-allowed; }

#active-users { display: flex; gap: 5px; flex-wrap: wrap; }

.user-badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 12px;
    color: #fff;
}

.user-badge.current-user { background: rgba(255,255,255,0.4); font-weight: bold; }

/* ============================================================
   MAIN CONTENT — three-column landscape layout
   ============================================================ */
.main-content {
    display: flex;
    flex-direction: row;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* ============================================================
   LEFT PANEL
   ============================================================ */
.left-panel {
    width: 260px;
    min-width: 220px;
    max-width: 300px;
    background: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 14px;
    flex-shrink: 0;
}

.file-upload-section {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #eee;
}

.file-upload-section h2,
.track-list-section h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    margin-bottom: 10px;
}

/* Hide the native file input; use label instead */
#gpx-upload { display: none; }

.file-label {
    display: block;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px dashed #81c784;
    border-radius: 5px;
    padding: 8px 10px;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.file-label:hover { background: #c8e6c9; }

#upload-btn {
    width: 100%;
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 8px;
    border-radius: 5px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

#upload-btn:hover { background: #1b5e20; }

.track-list-section { flex: 1; overflow-y: auto; }

/* ============================================================
   TRACK ITEMS
   ============================================================ */
.track-item {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 10px 8px;
    margin-bottom: 10px;
}

.track-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    word-break: break-word;
    cursor: pointer;
    color: #1a237e;
}

.track-name:hover { text-decoration: underline; }

.track-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Colored radio buttons */
.color-radio-group {
    display: flex;
    flex-direction: row;
    gap: 5px;
    flex: 1;
}

.radio-container {
    position: relative;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.radio-container input[type="radio"] {
    opacity: 0;
    position: absolute;
    inset: 0;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

.radio-label {
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    position: absolute;
    inset: 0;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #bbb;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.radio-container input[type="radio"]:checked + .radio-label {
    box-shadow: 0 0 0 2.5px #333;
    transform: scale(1.18);
}

.radio-label.grey  { background: #808080; }
.radio-label.amber { background: #FFC107; }
.radio-label.green { background: #4CAF50; }
.radio-label.black { background: #111111; }
.radio-label.red   { background: #F44336; }

/* Download button */
.download-btn {
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    title: "Download GPX";
    transition: background 0.2s;
}

.download-btn:hover { background: #0d47a1; }

/* Delete button */
.delete-btn {
    background: #c62828;
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.delete-btn:hover { background: #7f0000; }

.warning-icon { color: #e53935; font-size: 14px; }

/* ============================================================
   MAP
   ============================================================ */
.map-container {
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

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

/* ============================================================
   RIGHT PANEL
   ============================================================ */
.right-panel {
    width: 240px;
    min-width: 200px;
    max-width: 280px;
    background: #fff;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 14px;
    flex-shrink: 0;
}

/* Status key */
.status-key {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #eee;
}

.status-key h2,
.change-log h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
    margin-bottom: 10px;
}

.key-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

.color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.color-dot.grey  { background: #808080; }
.color-dot.amber { background: #FFC107; }
.color-dot.green { background: #4CAF50; }
.color-dot.black { background: #111111; }
.color-dot.red   { background: #F44336; }

/* Change log */
.change-log { flex: 1; overflow-y: auto; }

#log-entries { font-size: 12px; }

.log-entry {
    padding: 7px 0;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.4;
}

.log-entry .timestamp { color: #999; font-size: 11px; display: block; margin-top: 2px; }
.log-entry .user-name { font-weight: bold; color: #1565c0; }

.issue-details {
    margin-top: 5px;
    padding: 5px 8px;
    background: #fff3f3;
    border-left: 3px solid #e53935;
    font-style: italic;
    font-size: 12px;
    color: #555;
}

/* Issue popup on map */
.issue-popup-content h3 {
    color: #c62828;
    margin-bottom: 6px;
    font-size: 14px;
}

.issue-popup-content p { font-size: 13px; margin-bottom: 4px; }
.issue-popup-content .reported-by { font-size: 11px; color: #888; font-style: italic; }

/* ============================================================
   ROLE SELECTOR (user modal)
   ============================================================ */
.role-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.role-option {
    flex: 1;
    cursor: pointer;
}

.role-option input[type="radio"] {
    display: none;
}

.role-card {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px 8px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.role-card .role-icon { font-size: 22px; }
.role-card strong { font-size: 13px; display: block; }
.role-card small { font-size: 11px; color: #666; line-height: 1.3; }

.role-option input[type="radio"]:checked + .role-card {
    border-color: #2e7d32;
    background: #e8f5e9;
}

#admin-pin-section {
    margin-bottom: 12px;
}

#admin-pin-section input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    margin-bottom: 6px;
    outline: none;
}

/* Role badge in header */
.role-badge {
    font-size: 12px;
    padding: 2px 9px;
    border-radius: 12px;
    font-weight: bold;
}

.role-badge.admin { background: rgba(255,200,0,0.3); color: #fff; border: 1px solid rgba(255,200,0,0.5); }
.role-badge.user  { background: rgba(255,255,255,0.2); color: #fff; border: 1px solid rgba(255,255,255,0.4); }

/* Admin user badge in active users list */
.user-badge.admin-user { background: rgba(255,200,0,0.3); }

/* Share modal info text */
.share-info { font-size: 12px; color: #888; margin-bottom: 14px; }

/* ============================================================
   RESPONSIVE — tablets and phones
   ============================================================ */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
        overflow-y: auto;
    }

    .left-panel,
    .right-panel {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid #ddd;
        max-height: 300px;
    }

    .map-container {
        height: 50vh;
        min-height: 300px;
    }
}

/* ============================================================
   LOBBY SCREEN
   ============================================================ */
.lobby-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #f5f5f5;
    z-index: 1500;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.lobby-container {
    background: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.lobby-container h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.session-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 10px;
    min-height: 200px;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

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

.session-item:hover {
    background: #f9f9f9;
}

.session-item-name {
    font-weight: bold;
    font-size: 16px;
    color: #2e7d32;
}

.session-item-date {
    font-size: 12px;
    color: #888;
}

.new-session-container {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.new-session-container h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
}

.new-session-container input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.new-session-container button {
    width: 100%;
    padding: 10px;
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.new-session-container button:hover {
    background: #1b5e20;
}

.loading-sessions {
    text-align: center;
    padding: 20px;
    color: #888;
    font-style: italic;
}
