/* Reset & Base */
:root {
    --bg-color: #f5f5f7;
    --white: #ffffff;
    --black: #1d1d1f;
    --gray-light: #e5e5ea;
    --gray-text: #86868b;
    --accent: #000000; /* 高级黑 */
    --accent-text: #ffffff;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 8px;
    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--black);
    height: 100vh; /* Fallback */
    height: 100dvh; /* Mobile viewport fix */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 480px; /* 手机尺寸感 */
    height: 100%;
    max-height: 900px;
    background: var(--white);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

@media (min-width: 500px) {
    .app-container {
        height: 90vh;
        border-radius: var(--radius-lg);
    }
}

/* Header */
.chat-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #34c759;
    border-radius: 50%;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--black);
    opacity: 0.6;
    transition: opacity 0.2s;
}

.icon-btn:hover {
    opacity: 1;
}

/* Chat Window */
.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    margin-top: 40px;
    color: var(--gray-text);
    opacity: 0.6;
}

.welcome-message p {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 4px;
}

.welcome-message small {
    font-size: 12px;
}

/* Messages */
.message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeIn 0.3s ease-out;
}

.message-content {
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.message-meta {
    font-size: 11px;
    color: var(--gray-text);
    margin: 0 4px;
}

/* Self Messages (Right) */
.message.self {
    align-self: flex-end;
    align-items: flex-end;
}

.message.self .message-content {
    background-color: var(--accent);
    color: var(--accent-text);
    border-bottom-right-radius: 4px;
}

/* Other Messages (Left) */
.message.other {
    align-self: flex-start;
    align-items: flex-start;
}

.message.other .message-content {
    background-color: var(--gray-light);
    color: var(--black);
    border-bottom-left-radius: 4px;
}

/* Image Messages */
.message-img {
    max-width: 100%;
    border-radius: var(--radius-md);
    display: block;
}

/* Input Area */
.input-area {
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom)); /* 适配 iPhone 底部横条 */
    background: var(--white);
    border-top: 1px solid rgba(0,0,0,0.05);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gray-light);
    padding: 8px 8px 8px 16px;
    border-radius: 24px;
    transition: background 0.2s;
}

.input-wrapper:focus-within {
    background: #eef0f2;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

#message-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 15px;
    color: var(--black);
    font-family: var(--font-family);
}

.send-btn {
    background: var(--accent);
    color: var(--white);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Modal */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius-lg);
    width: 80%;
    max-width: 320px;
    box-shadow: var(--shadow-md);
    transform: scale(1);
    transition: transform 0.3s;
}

.modal-overlay.hidden .modal {
    transform: scale(0.95);
}

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

.modal input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 16px;
    outline: none;
}

.modal input:focus {
    border-color: var(--black);
}

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

.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

.btn.primary {
    background: var(--black);
    color: var(--white);
}

.btn.secondary {
    background: var(--gray-light);
    color: var(--black);
}

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

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
}
