*{margin:0;padding:0;box-sizing:border-box}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;background:#f5f5f5;height:100vh;overflow:hidden}

.login-container{display:flex;align-items:center;justify-content:center;height:100vh;background:#000}
.login-box{background:#fff;padding:48px;border-radius:16px;box-shadow:0 20px 60px rgba(0,0,0,.3);text-align:center;max-width:400px;width:90%}
.login-box h1{margin-bottom:8px;font-size:28px;color:#333}
.login-box p{color:#888;margin-bottom:24px}
.login-box .error{background:#fee;color:#c00;padding:10px;border-radius:8px;margin-bottom:16px;font-size:14px}
.login-box input{width:100%;padding:14px 18px;border:2px solid #e0e0e0;border-radius:12px;font-size:16px;outline:none;margin-bottom:16px;transition:border-color .2s}
.login-box input:focus{border-color:#007AFF}
.login-box button{width:100%;padding:14px;background:#007AFF;color:#fff;border:none;border-radius:12px;font-size:16px;font-weight:600;cursor:pointer;transition:background .2s}
.login-box button:hover{background:#0056CC}

.app-container{display:flex;height:100vh;background:#fff}

.sidebar{width:350px;min-width:350px;border-right:1px solid #e0e0e0;display:flex;flex-direction:column;background:#f9f9f9}
.sidebar-header{padding:16px 20px;border-bottom:1px solid #e0e0e0;display:flex;align-items:center;justify-content:space-between;background:#fff}
.sidebar-header h2{font-size:22px;color:#333}
.sidebar-actions{display:flex;gap:8px}
.sidebar-actions button{padding:6px 12px;border:1px solid #ddd;border-radius:8px;background:#fff;cursor:pointer;font-size:14px;transition:background .2s}
.sidebar-actions button:hover{background:#f0f0f0}
.new-conversation{padding:12px 16px;border-bottom:1px solid #e0e0e0;display:flex;gap:8px;background:#fff}
.new-conversation input{flex:1;padding:10px 14px;border:2px solid #e0e0e0;border-radius:10px;font-size:15px;outline:none;transition:border-color .2s}
.new-conversation input:focus{border-color:#007AFF}
.new-conversation button{padding:10px 16px;background:#007AFF;color:#fff;border:none;border-radius:10px;font-size:16px;cursor:pointer;transition:background .2s}
.new-conversation button:hover{background:#0056CC}
.conversation-list{flex:1;overflow-y:auto}
.conversation-item{padding:14px 20px;border-bottom:1px solid #f0f0f0;cursor:pointer;transition:background .15s}
.conversation-item:hover{background:#edf2ff}
.conversation-item.active{background:#007AFF}
.conversation-item.active .conv-number,
.conversation-item.active .conv-preview,
.conversation-item.active .conv-time{color:#fff!important}
.conv-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}
.conv-number{font-weight:600;font-size:15px;color:#333}
.conv-time{font-size:12px;color:#999}
.conv-preview{font-size:14px;color:#888;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:260px}

.chat-area{flex:1;display:flex;flex-direction:column;background:#fff}
.chat-placeholder{flex:1;display:flex;align-items:center;justify-content:center}
.placeholder-content{text-align:center;color:#999}
.placeholder-icon{font-size:64px;display:block;margin-bottom:16px}
.placeholder-content p{font-size:16px;max-width:300px}
.chat-header{padding:16px 24px;border-bottom:1px solid #e0e0e0;font-size:18px;font-weight:600;color:#333;background:#fff;display:flex;align-items:center;gap:12px}
.chat-header .back-btn{display:none;background:none;border:none;font-size:22px;cursor:pointer;padding:0 8px 0 0;color:#007AFF}
.chat-header .avatar{width:36px;height:36px;border-radius:50%;background:#007AFF;color:#fff;display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:600;flex-shrink:0}

.messages-container{flex:1;overflow-y:auto;padding:20px 24px;display:flex;flex-direction:column;gap:4px}
.date-separator{text-align:center;margin:16px 0 8px;font-size:12px;color:#999;font-weight:500}
.message-wrapper{display:flex;flex-direction:column;max-width:65%}
.message-wrapper.sent{align-self:flex-end;align-items:flex-end}
.message-wrapper.received{align-self:flex-start;align-items:flex-start}
.message-bubble{padding:10px 16px;border-radius:20px;line-height:1.4;font-size:16px;word-wrap:break-word;white-space:pre-wrap}
.message-wrapper.sent .message-bubble{background:#007AFF;color:#fff;border-bottom-right-radius:6px}
.message-wrapper.received .message-bubble{background:#E9E9EB;color:#000;border-bottom-left-radius:6px}
.message-meta{font-size:11px;color:#999;margin-top:2px;padding:0 4px}

.input-area{padding:12px 24px 24px;border-top:1px solid #e0e0e0;display:flex;gap:12px;align-items:flex-end;background:#fff}
.input-area textarea{flex:1;padding:12px 18px;border:2px solid #e0e0e0;border-radius:22px;font-size:16px;font-family:inherit;outline:none;resize:none;max-height:120px;line-height:1.4;transition:border-color .2s}
.input-area textarea:focus{border-color:#007AFF}
.send-btn{width:44px;height:44px;border-radius:50%;background:#007AFF;color:#fff;border:none;font-size:20px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .2s;flex-shrink:0}
.send-btn:hover{background:#0056CC}
.send-btn:disabled{background:#ccc;cursor:not-allowed}

.toast{position:fixed;top:20px;right:20px;padding:14px 24px;border-radius:12px;color:#fff;font-weight:500;z-index:1000;animation:slideIn .3s ease,fadeOut .3s ease 2.7s forwards;box-shadow:0 4px 12px rgba(0,0,0,.15)}
.toast.success{background:#34C759}
.toast.error{background:#FF3B30}
.toast.info{background:#007AFF}
@keyframes slideIn{from{transform:translateX(100px);opacity:0}to{transform:translateX(0);opacity:1}}
@keyframes fadeOut{to{opacity:0}}

.spinning{animation:spin 1s linear infinite;display:inline-block}
@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}

@media(max-width:768px){
  .sidebar{width:100%;min-width:100%}
  .chat-area{display:none;width:100%}
  .app-container.chat-open .sidebar{display:none}
  .app-container.chat-open .chat-area{display:flex}
  .app-container.chat-open .chat-header .back-btn{display:inline}
  .message-wrapper{max-width:85%}
}
.login-logo{max-width:220px;margin-bottom:24px}

.attach-btn{width:44px;height:44px;border-radius:50%;background:#f0f0f0;border:none;font-size:20px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .2s;flex-shrink:0}
.attach-btn:hover{background:#e0e0e0}
.attachment-preview{display:flex;gap:8px;padding:8px 24px;border-top:1px solid #e0e0e0;overflow-x:auto;background:#fafafa}
.preview-item{position:relative;width:80px;height:80px;flex-shrink:0;border-radius:10px;overflow:hidden;border:1px solid #ddd}
.preview-item img{width:100%;height:100%;object-fit:cover}
.preview-remove{position:absolute;top:2px;right:2px;width:22px;height:22px;border-radius:50%;background:rgba(0,0,0,.6);color:#fff;border:none;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}
.chat-media{max-width:100%;max-height:300px;border-radius:12px;margin-bottom:4px;cursor:pointer;display:block}
video.chat-media{cursor:default}
.lightbox{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.92);display:flex;align-items:center;justify-content:center;z-index:2000;cursor:pointer}
.lightbox img{max-width:92%;max-height:92%;object-fit:contain;border-radius:4px}
