/* iPhone 14 Pro Max 聊天界面样式 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    position: relative;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

/* 多层次背景动效 - 深色Mac风格 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 1200px 800px at 15% 25%, rgba(15, 23, 42, 0.9) 0%, rgba(30, 41, 59, 0.8) 20%, rgba(51, 65, 85, 0.6) 60%),
        radial-gradient(ellipse 800px 1200px at 85% 75%, rgba(17, 24, 39, 0.8) 0%, rgba(31, 41, 55, 0.7) 25%, rgba(55, 65, 81, 0.5) 70%),
        radial-gradient(ellipse 1000px 600px at 50% 5%, rgba(13, 71, 161, 0.15) 0%, rgba(10, 56, 128, 0.1) 30%, transparent 80%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 50%, rgba(51, 65, 85, 0.85) 100%);
    background-size: 800% 800%, 700% 700%, 900% 900%, 500% 500%;
    /* animation: macGradientLayer1 60s ease-in-out infinite; */
    z-index: -3;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 900px 1100px at 75% 20%, rgba(17, 24, 39, 0.7) 0%, rgba(31, 41, 55, 0.6) 35%, transparent 75%),
        radial-gradient(ellipse 1100px 700px at 25% 80%, rgba(15, 23, 42, 0.8) 0%, rgba(30, 41, 59, 0.6) 40%, transparent 85%),
        linear-gradient(45deg, rgba(13, 71, 161, 0.08) 0%, rgba(10, 56, 128, 0.05) 100%);
    background-size: 600% 600%, 750% 750%, 400% 400%;
    /* animation: macGradientLayer2 45s ease-in-out infinite reverse; */
    z-index: -2;
}

/* 主背景层 */
.mac-gradient-base {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 700px 500px at 40% 60%, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 25%, rgba(51, 65, 85, 0.7) 65%),
        radial-gradient(ellipse 600px 900px at 60% 40%, rgba(17, 24, 39, 0.9) 0%, rgba(31, 41, 55, 0.8) 30%, rgba(55, 65, 81, 0.6) 70%),
        linear-gradient(90deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.95) 50%, rgba(51, 65, 85, 0.9) 100%);
    background-size: 500% 500%, 650% 650%, 300% 300%;
    animation: macGradientBase 120s ease-in-out infinite;
    z-index: -4;
}

/* Mac风格多层次动画关键帧 */
@keyframes macGradientLayer1 {
    0% { 
        background-position: 0% 20%, 100% 80%, 50% 0%, 0% 50%;
        transform: rotate(0deg) scale(1);
    }
    25% { 
        background-position: 30% 60%, 70% 40%, 80% 30%, 25% 75%;
        transform: rotate(1deg) scale(1.02);
    }
    50% { 
        background-position: 100% 100%, 0% 0%, 20% 80%, 50% 50%;
        transform: rotate(0deg) scale(1);
    }
    75% { 
        background-position: 70% 30%, 30% 70%, 90% 10%, 75% 25%;
        transform: rotate(-1deg) scale(0.98);
    }
    100% { 
        background-position: 0% 20%, 100% 80%, 50% 0%, 0% 50%;
        transform: rotate(0deg) scale(1);
    }
}

@keyframes macGradientLayer2 {
    0% { 
        background-position: 100% 0%, 0% 100%, 50% 50%;
        opacity: 0.8;
    }
    33% { 
        background-position: 20% 80%, 80% 20%, 10% 90%;
        opacity: 1;
    }
    66% { 
        background-position: 80% 20%, 20% 80%, 90% 10%;
        opacity: 0.9;
    }
    100% { 
        background-position: 100% 0%, 0% 100%, 50% 50%;
        opacity: 0.8;
    }
}

@keyframes macGradientBase {
    0% { 
        background-position: 50% 50%, 0% 0%, 0% 0%;
        filter: hue-rotate(0deg) brightness(1);
    }
    20% { 
        background-position: 80% 20%, 30% 70%, 25% 25%;
        filter: hue-rotate(5deg) brightness(1.05);
    }
    40% { 
        background-position: 20% 80%, 70% 30%, 50% 50%;
        filter: hue-rotate(10deg) brightness(1.1);
    }
    60% { 
        background-position: 90% 10%, 10% 90%, 75% 75%;
        filter: hue-rotate(5deg) brightness(1.05);
    }
    80% { 
        background-position: 10% 90%, 90% 10%, 25% 75%;
        filter: hue-rotate(-5deg) brightness(0.95);
    }
    100% { 
        background-position: 50% 50%, 0% 0%, 0% 0%;
        filter: hue-rotate(0deg) brightness(1);
    }
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    25% { background-position: 100% 50%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
    100% { background-position: 0% 50%; }
}

/* iPhone 容器 */
.iphone-container {
    position: relative;
    transform: scale(1.1);
    transform-origin: center;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 70px;
    padding: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* iPhone 外框 - 基于真实尺寸比例 */
.iphone-frame {
    width: 388px; /* 77.6mm * 5 */
    height: 803px; /* 160.7mm * 5 */
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 55px;
    padding: 8px;
    position: relative;
    box-shadow: 
        0 0 0 2px rgba(255, 255, 255, 0.1),
        0 20px 40px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* 动态岛 */
.dynamic-island {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 37px;
    background: #000;
    border-radius: 19px;
    z-index: 10;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* MarsMind Logo */
.marsmind-logo {
    height: 28px;
    width: auto;
    max-width: 110px;
    opacity: 0.9;
    filter: brightness(1.1);
    object-fit: contain;
}

/* iPhone 屏幕区域 */
.iphone-screen {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 47px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 状态栏 */
.status-bar {
    height: 54px;
    background: #000;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    font-size: 17px;
    font-weight: 600;
    position: relative;
    z-index: 5;
}

.status-left .time {
    font-variant-numeric: tabular-nums;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.signal-bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
}

.signal-bars .bar {
    width: 3px;
    background: white;
    border-radius: 1px;
}

.signal-bars .bar:nth-child(1) { height: 4px; }
.signal-bars .bar:nth-child(2) { height: 6px; }
.signal-bars .bar:nth-child(3) { height: 8px; }
.signal-bars .bar:nth-child(4) { height: 10px; }



.battery {
    width: 24px;
    height: 12px;
    border: 1px solid white;
    border-radius: 2px;
    position: relative;
}

.battery::after {
    content: '';
    position: absolute;
    right: -3px;
    top: 3px;
    width: 2px;
    height: 6px;
    background: white;
    border-radius: 0 1px 1px 0;
}

.battery-level {
    width: 80%;
    height: 100%;
    background: white;
    border-radius: 1px;
}

/* 微信导航栏 */
.wechat-header {
    height: 64px;
    background: #ffffff;
    border-bottom: 1px solid #e8eaf0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-left, .header-right {
    width: 60px;
    display: flex;
    justify-content: center;
}

.refresh-btn, .more-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #576b95;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.refresh-btn:hover, .more-btn:hover {
    background-color: rgba(87, 107, 149, 0.1);
}

.header-center {
    flex: 1;
    text-align: center;
}

.contact-name {
    font-size: 17px;
    font-weight: 600;
    color: #000;
    line-height: 1.2;
}

.contact-status {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

/* 聊天容器 */
.chat-container {
    flex: 1;
    background: #f0f2f5;
    overflow: hidden;
    position: relative;
}

/* External Brand Info Styles */
.brand-info-external {
    position: relative;
    margin-top: 20px;
    text-align: center;
    z-index: 1000;
}

.brand-logo-line {
    margin-bottom: 2px;
    text-align: center;
    padding: 0;
}

.brand-logo {
    height: 20px;
    width: auto;
    opacity: 0.7;
    filter: brightness(1.1);
}

.brand-text-line {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    letter-spacing: 0.3px;
    writing-mode: horizontal-tb;
    white-space: nowrap;
    text-align: center;
    padding: 0;
}

.brand-text-external #brandName {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    letter-spacing: 0.2px;
}

.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

/* 消息项 */
.message-item {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
}

.message-item.sent {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    margin: 0 12px;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
}

.message-item.sent .message-content {
    align-items: flex-end;
}

.message-bubble {
    background: #ffffff;
    border-radius: 16px;
    padding: 12px 16px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    word-wrap: break-word;
    border: 1px solid #f0f2f5;
}

.message-item.sent .message-bubble {
    background: #576b95;
    color: white;
    border-color: #576b95;
}

.message-item.sent .message-text {
    color: white;
}

.message-item.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-bubble::before {
    content: '';
    position: absolute;
    top: 12px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
}

.message-item.received .message-bubble::before {
    left: -12px;
    border-right-color: #ffffff;
}

.message-item.sent .message-bubble::before {
    right: -12px;
    border-left-color: #576b95;
}

.message-text {
    font-size: 16px;
    line-height: 1.4;
    color: #000;
    margin-bottom: 4px;
}

.message-time {
    display: none;
}

.message-item.received .message-time {
    display: none;
}

/* 加载动效 */
.message-bubble.loading {
    position: relative;
    overflow: hidden;
}

.message-bubble.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: loading-shimmer 1.5s infinite;
}

.message-item.sent .message-bubble.loading::after {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
}

@keyframes loading-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: loading-bounce 1.4s infinite ease-in-out;
}

.message-item.sent .loading-dot {
    background: rgba(255, 255, 255, 0.7);
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 输入区域 */
.chat-input-area {
    background: #ffffff;
    border-top: 1px solid #e8eaf0;
    padding: 12px 16px 34px; /* 底部留出安全区域 */
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8eaf0;
    transition: all 0.3s ease;
}

.input-container:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-color: #d0d7de;
}

.input-container:focus-within {
    box-shadow: 0 4px 20px rgba(87, 107, 149, 0.15);
    border-color: #576b95;
    background: #ffffff;
}

.text-input-wrapper {
    flex: 1;
    position: relative;
}

.message-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 12px 18px;
    border-radius: 20px;
    background: transparent;
    color: #333;
    transition: all 0.3s ease;
    line-height: 1.4;
}

.message-input::placeholder {
    color: #8b949e;
    transition: color 0.3s ease;
}

.message-input:focus::placeholder {
    color: #a8b3c1;
}

.send-btn {
    background: #576b95;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(87, 107, 149, 0.3);
    min-width: 60px;
}

.send-btn:hover {
    background: #4a5d84;
    box-shadow: 0 4px 12px rgba(87, 107, 149, 0.4);
    transform: translateY(-1px);
}

.send-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(87, 107, 149, 0.3);
}

.send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* 加载指示器 */
.loading-indicator {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 100;
}

.loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    animation: loading-bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .iphone-container {
        transform: scale(0.9);
    }
    
    body {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .iphone-container {
        transform: scale(0.85);
    }
    
    body {
        padding: 10px;
    }
}

@media (max-width: 390px) {
    .iphone-container {
        transform: scale(0.8);
    }
    
    body {
        padding: 5px;
    }
}

@media (max-width: 360px) {
    .iphone-container {
        transform: scale(0.75);
    }
    
    body {
        padding: 5px;
    }
}

/* 打字效果 */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #000;
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 消息发送动画 */
.message-item.sending {
    opacity: 0.6;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.message-item.sent-complete {
    opacity: 1;
    transform: translateY(0);
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    .iphone-frame {
        background: linear-gradient(145deg, #0a0a0a, #1a1a1a);
    }
    
    .wechat-header {
        background: #1c1c1e;
        border-bottom-color: #2c2c2e;
    }
    
    .contact-name {
        color: #fff;
    }
    
    .chat-container {
        background: #000;
    }
    
    .message-bubble {
        background: #1c1c1e;
        color: #fff;
    }
    
    .message-item.sent .message-bubble {
        background: #007aff;
    }
    
    .chat-input-area {
        background: #1c1c1e;
        border-top-color: #2c2c2e;
    }
    
    .input-container {
        background: #2c2c2e;
    }
    
    .message-input {
        background: #3a3a3c;
        color: #fff;
    }
    
    .message-input:focus {
        background: #48484a;
    }
}