@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0');

:root {
    --font-serif: 'Merriweather', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --background: #f4f4f9;
    --surface: #ffffff;
    --text-primary: #1c1c1e;
    --text-secondary: #8a8a8e;
    --accent: #007aff;
    --border: #e5e5e5;
    --status-open: #ff9500;
    --status-claimed: #5ac8fa;
    --status-closed: #34c759;
    --danger: #ff3b30;
}

* { box-sizing: border-box; }

.hidden {
    display: none !important;
}

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    color: var(--text-primary);
    font-size: 17px;
    line-height: 1.6;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

#app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 15px 100px 15px; /* Padding for bottom nav */
}

#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 20px;
}
.logo-main {
    font-family: var(--font-sans);
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

/* MODIFIED: Styles for clickable user profile */
#user-profile {
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}
#user-profile:hover {
    background-color: var(--background);
}

.welcome-message {
    text-align: right;
}
.welcome-message strong {
    font-weight: 600;
    color: var(--text-primary);
}

#news-banner {
    background-color: #eef5ff;
    color: var(--accent);
    border-left: 5px solid var(--accent);
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.5;
    display: none;
    position: relative;
    margin-bottom: 25px;
}
#news-banner .news-content {
    padding-right: 30px;
}
#news-banner strong { font-weight: 600; color: #005ecb; }
#news-banner .delete-news-btn {
    position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
    background: none; border: none; color: var(--accent); font-size: 24px;
    cursor: pointer; opacity: 0.6; padding: 5px;
}
#news-banner .delete-news-btn:hover { opacity: 1; }


#main-content {
    animation: fadeIn 0.5s forwards;
}
@keyframes fadeIn { to { opacity: 1; } }

.page-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-title {
    font-size: 34px;
    font-weight: 700;
    margin: 0;
}
.page-header-controls {
    display: flex;
    gap: 10px;
}
.page-header-controls input[type="search"] {
    width: 250px;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: var(--surface);
}
.icon-button {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}
.icon-button.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.icon-button:hover {
    background-color: #f0f0f0;
}
.icon-button.active:hover {
     background-color: #006ee5;
}


/* Less intrusive subheadings */
.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 30px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
}

.action-card {
    background: var(--surface);
    border-radius: 18px;
    padding: 20px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 150px;
}
.action-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
.action-card .material-symbols-outlined {
    font-size: 32px;
    color: var(--accent);
    margin-bottom: 10px;
}
.action-card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.item-list {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 15px;
}
.list-item-card {
    background: var(--surface);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    border-left: 5px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s;
}
.list-item-card:hover {
    background-color: #f9f9f9;
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.card-title { font-size: 18px; font-weight: 600; }
.card-status-tag {
    font-size: 12px; font-weight: 600; padding: 4px 10px;
    border-radius: 20px; color: white; text-transform: uppercase;
}
.card-body { font-size: 16px; color: #3c3c3e; margin-bottom: 12px; }
.card-footer { font-size: 14px; color: var(--text-secondary); }

.list-item-card.status-open { border-left-color: var(--status-open); }
.list-item-card.status-claimed { border-left-color: var(--status-claimed); }
.list-item-card.status-closed { border-left-color: var(--status-closed); opacity: 0.7; }

.status-open .card-status-tag { background-color: var(--status-open); }
.status-claimed .card-status-tag { background-color: var(--status-claimed); }
.status-closed .card-status-tag { background-color: var(--status-closed); }

.details-view {
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid var(--border);
}
.details-title { font-size: 20px; font-weight: 600; margin-bottom: 15px; }
.comment-list { display: flex; flex-direction: column; gap: 20px; }
.comment-row { background: var(--background); padding: 15px; border-radius: 12px; }
.comment-meta { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.comment-text { font-size: 15px; }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex; justify-content: center; align-items: flex-end;
    z-index: 1000; opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease;
}
.modal-overlay:not(.hidden) { opacity: 1; visibility: visible; }
.modal-overlay .modal-content {
    background: var(--surface);
    width: 100%; max-width: 800px;
    border-radius: 20px 20px 0 0;
    padding: 15px;
    box-shadow: 0 -5px 30px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}
.modal-overlay:not(.hidden) .modal-content {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
#modal-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}
#modal-close-btn {
    background: #e5e5e5;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: var(--text-secondary);
}
.modal-body {
    max-height: 70vh;
    overflow-y: auto;
    padding: 0 5px;
}

.form-field { margin-bottom: 20px; }
.form-field label {
    font-weight: 600;
    font-size: 15px;
    display: block;
    margin-bottom: 8px;
}

/* Making text fields consistent */
.form-field input, .form-field textarea {
    width: 100%;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    font-size: 16px;
    font-family: var(--font-sans);
}
.form-field textarea {
    min-height: 120px; /* Adjust as needed */
}

.form-field input:focus, .form-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}
.button {
    font-family: var(--font-sans); font-weight: 600; font-size: 16px;
    border-radius: 10px; padding: 14px 20px; border: none;
    cursor: pointer;
}
.button-primary { background: var(--accent); color: #fff; }

#app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
}
#app-nav.hidden { display: none; }
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 8px;
    transition: background-color 0.2s;
}
.nav-item.active {
    color: var(--accent);
}
.nav-item:active {
    background-color: rgba(0,0,0,0.05);
}
.nav-item .material-symbols-outlined {
    font-size: 28px;
}

#notification-container {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 2000;
}
.notification {
    background-color: var(--text-primary); color: white;
    padding: 10px 20px; border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    opacity: 0;
    animation: slideInAndOut 4s ease;
    font-size: 14px; font-weight: 500;
}
@keyframes slideInAndOut {
    5%, 85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* User Management Specifics */
.user-row {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.user-row:last-child { border-bottom: none; }
.user-info { font-weight: 600; }
.user-roles { text-align: right; }
.role-list {
    font-size: 14px; color: var(--text-secondary);
}
.approve-btn {
    background: var(--status-closed); color: white;
    padding: 6px 12px; font-size: 14px;
}
.role-toggle-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}
.role-toggle {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: var(--background); padding: 15px; border-radius: 10px;
}
.role-toggle-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.role-toggle-header label { font-weight: 500; }
.role-toggle input[type="checkbox"] {
    transform: scale(1.3);
    accent-color: var(--accent);
}
.role-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 5px;
}


/* --- CHAT STYLES --- */
.chat-card {
    border-left-color: var(--accent);
    flex-direction: row;
    align-items: center;
    gap: 15px;
}
.chat-card.archived {
    border-left-color: var(--text-secondary);
    opacity: 0.7;
}
.chat-card.archived .material-symbols-outlined {
    color: var(--text-secondary);
}

.chat-view {
    background: var(--surface);
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 120px);
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px 10px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-header h3 { margin: 0; font-size: 20px; }
.chat-header .button-icon {
    background: transparent; border: none; cursor: pointer;
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-primary);
}
.chat-header .button-icon:hover { background-color: var(--background); }

#chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.chat-message-group {
    display: flex;
    flex-direction: column;
}
.message-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    margin-left: 15px;
}
.message-bubble {
    background: var(--background);
    padding: 10px 15px;
    border-radius: 20px;
    max-width: 75%;
    width: fit-content;
    line-height: 1.5;
}

#chat-input-container {
    padding: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}
#chat-input {
    flex-grow: 1;
    background: var(--background);
    border: none;
    border-radius: 20px;
    padding: 12px 18px;
    font-size: 16px;
    font-family: var(--font-sans);
}
#chat-input:focus { outline: none; }
#chat-send-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}
#chat-send-btn:active { transform: scale(0.9); }

/* Chat Management Modal */
.user-management-list {
    display: flex; flex-direction: column; gap: 5px;
    max-height: 300px; overflow-y: auto; margin-top: 15px;
    border: 1px solid var(--border); border-radius: 10px; padding: 5px;
}
.user-management-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; border-radius: 8px;
}
.user-management-row:hover { background-color: var(--background); }
.user-management-row .name { font-weight: 500; }
.user-management-row .button { padding: 5px 12px; font-size: 14px; }
.button-add { background-color: var(--status-closed); color: white; }
.button-remove { background-color: var(--danger); color: white; }
#user-search-input { width: 100%; }
.archive-button {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    margin-top: 20px;
}
.archive-button:hover {
    background-color: var(--danger);
    color: white;
}

.login-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.login-actions .button,
.login-actions .button-primary {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    font-size: 18px;
}

#connection-status {
    background-color: var(--danger);
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 15px;
    font-weight: 500;
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
}
#connection-status.visible {
    display: block;
}