:root {
  --bg-dark: #0a0e14;
  --bg-sidebar: #111822;
  --bg-chat-header: #17212e;
  --bg-chat-body: #0d131c;
  --bg-input: #1f2c3e;
  --bg-msg-in: #1c2838;
  --bg-msg-out: #005c4b;
  --accent-cyan: #00b0ff;
  --accent-emerald: #00e676;
  --accent-gradient: linear-gradient(135deg, #00e676 0%, #00b0ff 100%);
  --text-main: #f0f4f8;
  --text-muted: #8a99ad;
  --border-color: #1e2b3c;
  --modal-bg: #141d29;
  --font-family: 'Outfit', 'Segoe UI', Tahoma, sans-serif;
}

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

html, body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: fixed;
}

/* App Container */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 380px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
  flex-shrink: 0;
}

.sidebar-header {
  height: 66px;
  background-color: var(--bg-chat-header);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #090e14;
  box-shadow: 0 4px 14px rgba(0, 230, 118, 0.3);
}

.brand-title h3 {
  font-size: 15.5px;
  font-weight: 600;
}

.brand-title span {
  font-size: 11px;
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn:hover, .icon-btn:active {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* Search */
.sidebar-search {
  padding: 10px 14px;
  background-color: var(--bg-dark);
  flex-shrink: 0;
}

.search-wrapper {
  background-color: var(--bg-input);
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid transparent;
}

.search-wrapper:focus-within {
  border-color: var(--accent-emerald);
}

.search-wrapper i {
  color: var(--text-muted);
  font-size: 14px;
}

.search-wrapper input {
  width: 100%;
  padding: 10px 10px;
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 14px;
  font-family: var(--font-family);
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.2s;
  border-left: 3px solid transparent;
}

.chat-item:hover, .chat-item.active {
  background-color: var(--bg-chat-header);
  border-left-color: var(--accent-emerald);
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1c2838, #2a3b50);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent-emerald);
  margin-right: 12px;
  flex-shrink: 0;
}

.chat-details {
  flex: 1;
  min-width: 0;
}

.chat-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.chat-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-time {
  font-size: 11.5px;
  color: var(--text-muted);
}

.chat-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-last-msg {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  background: var(--accent-gradient);
  color: #090e14;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
}

/* Main Chat Area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-chat-body);
  position: relative;
  overflow: hidden;
}

.empty-chat-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

.empty-logo {
  width: 80px;
  height: 80px;
  background: var(--accent-gradient);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #090e14;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 230, 118, 0.3);
}

.empty-chat-state h2 {
  font-size: 22px;
  color: var(--text-main);
  margin-bottom: 8px;
}

.empty-chat-state p {
  font-size: 13.5px;
  max-width: 360px;
  line-height: 1.5;
}

.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.chat-header {
  height: 66px;
  background-color: var(--bg-chat-header);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.back-btn {
  display: none;
  margin-right: 8px;
}

.chat-header-info {
  margin-left: 10px;
}

.chat-header-info h4 {
  font-size: 15.5px;
  font-weight: 600;
}

.chat-header-info span {
  font-size: 11.5px;
  color: var(--accent-cyan);
}

/* Messages Body */
.messages-container {
  flex: 1;
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  background-image: 
    radial-gradient(rgba(0, 230, 118, 0.03) 1px, transparent 0),
    radial-gradient(rgba(0, 176, 255, 0.03) 1px, transparent 0);
  background-size: 24px 24px;
}

.msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.msg-bubble.inbound {
  align-self: flex-start;
  background-color: var(--bg-msg-in);
  border-top-left-radius: 2px;
}

.msg-bubble.outbound {
  align-self: flex-end;
  background-color: var(--bg-msg-out);
  border-top-right-radius: 2px;
  color: #ffffff;
}

.msg-meta {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.65);
  text-align: right;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Media Elements inside Messages */
.msg-media-image img {
  max-width: 100%;
  max-height: 250px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
}

.msg-media-video video {
  max-width: 100%;
  max-height: 250px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.msg-media-audio audio {
  width: 220px;
  height: 38px;
  outline: none;
  margin-bottom: 4px;
}

.msg-media-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.msg-media-doc i {
  font-size: 22px;
  color: var(--accent-emerald);
}

.msg-media-doc a {
  color: var(--accent-emerald);
  text-decoration: none;
  font-weight: 500;
  font-size: 12.5px;
  word-break: break-all;
}

/* Footer / Input Bar (ALWAYS VISIBLE STICKY FOOTER) */
.chat-footer {
  min-height: 64px;
  background-color: var(--bg-chat-header);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 50;
  width: 100%;
}

.chat-input-wrapper {
  flex: 1;
  background-color: var(--bg-input);
  border-radius: 20px;
  padding: 2px 12px;
  display: flex;
  align-items: center;
  min-width: 0;
}

.chat-input-wrapper input {
  width: 100%;
  padding: 8px 4px;
  background: transparent;
  border: none;
  color: var(--text-main);
  outline: none;
  font-size: 14.5px;
  font-family: var(--font-family);
}

.send-btn {
  background: var(--accent-gradient);
  color: #090e14;
  box-shadow: 0 4px 12px rgba(0, 230, 118, 0.3);
  font-weight: bold;
}

/* Recording Indicator */
.recording-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ff4b4b;
  font-weight: 600;
  font-size: 13.5px;
}

.recording-dot {
  width: 10px;
  height: 10px;
  background-color: #ff4b4b;
  border-radius: 50%;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.25); }
  100% { opacity: 1; transform: scale(1); }
}

/* Attachment Menu */
.attachment-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  padding: 6px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
  flex-shrink: 0;
}

.attachment-preview span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: var(--modal-bg);
  border-radius: 18px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,0.8);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.modal-body {
  padding: 18px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-main);
  font-size: 13.5px;
  outline: none;
  font-family: var(--font-family);
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent-emerald);
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.btn-small {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-family);
}

.info-box {
  background: rgba(0, 230, 118, 0.08);
  border-left: 3px solid var(--accent-emerald);
  padding: 12px;
  border-radius: 6px;
  font-size: 12.5px;
  margin-bottom: 16px;
  line-height: 1.45;
}

.info-box code {
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--accent-cyan);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent-gradient);
  color: #090e14;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14.5px;
  font-family: var(--font-family);
  box-shadow: 0 4px 16px rgba(0, 230, 118, 0.3);
}

/* Toast Notifications */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--accent-gradient);
  color: #090e14;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  font-size: 13.5px;
  z-index: 2000;
  display: none;
}

/* MOBILE SCREEN (FULL WIDTH & FLEXIBLY VISIBLE INPUT BAR) */
@media (max-width: 768px) {
  .app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
  }

  .sidebar {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  .chat-area {
    width: 100%;
    height: 100%;
  }

  .back-btn {
    display: flex;
  }

  .msg-bubble {
    max-width: 88%;
  }

  .chat-footer {
    padding: 8px 10px;
    gap: 6px;
  }

  .icon-btn {
    padding: 6px;
    font-size: 17px;
  }
}
