/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Electric primary colors */
    --primary-color: #940f99;        /* Electric purple/magenta (primary) */
    --primary-dark: #6b0a70;         /* Darker electric purple */
    --secondary-color: #030891;      /* Electric blue (secondary) */
    --secondary-light: #0510d8;      /* Lighter electric blue */
    --tertiary-color: #c026d3;       /* Electric fuchsia */
    --accent-cyan: #06b6d4;          /* Electric cyan accent */

    /* Green for special highlights only */
    --highlight-color: #10b981;      /* Emerald green for special items */

    /* Status colors */
    --success-color: #10b981;        /* Green for success */
    --error-color: #ef4444;          /* Red for errors */

    /* Background colors */
    --bg-color: #000000;             /* Pure black */
    --card-bg: #0a0514;              /* Very dark purple-tinted */
    --text-color: #e5e7eb;           /* Light gray (readable) */
    --text-secondary: #9ca3af;       /* Medium gray for secondary text */
    --border-color: #1a0b2e;         /* Dark purple border */

    /* Electric glows for that electric feel */
    --glow-purple: 0 0 10px rgba(148, 15, 153, 0.6), 0 0 20px rgba(148, 15, 153, 0.4), 0 0 30px rgba(148, 15, 153, 0.2);
    --glow-blue: 0 0 10px rgba(3, 8, 145, 0.6), 0 0 20px rgba(3, 8, 145, 0.4), 0 0 30px rgba(3, 8, 145, 0.2);
    --glow-fuchsia: 0 0 10px rgba(192, 38, 211, 0.6), 0 0 20px rgba(192, 38, 211, 0.4), 0 0 30px rgba(192, 38, 211, 0.2);
    --glow-cyan: 0 0 10px rgba(6, 182, 212, 0.6), 0 0 20px rgba(6, 182, 212, 0.4);
    --glow-green: 0 0 10px rgba(16, 185, 129, 0.6), 0 0 20px rgba(16, 185, 129, 0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(148, 15, 153, 0.03) 0px,
            transparent 1px,
            transparent 2px,
            rgba(3, 8, 145, 0.02) 3px
        );
    pointer-events: none;
    z-index: 1;
}

body > * {
    position: relative;
    z-index: 2;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

/* Logo */
.logo {
    text-align: center;
    margin: 40px 0 30px;
}

.logo h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color), var(--tertiary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 12px rgba(148, 15, 153, 0.8));
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 12px rgba(148, 15, 153, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(3, 8, 145, 0.9)) drop-shadow(0 0 30px rgba(192, 38, 211, 0.6));
    }
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Card */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(148, 15, 153, 0.4);
    box-shadow: 0 0 20px rgba(148, 15, 153, 0.15),
                0 0 30px rgba(3, 8, 145, 0.1),
                inset 0 0 20px rgba(148, 15, 153, 0.05);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: rgba(148, 15, 153, 0.6);
    box-shadow: 0 0 25px rgba(148, 15, 153, 0.25),
                0 0 35px rgba(3, 8, 145, 0.15),
                inset 0 0 25px rgba(148, 15, 153, 0.08);
}

.card h2, .card h3 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 12px rgba(148, 15, 153, 0.6);
}

.card h3 {
    font-size: 1.2rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4),
                inset 0 0 10px rgba(0, 255, 65, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

/* Badge Buttons (Single Select) */
.badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.badge-button {
    padding: 10px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-color);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.badge-button:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(148, 15, 153, 0.3);
    transform: translateY(-2px);
}

.badge-button.active {
    background: rgba(148, 15, 153, 0.25);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(148, 15, 153, 0.5);
}

/* Tag Checkboxes (Multi Select) */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.tag-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.tag-checkbox:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(148, 15, 153, 0.3);
}

.tag-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.tag-checkbox input[type="checkbox"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.tag-checkbox:has(input:checked) {
    background: rgba(148, 15, 153, 0.15);
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(148, 15, 153, 0.4);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
    box-shadow: var(--glow-purple);
    border: 1px solid var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.6),
                0 0 25px rgba(168, 85, 247, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
    box-shadow: var(--glow-blue);
}

.btn-secondary:hover {
    background: var(--secondary-color);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(3, 8, 145, 0.8),
                0 0 30px rgba(3, 8, 145, 0.5);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
    width: auto;
    margin: 0;
}

/* Messages */
.error-message {
    color: var(--error-color);
    background: rgba(255, 0, 110, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    display: none;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 0, 110, 0.3);
}

.error-message.show {
    display: block;
}

.info-message {
    color: var(--success-color);
    background: rgba(16, 185, 129, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 0.9rem;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.info-box {
    background: rgba(3, 8, 145, 0.15);
    border: 1px solid rgba(3, 8, 145, 0.4);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    box-shadow: var(--glow-blue);
}

.info-box strong {
    color: var(--text-color);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header h2 {
    margin: 0;
}

/* Map Screen */
.map-header {
    background: var(--card-bg);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 15px rgba(0, 255, 65, 0.2);
    border-bottom: 2px solid rgba(0, 255, 65, 0.3);
}

.map-header h2 {
    font-size: 1.25rem;
    margin: 0;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(0, 255, 65, 0.5);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.map-controls {
    background: var(--card-bg);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.control-group select {
    padding: 6px 12px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.9rem;
}

/* Map */
#map {
    height: calc(100vh - 200px);
    width: 100%;
}

.leaflet-popup-content {
    color: #1e293b;
}

.leaflet-popup-content h3 {
    margin: 0 0 8px 0;
    color: #0f172a;
}

.leaflet-popup-content p {
    margin: 4px 0;
    font-size: 0.9rem;
}

/* User Info Panel */
.user-info-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

.user-info-panel h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

#current-user-info {
    font-size: 0.9rem;
}

#current-user-info p {
    margin: 4px 0;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 2rem;
    }

    .container {
        padding: 16px;
    }

    .card {
        padding: 20px;
    }

    #map {
        height: calc(100vh - 180px);
    }

    .map-controls {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .control-group {
        justify-content: space-between;
    }

    .header-actions {
        flex-direction: column;
        gap: 4px;
    }

    .btn-sm {
        width: auto;
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "Loading...";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    padding: 20px 40px;
    border-radius: 12px;
    font-weight: 600;
    z-index: 9999;
}

/* Photo Gallery */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    min-height: 50px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
}

.photo-item-actions button {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
}

.photo-item.primary::after {
    content: "★ Primary";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary-color);
    color: #000000;
    text-align: center;
    font-size: 0.7rem;
    padding: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    box-shadow: 0 -2px 15px rgba(0, 255, 65, 0.6);
}

.photo-item {
    border: 2px solid rgba(0, 255, 65, 0.2);
    transition: all 0.3s ease;
}

.photo-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.4);
}

/* Chat Screen */
.chat-header {
    background: var(--card-bg);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chat-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.chat-container {
    display: flex;
    height: calc(100vh - 70px);
}

.conversations-list {
    width: 300px;
    border-right: 1px solid var(--border-color);
    background: var(--card-bg);
    overflow-y: auto;
}

.conversations-list h3 {
    padding: 16px;
    margin: 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 1rem;
}

.conversation-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: rgba(0, 255, 65, 0.05);
    border-left: 3px solid var(--primary-color);
}

.conversation-item.active {
    background: rgba(0, 255, 65, 0.15);
    border-left: 3px solid var(--primary-color);
    box-shadow: inset 0 0 20px rgba(0, 255, 65, 0.2);
}

.conversation-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.conversation-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item.active .conversation-preview {
    color: rgba(255, 255, 255, 0.8);
}

.unread-badge {
    background: var(--tertiary-color);
    color: #ffffff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    margin-left: 8px;
    box-shadow: 0 0 10px rgba(255, 0, 110, 0.6);
    animation: pulse-badge 1.5s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 0, 110, 0.6);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 0, 110, 0.9);
    }
}

.chat-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.chat-user-header {
    padding: 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.message.sent {
    align-items: flex-end;
}

.message.received {
    align-items: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: var(--tertiary-color);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.5);
    border: 1px solid var(--tertiary-color);
}

.message.received .message-bubble {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.message-input-container {
    padding: 16px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.message-input-container input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-color);
}

.message-input-container button {
    padding: 10px 20px;
    margin: 0;
    width: auto;
}

/* Profile Switcher */
.profile-switcher-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.profile-switcher-header h3 {
    margin: 0;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    width: auto;
}

.profile-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-item {
    background: var(--card-bg);
    border: 2px solid rgba(0, 255, 65, 0.2);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profile-item:hover {
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
}

.profile-item.active {
    border-color: var(--primary-color);
    background: rgba(0, 255, 65, 0.1);
    box-shadow: 0 0 25px rgba(0, 255, 65, 0.4),
                inset 0 0 20px rgba(0, 255, 65, 0.1);
}

.profile-item-info {
    flex: 1;
}

.profile-item-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.profile-item-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-badge.primary {
    background: var(--primary-color);
    color: #000000;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.6);
}

.profile-badge.public {
    background: var(--accent-blue);
    color: #000000;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.6);
}

.profile-badge.private {
    background: var(--secondary-color);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(189, 0, 255, 0.6);
}

.profile-item-actions {
    display: flex;
    gap: 8px;
}

.profile-item-actions button {
    padding: 6px 10px;
    font-size: 0.8rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-item-actions button:hover {
    opacity: 0.8;
}

.profile-item-actions .btn-toggle-public {
    background: var(--secondary-color);
    color: white;
}

.profile-item-actions .btn-delete {
    background: var(--error-color);
    color: white;
}

/* Mobile adjustments for chat */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .conversations-list {
        width: 100%;
        height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .message-bubble {
        max-width: 85%;
    }

    .profile-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .profile-item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
