:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --primary-light: #81C784;
    --secondary: #8BC34A;
    --accent: #CDDC39;
    --background: #F5F5F5;
    --surface: #FFFFFF;
    --error: #F44336;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-disabled: #9E9E9E;
    --divider: #E0E0E0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.15);
    --shadow-lg: rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--surface);
    position: relative;
    overflow: hidden;
}

/* Top App Bar */
.app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 4px var(--shadow);
    z-index: 100;
    min-height: 56px;
}

.app-bar-title {
    font-size: 20px;
    font-weight: 500;
    flex: 1;
    text-align: center;
    margin: 0 8px;
}

.icon-button {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.icon-button:active {
    background: rgba(255, 255, 255, 0.2);
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--background);
    padding-bottom: 72px;
    -webkit-overflow-scrolling: touch;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease;
    padding: 16px;
    min-height: calc(100vh - 128px);
}

.screen.active {
    display: block;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-card:first-child {
    grid-column: 1 / -1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

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

.section-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.text-button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.text-button:active {
    opacity: 0.7;
}

/* Trail Cards */
.trail-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.trail-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px var(--shadow);
}

.trail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.trail-card-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.trail-card-location {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.difficulty-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.difficulty-badge.easy {
    background: #E8F5E9;
    color: #2E7D32;
}

.difficulty-badge.moderate {
    background: #FFF3E0;
    color: #E65100;
}

.difficulty-badge.hard {
    background: #FFEBEE;
    color: #C62828;
}

.trail-card-meta {
    display: flex;
    gap: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--divider);
}

.trail-card-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.trail-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

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

.button-icon:active {
    background: var(--divider);
}

/* Search Bar */
.search-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-bar {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
}

.search-input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 44px;
    border: none;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 2px 8px var(--shadow);
    font-size: 16px;
    color: var(--text-primary);
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 2px 12px var(--shadow-md);
}

.filter-button {
    width: 48px;
    height: 48px;
    border: none;
    background: var(--surface);
    color: var(--text-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow);
}

.filter-button:active {
    background: var(--divider);
}

/* Filter Chips */
.filter-chips {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 8px 16px;
    border-radius: 16px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--divider);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chip:active {
    transform: scale(0.95);
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    background: var(--surface);
    padding: 4px;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* List Items */
.list-container {
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    margin-bottom: 16px;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--divider);
    transition: background 0.2s;
}

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

.list-item:active {
    background: var(--background);
}

.list-avatar {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.list-chevron {
    color: var(--text-disabled);
    flex-shrink: 0;
}

/* Community */
.community-header {
    position: relative;
    margin: -16px -16px 16px -16px;
    overflow: hidden;
}

.community-banner {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.community-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 16px 16px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    color: white;
}

.community-info h2 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 4px;
}

.community-info p {
    font-size: 14px;
    opacity: 0.9;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    display: flex;
    gap: 12px;
}

.activity-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 14px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 4px;
}

.activity-time {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    min-height: 300px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    background: var(--background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--text-disabled);
}

.empty-state-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--divider);
    padding: 8px 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    min-height: 56px;
}

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

.nav-icon {
    flex-shrink: 0;
}

.nav-label {
    font-size: 12px;
    font-weight: 500;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 72px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 90;
}

.fab:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px var(--shadow-md);
}

@media (min-width: 480px) {
    .fab {
        right: calc(50% - 240px + 16px);
    }
}

/* Bottom Sheet */
.bottom-sheet {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: none;
    align-items: flex-end;
    animation: fadeIn 0.3s ease;
}

.bottom-sheet.active {
    display: flex;
}

.bottom-sheet-content {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

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

.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 8px;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.bottom-sheet-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Form */
.form {
    padding: 16px;
}

.input-group {
    position: relative;
    margin-bottom: 24px;
}

.input-field {
    width: 100%;
    padding: 16px 12px 8px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
}

.input-field:focus + .input-label,
.input-field:not(:placeholder-shown) + .input-label {
    transform: translateY(-8px) scale(0.85);
    color: var(--primary);
}

.input-label {
    position: absolute;
    left: 12px;
    top: 16px;
    font-size: 16px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: all 0.2s;
    transform-origin: left top;
    background: var(--surface);
    padding: 0 4px;
}

.input-label.select-label,
.input-label.date-label {
    transform: translateY(-8px) scale(0.85);
}

.input-field:focus + .input-label.select-label,
.input-field:focus + .input-label.date-label {
    color: var(--primary);
}

.button-primary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.button-primary:active {
    background: var(--primary-dark);
}

/* Detail View */
.detail-header {
    position: relative;
    padding: 16px;
    display: flex;
    justify-content: flex-end;
}

.detail-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 16px;
}

.detail-content {
    padding: 0 16px 24px;
}

.detail-title {
    font-size: 24px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.detail-location {
    font-size: 16px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}

.detail-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--background);
    border-radius: 12px;
}

.detail-meta-item {
    display: flex;
    flex-direction: column;
}

.detail-meta-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-meta-value {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

.detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}

.button-secondary {
    padding: 12px 24px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: transparent;
    color: var(--primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.button-secondary:active {
    background: rgba(76, 175, 80, 0.1);
}

.button-danger {
    padding: 12px 24px;
    border: 1px solid var(--error);
    border-radius: 8px;
    background: transparent;
    color: var(--error);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.button-danger:active {
    background: rgba(244, 67, 54, 0.1);
}

/* Dialog */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.dialog-overlay.active {
    display: flex;
}

.dialog {
    background: var(--surface);
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 8px 24px var(--shadow-lg);
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.dialog-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.dialog-message {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.button-text {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s;
}

.button-text:active {
    background: rgba(76, 175, 80, 0.1);
}

.button-text.danger {
    color: var(--error);
}

.button-text.danger:active {
    background: rgba(244, 67, 54, 0.1);
}

/* Snackbar */
.snackbar {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #323232;
    color: white;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px var(--shadow-lg);
    z-index: 400;
    transition: transform 0.3s ease;
    max-width: calc(100% - 32px);
}

.snackbar.active {
    transform: translateX(-50%) translateY(0);
}

/* Scrollbar */
.content-area::-webkit-scrollbar {
    width: 0;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    height: 140px;
    margin-bottom: 12px;
}

/* Responsive adjustments */
@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card:first-child {
        grid-column: 1;
    }
}

/* Utilities */
.text-center {
    text-align: center;
}

.hidden {
    display: none !important;
}
