/* 
 * URAIO Community Hub - Stylesheet
 * Design System: Mobile-first, Dark/Light Mode, 8px Grid
 */

:root {
    /* Color Palette */
    --primary: #4361ee;
    --primary-light: #eef2ff;
    --secondary: #3a0ca3;
    --secondary-light: #f0ebfa;
    --accent: #4cc9f0;
    --accent-light: #e0f7fc;
    --success: #4ade80;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    
    /* Neutral Colors (Light Mode Default) */
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    
    /* Spacing & Layout */
    --spacing-unit: 8px;
    --header-height: 60px;
    --nav-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-body: #111827;
    --bg-card: #1f2937;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border: #374151;
    --primary-light: rgba(67, 97, 238, 0.2);
    --secondary-light: rgba(58, 12, 163, 0.2);
    --accent-light: rgba(76, 201, 240, 0.2);
    --success-light: rgba(74, 222, 128, 0.2);
    --warning-light: rgba(245, 158, 11, 0.2);
    --danger-light: rgba(239, 68, 68, 0.2);
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + 20px); /* Space for bottom nav */
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.125rem; }

p { font-size: 0.9375rem; }

/* Utility Classes */
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-white { color: #fff; }
.text-center { text-align: center; }

.bg-primary { background-color: var(--primary); }
.bg-danger { background-color: var(--danger); }
.bg-primary-light { background-color: var(--primary-light); }
.bg-secondary-light { background-color: var(--secondary-light); }
.bg-accent-light { background-color: var(--accent-light); }
.bg-success-light { background-color: var(--success-light); }
.bg-warning-light { background-color: var(--warning-light); }
.bg-danger-light { background-color: var(--danger-light); }

.mt-2 { margin-top: calc(var(--spacing-unit) * 2); }
.mt-4 { margin-top: calc(var(--spacing-unit) * 4); }

.hidden { display: none !important; }

/* Status Bar */
.status-bar {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-unit);
    position: sticky;
    top: 0;
    z-index: 100;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.status-icon {
    font-size: 1rem;
    margin-bottom: 2px;
}

/* Main Content */
main {
    padding: var(--spacing-unit);
    max-width: 600px;
    margin: 0 auto;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.view.active {
    display: block;
}

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

/* Hero Card */
.hero-card {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: calc(var(--spacing-unit) * 3);
    border-radius: var(--radius-lg);
    margin-bottom: calc(var(--spacing-unit) * 3);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.hero-card h1 { margin-bottom: 4px; }
.hero-card p { opacity: 0.9; font-size: 0.875rem; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background-color: var(--success); color: #000; }

.weather-widget {
    position: absolute;
    top: 24px;
    right: 24px;
    text-align: right;
}

/* Grid Menu */
.grid-menu {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: calc(var(--spacing-unit) * 2);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.grid-item span {
    font-size: 0.75rem;
    color: var(--text-main);
    font-weight: 500;
}

.icon-box {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: transform 0.2s;
}

.grid-item:active .icon-box {
    transform: scale(0.95);
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.btn-text {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.875rem;
}

/* Feed List */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-unit) * 2);
}

.feed-item {
    background-color: var(--bg-card);
    padding: calc(var(--spacing-unit) * 2);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.feed-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: bold;
}

.feed-meta {
    display: flex;
    flex-direction: column;
}

.feed-author { font-weight: 600; font-size: 0.875rem; }
.feed-time { font-size: 0.75rem; color: var(--text-muted); }

.feed-content { font-size: 0.9375rem; margin-bottom: 10px; }

.feed-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    background-color: var(--border);
}

.feed-actions {
    display: flex;
    gap: 20px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.action-btn:hover, .action-btn.active { color: var(--primary); }

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--nav-height);
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    gap: 4px;
    width: 20%;
}

.nav-item i { font-size: 1.25rem; }

.nav-item.active { color: var(--primary); }

.badge-container { position: relative; }
.badge-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 90;
    transition: transform 0.2s;
}

.fab:active { transform: scale(0.9); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 200;
    backdrop-filter: blur(4px);
}

.modal {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 201;
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-body textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    resize: none;
    margin-bottom: 10px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.875rem;
    transition: opacity 0.2s;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-outline-danger { border: 1px solid var(--danger); color: var(--danger); }
.btn-outline-warning { border: 1px solid var(--warning); color: var(--warning); }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    transition: background-color 0.2s;
}

.icon-btn:hover { background-color: var(--bg-body); }

/* Chat Styles */
.chat-messages {
    height: calc(100vh - 180px);
    overflow-y: auto;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.9375rem;
    position: relative;
}

.message.received {
    align-self: flex-start;
    background-color: var(--bg-body);
    border-bottom-left-radius: 4px;
}

.message.sent {
    align-self: flex-end;
    background-color: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-input-area {
    position: fixed;
    bottom: var(--nav-height);
    left: 0;
    width: 100%;
    padding: 10px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* SOS Button */
.sos-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--danger);
    color: white;
    font-size: 1.5rem;
    font-weight: 900;
    border: 4px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0.2);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* List Group */
.list-group {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.list-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

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

.list-icon {
    width: 24px;
    margin-right: 12px;
    color: var(--text-muted);
}

.list-arrow {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Profile Header */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 16px;
}

/* Placeholder View */
.placeholder-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    text-align: center;
    color: var(--text-muted);
    gap: 16px;
}

/* Desktop Tweaks */
@media (min-width: 768px) {
    main {
        margin-top: 20px;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        min-height: 80vh;
        background-color: var(--bg-card);
        box-shadow: var(--shadow-lg);
    }
    
    .bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    
    .modal {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .fab {
        right: calc(50% - 280px);
    }
}
