/**
 * Toronto Ice Skating - Styles
 * Mobile-first, minimal CSS
 */

/* ========== RESET & BASE ========== */
:root {
    --primary: #4a9;
    --primary-dark: #3a8;
    --danger: #c55;
    --warning: #f5a623;
    --success: #4a9;
    --text: #222;
    --text-muted: #666;
    --bg: #f5f5f5;
    --bg-white: #fff;
    --border: #ddd;
    --border-dark: #ccc;
    --bubble-mine: #dcf8c6;
    --bubble-other: #fff;
    --bubble-system: #f0f0f0;
    --bubble-shared: #e3f2fd;
    --radius: 8px;
    --radius-lg: 16px;
    --happening-now: #ff6b35;
}

/* Dark mode */
body.dark-mode {
    --primary: #5cb;
    --primary-dark: #4ba;
    --text: #e8e8e8;
    --text-muted: #999;
    --bg: #1a1a1a;
    --bg-white: #252525;
    --border: #404040;
    --border-dark: #555;
    --bubble-mine: #2d4a2d;
    --bubble-other: #333;
    --bubble-system: #2a2a2a;
    --bubble-shared: #1e3a4a;    
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    background: var(--bg);
    color: var(--text);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: var(--bg);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    transition: background 0.15s, transform 0.1s;
}

button:active { transform: scale(0.97); }

input, select {
    font-family: inherit;
    font-size: 14px;
    padding: 8px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    background: var(--bg-white);
}

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

/* ========== APP LAYOUT ========== */
.app {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    gap: 10px;
    flex-shrink: 0;
}

.top-bar h1 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

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

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--bg);
    border: 1px solid var(--border);
}

/* Tabs for switching views */
.view-tabs {
    display: flex;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.view-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-weight: 500;
}

.view-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.view-tab .badge {
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

/* Main content area */
.main-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    display: none;
    padding: 10px;
}

.view-panel.active { display: block; }

/* ========== PROGRAMS VIEW ========== */
.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.search-box input { flex: 1; }

.filter-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 15px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.filter-chip.active {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}

.filter-selects {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.filter-selects select {
    flex: 1;
    max-width: 150px;
}

.stats-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    gap: 8px;
}

.stats-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.data-updated {
    font-size: 10px;
    color: var(--text-muted);
}

.data-updated.stale {
    color: var(--warning);
}

.btn-refresh {
    padding: 4px 8px;
    font-size: 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
}

.btn-refresh:hover { background: var(--bg); }
.btn-refresh:disabled { opacity: 0.5; cursor: not-allowed; }

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

.program-item {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.program-item:active { background: #ffffd0; }

.program-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.program-title {
    font-weight: 600;
    color: #0066cc;
    font-size: 14px;
}

.program-meta {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.program-date { font-weight: 600; color: var(--text); }

.program-location {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.program-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.tag {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 3px;
    background: #eee;
    text-transform: uppercase;
    font-weight: 500;
}

.tag.hockey { background: #ffe0e6; color: #c44; }
.tag.figure { background: #e0e6ff; color: #44c; }
.tag.speed { background: #fff5e0; color: #a84; }
.tag.leisure { background: #e0ffe6; color: #4a9; }
.tag.adapted { background: #e6e0ff; color: #84a; }
.tag.ringette { background: #ffe6f5; color: #a4c; }

.program-actions {
    display: flex;
    gap: 6px;
}

.program-actions button {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-vote.voted {
    background: var(--primary);
    color: #fff;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 10px 0;
    flex-wrap: wrap;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    padding: 0;
}

.pagination button.active {
    background: var(--text);
    color: #fff;
}

/* ========== GROUPS VIEW ========== */
.groups-list {
    list-style: none;
}

.group-item {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-item.active {
    border-color: var(--primary);
    background: #f0fff4;
}

.group-info h3 {
    font-size: 14px;
    font-weight: 600;
}

.group-info .group-code {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

.group-info .group-members {
    font-size: 12px;
    color: var(--text-muted);
}

.group-actions {
    display: flex;
    gap: 6px;
}

.create-group-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 16px;
    border: 2px dashed var(--border);
    text-align: center;
}

.create-group-card h3 {
    font-size: 14px;
    margin-bottom: 8px;
}

.create-group-card p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.create-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.create-options input {
    text-align: center;
}

.create-options .btn-primary {
    padding: 12px;
    font-size: 15px;
}

.share-card {
    background: #fffde7;
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 12px;
    border: 1px solid #e6d88a;
}

.share-card label {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

.share-card input {
    width: 100%;
    font-size: 12px;
    margin-bottom: 8px;
}

/* ========== CHAT VIEW ========== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 10px 12px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info h3 {
    font-size: 14px;
    font-weight: 600;
}

.chat-header-info .status {
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.status-dot.online { background: var(--primary); }
.status-dot.offline { background: #ccc; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: #fafafa;
}

.chat-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.chat-msg {
    margin-bottom: 8px;
    max-width: 85%;
}

.chat-msg.mine {
    margin-left: auto;
    text-align: right;
}

.chat-msg .sender {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.chat-msg .bubble {
    display: inline-block;
    padding: 8px 12px;
    background: var(--bubble-other);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 14px;
    text-align: left;
    word-break: break-word;
    color: var(--text);
}

.chat-msg.mine .bubble {
    background: var(--bubble-mine);
    border-color: var(--border);
}

.chat-msg.system {
    text-align: center;
    max-width: 100%;
}

.chat-msg.system .bubble {
    background: var(--bubble-system);
    color: var(--text-muted);
    font-size: 12px;
    border: none;
    padding: 4px 10px;
}

.chat-msg.share .bubble {
    background: var(--bubble-shared);
    border-color: var(--border);
}

.chat-msg .subtext {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.chat-msg .dm-btn {
    font-size: 11px;
    padding: 2px 6px;
    margin-left: 4px;
}

.chat-input-bar {
    padding: 10px;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.chat-input-bar input {
    flex: 1;
    border-radius: 20px;
    padding: 10px 16px;
}

.chat-input-bar button {
    width: 44px;
    height: 44px;
    border-radius: 22px;
    background: var(--primary);
    color: #fff;
    font-size: 18px;
    padding: 0;
}

.members-bar {
    padding: 8px 12px;
    background: #f0f0f0;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.member-chip {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-white);
    border-radius: 10px;
    margin: 2px;
    font-size: 11px;
    cursor: pointer;
}

.member-chip:hover { background: #e0e0e0; }

/* ========== PASSWORD MODAL ========== */
.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;
    padding: 20px;
    z-index: 1000;
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    max-width: 320px;
    width: 100%;
}

.modal h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.modal p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.modal input {
    width: 100%;
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ========== DESKTOP ENHANCEMENTS ========== */
@media (min-width: 768px) {
    .app {
        flex-direction: row;
    }
    
    .view-tabs { display: none; }
    
    .main-content {
        display: flex;
    }
    
    .view-panel {
        position: relative;
        display: block;
        flex: 1;
        border-right: 1px solid var(--border);
    }
    
    .view-panel.chat-panel-view {
        max-width: 380px;
        flex: 0 0 380px;
        border-right: none;
    }
    
    .view-panel.groups-panel-view {
        max-width: 280px;
        flex: 0 0 280px;
    }
}

/* ========== UTILITY ========== */
.hidden { display: none !important; }

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.error {
    text-align: center;
    padding: 40px;
    color: var(--danger);
}

/* ========== DM & MEMBER INTERACTIONS ========== */
.member-chip {
    cursor: pointer;
    transition: background 0.15s;
}

.member-chip:hover {
    background: var(--primary);
    color: #fff;
}

.chat-header-info {
    display: flex;
    align-items: center;
}

.chat-header-info h3 {
    font-size: 14px;
}

/* DM bubble styling */
.chat-msg.dm .bubble {
    background: #fff3e0;
    border-color: #ffcc80;
}

/* ========== DM INBOX ========== */
.dm-inbox {
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-white);
    z-index: 100;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dm-inbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.dm-inbox-header h4 {
    font-size: 16px;
    font-weight: 600;
}

.dm-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
}

.dm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.dm-item:hover {
    background: var(--bg);
}

.dm-item.unread {
    background: #e8f5e9;
}

.dm-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.dm-info strong {
    font-size: 14px;
}

.dm-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.dm-time {
    font-size: 11px;
    color: var(--text-muted);
}

.dm-unread-badge {
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Program location link */
.program-location {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    display: inline-block;
    margin-top: 2px;
}

.program-location:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Program actions cleanup */
.program-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-share-program {
    background: var(--primary);
    color: #fff;
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius);
}

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

.btn-vote {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 12px;
}

.btn-vote.voted {
    background: #e8f5e9;
    border-color: var(--primary);
    color: var(--primary);
}

/* ========== TOAST NOTIFICATIONS ========== */
#toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 320px;
}

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left: 4px solid var(--primary);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-error { border-left-color: var(--danger); }

.toast button {
    padding: 2px 6px;
    font-size: 12px;
    background: transparent;
    color: var(--text-muted);
}

/* ========== AGE BADGE (prominent) ========== */
.age-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.age-badge::before {
    content: '👤';
    font-size: 10px;
}

.age-badge.all-ages {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

/* ========== HAPPENING NOW ========== */
.happening-now {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--happening-now);
    color: #fff;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.happening-now::before {
    content: '🔴';
    font-size: 8px;
}

/* ========== FAVORITES ========== */
.btn-favorite {
    background: transparent;
    border: none;
    padding: 4px 8px;
    font-size: 18px;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-favorite:hover {
    transform: scale(1.2);
}

.btn-favorite.active {
    animation: heartBeat 0.3s ease;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ========== PUBLIC ROOMS ========== */
.public-rooms {
    padding: 16px;
}

.public-rooms h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.room-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.room-card:hover {
    border-color: var(--primary);
    background: #f0fff4;
}

.room-card.joined {
    border-color: var(--primary);
    background: #e8f5e9;
}

.room-emoji {
    font-size: 24px;
}

.room-info {
    flex: 1;
}

.room-name {
    font-weight: 600;
    font-size: 14px;
}

.room-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.room-members {
    font-size: 11px;
    color: var(--primary);
}

/* ========== COPY BUTTON ========== */
.btn-copy {
    background: transparent;
    border: 1px solid var(--border);
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-muted);
    border-radius: 4px;
}

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

/* ========== PROGRAM ITEM ENHANCEMENTS ========== */
.program-item.happening-soon {
    border-left: 3px solid var(--happening-now);
}

.program-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* ========== DARK MODE & TOGGLES ========== */
.btn-icon {
    background: transparent;
    border: none;
    font-size: 18px;
    padding: 4px 8px;
    cursor: pointer;
    opacity: 0.8;
}
.btn-icon:hover { opacity: 1; }

.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}
.dark-mode-toggle .btn-icon {
    padding: 2px 4px;
    font-size: 16px;
}
.dark-mode-toggle span {
    margin-right: 8px;
}

.toggle-past {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.toggle-past input {
    margin: 0;
    cursor: pointer;
}
.toggle-past:hover { color: var(--text); }

.pagination-top {
    margin-bottom: 8px;
}

