/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, #2c3e50, #1a252f);
    color: white;
    padding: 1.2rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
    width: 100%;
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-left: 1.5rem;
}

header h1 {
    font-size: 2.2rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(90deg, #ffffff, #e0e0e0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    font-family: 'Jumble', cursive;
}

header p {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-top: 0.2rem;
    font-weight: 300;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding-right: 1.5rem;
}

.help-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.help-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#auth-buttons, #user-status {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

#auth-buttons button, #user-status button {
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#auth-buttons button:hover, #user-status button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#login-btn {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

#login-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#register-btn {
    background-color: #3498db;
}

#register-btn:hover {
    background-color: #2980b9;
}

.hidden {
    display: none !important;
}

/* 主要内容区域 */
main {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 150px); /* 增加减去的高度，为footer留出更多空间 */
    padding: 1rem;
    gap: 1rem;
    margin-bottom: 50px; /* 添加底部边距，确保内容不被footer遮挡 */
}

/* 地图容器 */
#map-container {
    flex: 2;
    min-width: 300px;
    height: calc(100vh - 152px); /* 调整高度计算，为footer留出空间 */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10; /* 确保低于footer的z-index */
}

#map {
    width: 100%;
    flex: 1;
    border-radius: 8px;
}

/* 消息面板 */
#message-panel {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: calc(100vh - 152px); /* 与地图容器使用相同的高度计算 */
    position: relative;
    z-index: 10; /* 与map-container保持相同的z-index */
}

/* 消息表单 */
#message-form {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#message-form h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.2rem;
}

#message-input {
    width: 100%;
    height: 100px;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
}

button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: #2c3e50;
    color: white;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #34495e;
}

#send-button {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

/* 消息列表 */
#message-list {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-grow: 1;
    overflow-y: auto;
}

#message-list h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.2rem;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid #2c3e50;
}

.message .content {
    margin-bottom: 0.5rem;
}

.message .meta {
    font-size: 0.85rem;
    color: #666;
}

/* 底部样式 */
footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 1rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000; /* 增加z-index值，确保显示在所有内容之上 */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); /* 添加顶部阴影，提升层次感 */
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* 错误消息样式 */
.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 0.75rem;
    border-radius: 4px;
    border-left: 4px solid #c62828;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

button.close-modal {
    background-color: #95a5a6;
}

button.close-modal:hover {
    background-color: #7f8c8d;
}

#logout-btn {
    background-color: #e74c3c;
}

#logout-btn:hover {
    background-color: #c0392b;
}

/* Toast通知样式 */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    pointer-events: none;
}

.toast {
    background-color: #2c3e50;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-in-out;
    pointer-events: auto;
    max-width: 350px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-error {
    background-color: #e74c3c;
    border-left: 4px solid #c0392b;
}

.toast-success {
    background-color: #2ecc71;
    border-left: 4px solid #27ae60;
}

.toast-info {
    background-color: #3498db;
    border-left: 4px solid #2980b9;
}

.toast-warning {
    background-color: #f1c40f;
    border-left: 4px solid #f39c12;
    color: #333;
}

/* 响应式设计 */
@media (max-width: 768px) {
    main {
        flex-direction: column;
        height: auto;
        padding: 0.5rem;
        margin-bottom: 60px; /* 增加底部边距，避免被footer遮挡 */
    }

    #map-container {
        height: calc(100vh - 350px); /* 调整为更大的高度，确保地图可见性 */
        min-height: 400px; /* 设置最小高度，确保地图不会太小 */
        margin-bottom: 1rem;
        /* z-index已在全局设置，无需在此重复 */
    }

    #message-panel {
        max-width: none;
        height: auto;
        margin-bottom: 20px; /* 添加底部边距 */
        /* z-index已在全局设置，无需在此重复 */
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0.5rem;
    }

    .header-left {
        align-items: center;
        margin-bottom: 1rem;
        padding-left: 0;
    }

    .header-right {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        padding-right: 0;
    }

    #user-status, #auth-buttons {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
        justify-content: center;
        width: 100%;
    }

    .help-link {
        margin-top: 0.5rem;
    }

    button {
        padding: 0.5rem 1rem;
        min-width: 80px;
    }

    #toast-container {
        width: calc(100% - 40px);
        right: 20px;
    }

    .toast {
        width: 100%;
    }
}