/* Noah Web App - Stylesheet */
:root {
    --primary: #502379;
    --primary-light: #7b3fb5;
    --primary-dark: #3a1855;
    --accent: #ffeb3b;
    --bg: #f5f5f7;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #666;
    --border: #e0e0e0;
    --shadow: 0 2px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --header-h: 56px;
    --sidebar-w: 320px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

/* === HEADER === */
.header {
    height: var(--header-h);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: var(--shadow);
    z-index: 1000;
    position: relative;
}

.header-logo {
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo span { font-weight: 300; opacity: 0.8; }

.header-nav {
    display: flex;
    gap: 4px;
    margin-left: 24px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.8);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-btn:hover, .nav-btn.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

.user-menu {
    position: relative;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    min-width: 200px;
    display: none;
    z-index: 1001;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
}

.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: #d32f2f; }

/* === MAIN LAYOUT === */
.app-container {
    display: flex;
    height: calc(100vh - var(--header-h));
}

/* === SIDEBAR === */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
    z-index: 999;
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.map-list { list-style: none; }

.map-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    transition: background 0.2s;
}

.map-item:hover { background: var(--bg); }
.map-item.active { background: var(--primary); color: white; }
.map-item .map-icon { font-size: 18px; }
.map-item .map-name { font-size: 14px; font-weight: 500; flex: 1; }

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

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

/* === FLOATING PANELS === */
.panel {
    position: absolute;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
}

.panel-header {
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
}

.panel-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.panel-close:hover { background: rgba(255,255,255,0.2); }

.panel-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

/* === TOOL PALETTE === */
.tool-palette {
    position: absolute;
    left: 16px;
    top: 16px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 100;
    overflow: hidden;
}

.tool-palette-header {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 8px;
}

.tool-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    color: var(--text);
    transition: all 0.2s;
}

.tool-btn:hover { background: var(--primary-light); color: white; }
.tool-btn.active { background: var(--primary); color: white; }

.tool-btn .tool-icon { font-size: 20px; }

/* === LAYER PANEL === */
.layer-panel {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 280px;
    z-index: 100;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.layer-toggle {
    width: 40px;
    height: 22px;
    background: #ccc;
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.layer-toggle.on { background: var(--primary); }

.layer-toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: left 0.2s;
}

.layer-toggle.on::after { left: 20px; }

.layer-name { flex: 1; font-size: 14px; }
.layer-opacity { width: 60px; }

/* === POST-IT INFO WINDOW === */
.postit-window {
    max-width: 320px;
}

.postit-window .postit-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.postit-window .postit-content {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.postit-window .postit-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.postit-window .postit-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.postit-action-btn {
    background: var(--bg);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.postit-action-btn:hover { background: var(--primary-light); color: white; }
.postit-action-btn.liked { color: #e91e63; }

/* === MODALS === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-large { max-width: 600px; }

.modal-header {
    padding: 16px 20px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* === FORMS === */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-error {
    color: #d32f2f;
    font-size: 13px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #ffebee;
    border-radius: var(--radius-sm);
}

/* === BUTTONS === */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

.btn-secondary {
    background: var(--bg);
    color: var(--text);
}

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

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

.btn-block { width: 100%; }

/* === AUTH SCREEN === */
.auth-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo h1 {
    font-size: 32px;
    color: var(--primary);
    font-weight: 800;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow);
}

/* === POST-IT COLORS === */
.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.2s;
}

.color-option.selected { border-color: var(--primary); }

/* === FRIEND LIST === */
.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.friend-item:last-child { border: none; }

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.friend-info { flex: 1; }
.friend-name { font-size: 14px; font-weight: 600; }
.friend-username { font-size: 12px; color: var(--text-secondary); }

/* === SEARCH === */
.search-box {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* === TOAST === */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 4000;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* === LOADING === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

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

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
    }
    
    .sidebar.open { transform: translateX(0); }
    
    .header-nav { display: none; }
    
    .tool-palette { left: 8px; top: 8px; }
    .layer-panel { right: 8px; top: 8px; width: 240px; }
    
    .nav-mobile-toggle { display: block !important; }
}

.nav-mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    margin-right: 8px;
}

/* === ITEM EDITOR === */
.item-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-preview {
    text-align: center;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 48px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.slider {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

/* === ACTIVITY FEED === */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border: none; }

.activity-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.activity-content { flex: 1; font-size: 13px; }
.activity-time { font-size: 11px; color: var(--text-secondary); }

/* GPS Button */
.gps-btn {
    background: white;
    border: 2px solid #502379;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    margin: 10px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gps-btn:hover {
    background: #502379;
    color: white;
    transform: scale(1.1);
}
.gps-btn.active {
    background: #502379;
    color: white;
    animation: gps-pulse 2s infinite;
}
@keyframes gps-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(80, 35, 121, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(80, 35, 121, 0); }
}

/* Tool Palette Toggle Button */
.tool-toggle-btn {
    position: absolute;
    bottom: 120px;
    left: 10px;
    z-index: 5;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: 2px solid #502379;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tool-toggle-btn:hover {
    background: #502379;
    transform: scale(1.1);
}
.tool-toggle-btn.active {
    background: #502379;
    color: white;
}

/* Friend requests list */
#friend-requests-list .friend-item {
    border: 1px solid #e0d4e8;
    background: #f8f5fa;
}