/* ===================
   Gravity - CSS 樣式
   簡約現代風格
   =================== */

:root {
    /* 主色調 - 深灰黑強調色 */
    --primary: #1a1a1a;
    --primary-dark: #000000;
    --primary-light: #333333;

    /* 背景色 - 純白/淺灰 */
    --bg-main: #ffffff;
    --bg-card: #f8f9fa;
    --bg-input: #f1f3f4;

    /* 文字色 - 黑灰層次 */
    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;

    /* 強調色 */
    --accent-primary: #1a73e8;
    --accent-success: #34a853;
    --accent-warning: #fbbc04;
    --accent-error: #ea4335;

    /* 邊框色 */
    --border-color: #e8eaed;
    --border-color-hover: #dadce0;

    /* 間距 */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* 圓角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* 陰影 - 柔和 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

    /* 高度 */
    --header-height: 56px;
    --bottom-nav-height: 64px;
}

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

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* 載入畫面 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    z-index: 1000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-input);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* App 容器 */
.app-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: var(--header-height);
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

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

/* 地圖 */
.map-container {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
}

/* 地圖 Marker 樣式 */
.event-marker {
    background: var(--primary);
    border: 3px solid white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.event-marker.full {
    background: var(--accent-warning);
}

/* 底部導覽 */
.bottom-nav {
    height: var(--bottom-nav-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--spacing-sm);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

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

.nav-icon {
    font-size: 24px;
}

.nav-item-create {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    margin-top: -20px;
    box-shadow: var(--shadow-md);
}

.nav-item-create .nav-icon {
    font-size: 24px;
}

/* FAB */
.fab {
    position: fixed;
    right: var(--spacing-lg);
    bottom: calc(var(--bottom-nav-height) + var(--spacing-lg));
    z-index: 50;
}

.fab-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s;
}

.fab-button:hover {
    transform: scale(1.1);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 85vh;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen {
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
}

.modal-header {
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close,
.btn-back {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.modal-body {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--spacing-md);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 按鈕 */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-block {
    width: 100%;
}

/* 表單 */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
}

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

/* Chip Group */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.chip {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Event Info */
.event-types {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

.event-type-badge {
    padding: 2px 8px;
    background: var(--primary);
    border-radius: var(--radius-full);
    font-size: 12px;
}

.event-meta p {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

.event-host {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-top: var(--spacing-md);
}

/* 聊天室 */
.chat-messages {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.message {
    max-width: 80%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    background: var(--bg-input);
}

.message.sent {
    align-self: flex-end;
    background: var(--primary);
}

.message-sender {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.message-content {
    font-size: 14px;
    line-height: 1.4;
}

.message-time {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

.chat-input-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-card);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-container input {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-input);
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 14px;
}

.btn-emoji,
.btn-send {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
}

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

/* 選中位置 */
.selected-location {
    padding: var(--spacing-md);
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.selected-location .placeholder {
    color: var(--text-muted);
}

/* 響應式 */
@media (min-width: 768px) {
    .modal-content:not(.modal-fullscreen) {
        border-radius: var(--radius-lg);
        margin-bottom: 10vh;
    }
}

/* 安全區域 */
@supports(padding: max(0px)) {
    .app-container {
        padding-top: env(safe-area-inset-top);
    }

    .bottom-nav {
        padding-bottom: max(var(--spacing-sm), env(safe-area-inset-bottom));
    }
}