/* ============================================
   TELEGRAM-STYLE MESSENGER
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Telegram Colors */
  --tg-primary: #3390ec;
  --tg-primary-hover: #2b7fd1;
  --tg-primary-light: #e3f2fd;
  --tg-bg: #0e1621;
  --tg-bg-secondary: #17212b;
  --tg-bg-tertiary: #242f3d;
  --tg-bg-hover: #2b5278;
  --tg-text: #ffffff;
  --tg-text-secondary: #7aa3c1;
  --tg-text-muted: #5d7a91;
  --tg-border: #0e1621;
  --tg-message-out: #2b5278;
  --tg-message-in: #182533;
  --tg-online: #0ac630;
  --tg-mention: #c6e0f5;
  
  /* Spacing */
  --tg-sidebar-width: 420px;
  --tg-header-height: 64px;
  --tg-input-height: 56px;
  
  /* Transitions */
  --tg-transition: 0.2s ease;
}

/* ============================================
   BASE
   ============================================ */

html {
  font-size: 16px;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--tg-bg);
  color: var(--tg-text);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100vh;
  display: flex;
}

/* ============================================
   AUTH SCREEN - Telegram Style
   ============================================ */

#auth-screen {
  display: none;
  width: 100%;
  height: 100%;
  background: var(--tg-bg);
  justify-content: center;
  align-items: center;
}

#auth-screen.active {
  display: flex;
}

.auth-container {
  width: 100%;
  max-width: 360px;
  padding: 2rem;
  text-align: center;
}

.auth-logo {
  margin-bottom: 2rem;
}

.logo-icon {
  width: 160px;
  height: 160px;
  margin: 0 auto 1.5rem;
  background: linear-gradient(135deg, #59c7f9 0%, #3390ec 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  box-shadow: 0 4px 20px rgba(51, 144, 236, 0.3);
  animation: logoPulse 2s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.auth-container h1 {
  font-size: 2rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--tg-text);
}

.subtitle {
  color: var(--tg-text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  background: var(--tg-bg-tertiary);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: none;
  color: var(--tg-text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--tg-transition);
}

.tab-btn:hover {
  color: var(--tg-text);
}

.tab-btn.active {
  background: var(--tg-primary);
  color: white;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: formFadeIn 0.3s ease;
}

@keyframes formFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Form Elements */
.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--tg-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--tg-bg-tertiary);
  border: 2px solid transparent;
  border-radius: 8px;
  color: var(--tg-text);
  font-size: 1rem;
  transition: all var(--tg-transition);
  outline: none;
}

.form-group input::placeholder {
  color: var(--tg-text-muted);
}

.form-group input:focus {
  border-color: var(--tg-primary);
  background: var(--tg-bg-secondary);
}

.form-group small {
  display: block;
  margin-top: 0.5rem;
  color: var(--tg-text-muted);
  font-size: 0.8rem;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 0.875rem;
  background: var(--tg-bg-tertiary);
  border: none;
  border-radius: 8px;
  color: var(--tg-text);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--tg-transition);
}

.btn:hover {
  background: var(--tg-bg-hover);
}

.btn.primary {
  background: var(--tg-primary);
  color: white;
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--tg-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(51, 144, 236, 0.4);
}

/* Form Messages */
.form-error {
  color: #ff6b6b;
  font-size: 0.875rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0;
  background: transparent;
  border-radius: 0;
  border-left: none;
}

.form-success {
  color: var(--tg-online);
  font-size: 0.875rem;
  margin-top: 0.75rem;
  padding: 0.5rem 0;
  background: transparent;
  border-radius: 0;
  border-left: none;
}

/* ============================================
   MAIN SCREEN - Telegram Layout
   ============================================ */

#main-screen {
  display: none;
  width: 100%;
  height: 100%;
}

#main-screen.active {
  display: flex;
}

/* ============================================
   SIDEBAR - Left Panel
   ============================================ */

.sidebar {
  width: var(--tg-sidebar-width);
  min-width: 280px;
  max-width: 480px;
  background: var(--tg-bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--tg-border);
  position: relative;
}

/* Header */
.user-info {
  height: var(--tg-header-height);
  background: var(--tg-bg-secondary);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--tg-border);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #59c7f9 0%, #3390ec 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.125rem;
  color: white;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--tg-transition);
}

.avatar:hover {
  transform: scale(1.05);
}

.user-details {
  flex: 1;
  min-width: 0;
}

.username {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  font-size: 0.8rem;
  color: var(--tg-text-secondary);
  font-family: 'SF Mono', Monaco, monospace;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--tg-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all var(--tg-transition);
}

.btn-icon:hover {
  background: var(--tg-bg-tertiary);
  color: var(--tg-text);
}

/* Search / General Chat Button */
.general-chat-section {
  padding: 0.5rem 1rem;
  background: var(--tg-bg-secondary);
  border-bottom: 1px solid var(--tg-border);
}

.general-chat-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--tg-bg-tertiary);
  border: none;
  border-radius: 8px;
  color: var(--tg-text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all var(--tg-transition);
  text-align: left;
}

.general-chat-btn:hover,
.general-chat-btn.active {
  background: var(--tg-bg-hover);
}

.general-chat-btn .btn-icon-small {
  font-size: 1.25rem;
}

/* Sections */
.notifications-section {
  max-height: 200px;
  overflow-y: auto;
  border-bottom: 1px solid var(--tg-border);
}

.friends-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Section Header */
.section-header {
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--tg-bg-secondary);
}

.section-header h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tg-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  gap: 0.25rem;
}

/* Badge */
.badge {
  background: var(--tg-primary);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

/* Lists */
.notifications-list,
.friends-list {
  overflow-y: auto;
}

.empty-text {
  text-align: center;
  color: var(--tg-text-muted);
  font-size: 0.875rem;
  padding: 2rem 1rem;
}

/* Friend Item - Telegram Style */
.friend-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.625rem 1rem;
  cursor: pointer;
  transition: all var(--tg-transition);
  position: relative;
}

.friend-item:hover {
  background: var(--tg-bg-tertiary);
}

.friend-item.active-chat {
  background: var(--tg-bg-hover);
}

.friend-item .avatar {
  width: 54px;
  height: 54px;
  font-size: 1.25rem;
  position: relative;
}

.friend-item .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.friend-item .name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-item .tag {
  font-size: 0.875rem;
  color: var(--tg-text-secondary);
}

.friend-item .remove-btn {
  opacity: 0;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  color: var(--tg-text-secondary);
  transition: all var(--tg-transition);
}

.friend-item:hover .remove-btn {
  opacity: 1;
}

.friend-item .remove-btn:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

/* Online Indicator */
.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: var(--tg-online);
  border-radius: 50%;
  border: 2px solid var(--tg-bg-secondary);
}

/* Friends Hint */
.friends-hint {
  padding: 0.5rem 1rem;
  background: rgba(51, 144, 236, 0.1);
  border-left: 3px solid var(--tg-primary);
  margin: 0.5rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.8rem;
  color: var(--tg-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Notification Item */
.notif-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tg-border);
  transition: background var(--tg-transition);
}

.notif-item:hover {
  background: var(--tg-bg-tertiary);
}

.notif-item .text {
  font-size: 0.9rem;
  color: var(--tg-text);
  margin-bottom: 0.5rem;
}

.notif-item .user-tag {
  color: var(--tg-primary);
  font-weight: 600;
}

.notif-item .actions {
  display: flex;
  gap: 0.5rem;
}

.notif-item .actions button {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* ============================================
   MODAL - Telegram Style
   ============================================ */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  transition: opacity var(--tg-transition);
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--tg-bg-secondary);
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  margin: 1rem;
  overflow: hidden;
  animation: modalSlideUp 0.2s ease;
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 1.25rem 1.5rem 0.5rem;
  text-align: center;
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  display: block;
}

.modal-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--tg-text);
  margin-bottom: 0.25rem;
}

.modal-description {
  padding: 0 1.5rem 1rem;
  color: var(--tg-text-secondary);
  font-size: 0.9rem;
  text-align: center;
}

.modal-content form {
  padding: 0 1.5rem 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.modal-actions .btn {
  flex: 1;
}

/* ============================================
   CHAT AREA - Telegram Style
   ============================================ */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--tg-bg);
  position: relative;
}

/* Chat Header */
.chat-header {
  height: var(--tg-header-height);
  background: var(--tg-bg-secondary);
  padding: 0 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--tg-border);
}

.chat-title-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.chat-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tg-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-subtitle {
  font-size: 0.875rem;
  color: var(--tg-text-secondary);
}

.online-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--tg-text-secondary);
  font-size: 0.875rem;
}

.online-dot {
  width: 8px;
  height: 8px;
  background: var(--tg-online);
  border-radius: 50%;
}

/* Messages Container - Telegram Background Pattern */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: 
    radial-gradient(circle at 20% 50%, rgba(51, 144, 236, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(89, 199, 249, 0.03) 0%, transparent 50%),
    var(--tg-bg);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 800px;
  margin: 0 auto;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--tg-text-secondary);
  gap: 1rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--tg-bg-tertiary);
  border-top-color: var(--tg-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Message Bubbles - Telegram Style */
.messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1rem;
}

.message {
  display: flex;
  gap: 0.5rem;
  max-width: 70%;
  animation: messageAppear 0.2s ease;
  position: relative;
  align-self: flex-start;
}

@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message .avatar {
  width: 36px;
  height: 36px;
  font-size: 0.875rem;
  align-self: flex-end;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.message .content {
  background: var(--tg-message-in);
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  min-width: 60px;
}

.message.own .content {
  background: var(--tg-message-out);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 4px;
}

.message .header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.message .username {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--tg-primary);
}

.message.own .username {
  color: var(--tg-mention);
}

.message .tag {
  font-size: 0.75rem;
  color: var(--tg-text-secondary);
  opacity: 0.7;
}

.message .time {
  font-size: 0.75rem;
  color: var(--tg-text-secondary);
  margin-left: 0.5rem;
  float: right;
  margin-top: 0.25rem;
}

.message .text {
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--tg-text);
  word-wrap: break-word;
}

/* Message Actions - Floating buttons on hover */
.message-actions {
  position: absolute;
  top: -12px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.message:hover .message-actions {
  opacity: 1;
}

.message-actions .btn-icon {
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  background: var(--tg-bg-tertiary);
  border-radius: 50%;
  border: 1px solid var(--tg-border);
  color: var(--tg-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.message-actions .btn-icon:hover {
  background: var(--tg-primary);
  color: white;
  border-color: var(--tg-primary);
  transform: scale(1.1);
}

.message-actions .btn-icon.delete-btn:hover {
  background: #ff6b6b;
  border-color: #ff6b6b;
}

/* Message content positioning for actions */
.message .content {
  position: relative;
  background: var(--tg-message-in);
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  min-width: 80px;
}

.message.own .content {
  background: var(--tg-message-out);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 4px;
}

/* Edit Container and Input */
.edit-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
}

.message .edit-input {
  flex: 1;
  min-width: 0;
  background: var(--tg-bg-tertiary);
  border: 1px solid var(--tg-primary);
  border-radius: 6px;
  padding: 0.375rem 0.5rem;
  color: var(--tg-text);
  font-size: 0.9375rem;
  outline: none;
  font-family: inherit;
}

.message .edit-input:focus {
  border-color: var(--tg-primary);
  box-shadow: 0 0 0 2px rgba(51, 144, 236, 0.2);
}

.edit-container .btn-icon {
  width: 28px;
  height: 28px;
  font-size: 0.875rem;
  background: var(--tg-bg-tertiary);
  border-radius: 50%;
  border: 1px solid var(--tg-border);
  color: var(--tg-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.edit-container .btn-icon:hover {
  background: var(--tg-primary);
  color: white;
  border-color: var(--tg-primary);
}

.edit-container .btn-icon:last-child:hover {
  background: #ff6b6b;
  border-color: #ff6b6b;
}

/* Message Form - Telegram Style */
.message-form {
  height: var(--tg-input-height);
  background: var(--tg-bg-secondary);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-top: 1px solid var(--tg-border);
}

.input-wrapper {
  flex: 1;
  position: relative;
}

.message-form input {
  width: 100%;
  padding: 0.625rem 1rem;
  background: var(--tg-bg-tertiary);
  border: none;
  border-radius: 20px;
  color: var(--tg-text);
  font-size: 0.9375rem;
  outline: none;
  transition: all var(--tg-transition);
}

.message-form input::placeholder {
  color: var(--tg-text-muted);
}

.message-form input:focus {
  background: var(--tg-bg);
  box-shadow: inset 0 0 0 2px var(--tg-primary);
}

.input-hint {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tg-text-muted);
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity var(--tg-transition);
}

.message-form input:focus + .input-hint {
  opacity: 1;
}

.send-btn {
  width: 44px !important;
  height: 44px;
  border-radius: 50% !important;
  background: var(--tg-primary) !important;
  color: white;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tg-transition);
}

.send-btn:hover {
  background: var(--tg-primary-hover) !important;
  transform: scale(1.05);
}

/* ============================================
   BLOCKED USERS
   ============================================ */

.blocked-users-list {
  max-height: 300px;
  overflow-y: auto;
  padding: 0 1.5rem;
}

.blocked-user-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem;
  background: var(--tg-bg-tertiary);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.blocked-user-item .info {
  flex: 1;
}

.blocked-user-item .name {
  font-weight: 600;
  color: var(--tg-text);
}

.blocked-user-item .tag {
  font-size: 0.875rem;
  color: var(--tg-text-secondary);
}

.blocked-user-item .unblock-btn {
  padding: 0.5rem 0.875rem;
  background: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--tg-transition);
}

.blocked-user-item .unblock-btn:hover {
  background: rgba(255, 107, 107, 0.3);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}

.toast {
  background: var(--tg-bg-secondary);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: toastSlideIn 0.3s ease;
  border-left: 3px solid var(--tg-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
  color: var(--tg-text);
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left-color: var(--tg-online);
}

.toast.error {
  border-left-color: #ff6b6b;
}

.toast.warning {
  border-left-color: #ffa726;
}

/* ============================================
   SCROLLBAR - Telegram Style
   ============================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
  .sidebar {
    width: 320px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 280px;
  }
  
  .message {
    max-width: 80%;
  }
}

@media (max-width: 600px) {
  :root {
    --tg-safe-bottom: env(safe-area-inset-bottom, 0px);
    --tg-safe-top: env(safe-area-inset-top, 0px);
  }
  
  body {
    font-size: 16px; /* Prevent zoom on iOS */
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }
  
  #main-screen {
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height */
  }
  
  .sidebar {
    width: 100%;
    height: 35vh;
    min-height: 200px;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--tg-border);
  }
  
  .chat-area {
    flex: 1;
    height: 65vh;
    min-height: 0;
  }
  
  .chat-header {
    padding: 0.625rem 0.875rem;
    min-height: 56px;
  }
  
  .chat-header h2 {
    font-size: 1rem;
  }
  
  .chat-messages {
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + var(--tg-safe-bottom));
  }
  
  .message {
    max-width: 92%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    line-height: 1.5;
  }
  
  .message-form {
    padding: 0.625rem 0.75rem;
    padding-bottom: calc(0.625rem + var(--tg-safe-bottom));
    gap: 0.5rem;
  }
  
  .message-form input {
    padding: 0.625rem 0.875rem;
    font-size: 16px; /* Prevent zoom on iOS */
    min-height: 44px; /* Touch target */
  }
  
  .send-btn {
    width: 44px !important;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Touch-friendly buttons */
  .btn, .icon-btn, .action-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .user-item {
    padding: 0.75rem;
    min-height: 56px;
  }
  
  .user-avatar {
    width: 44px;
    height: 44px;
    font-size: 1.125rem;
  }
  
  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: 1rem;
    max-height: 90vh;
    max-height: 90dvh;
  }
  
  .modal-header {
    padding: 1rem;
  }
  
  .modal-body {
    padding: 1rem;
  }
  
  .form-group input {
    font-size: 16px; /* Prevent zoom */
    padding: 0.75rem;
    min-height: 48px;
  }
  
  .btn-primary, .btn-secondary {
    padding: 0.875rem;
    font-size: 1rem;
    min-height: 48px;
  }
  
  /* Toast notifications - bottom on mobile */
  #toast-container {
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: calc(0.75rem + var(--tg-safe-bottom));
    max-width: none;
    z-index: 300;
  }
  
  .toast {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
  }
  
  /* Call modal mobile optimization */
  .call-content {
    padding: 1.5rem 1rem;
  }
  
  .call-avatar {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
  }
  
  .call-status {
    font-size: 1.125rem;
  }
  
  .call-timer {
    font-size: 1.75rem;
  }
  
  .call-btn-action {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }
  
  .incoming-call {
    left: 0.75rem;
    right: 0.75rem;
    top: calc(0.75rem + var(--tg-safe-top));
    flex-direction: column;
    text-align: center;
    padding: 1rem;
  }
  
  .incoming-call-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
  }
  
  /* Sidebar tabs - larger touch targets */
  .sidebar-tabs {
    padding: 0.375rem;
  }
  
  .tab-btn {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    min-height: 40px;
  }
  
  /* Search input mobile */
  .search-box input {
    font-size: 16px;
    padding: 0.625rem 0.875rem;
    min-height: 44px;
  }
  
  /* Context menu mobile */
  .context-menu {
    min-width: 180px;
  }
  
  .context-menu-item {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
    min-height: 44px;
  }
  
  /* Scrollbar - thinner on mobile */
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}

/* Extra small screens */
@media (max-width: 380px) {
  .sidebar {
    height: 30vh;
  }
  
  .chat-area {
    height: 70vh;
  }
  
  .message {
    max-width: 95%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .chat-header h2 {
    font-size: 0.9375rem;
  }
  
  .online-count {
    font-size: 0.75rem;
  }
  
  .user-info .name {
    font-size: 0.9375rem;
  }
  
  .user-info .status {
    font-size: 0.75rem;
  }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  #main-screen {
    flex-direction: row;
  }
  
  .sidebar {
    width: 40%;
    height: 100vh;
    max-height: none;
    border-right: 1px solid var(--tg-border);
    border-bottom: none;
  }
  
  .chat-area {
    width: 60%;
    height: 100vh;
  }
  
  .call-avatar {
    width: 80px;
    height: 80px;
    font-size: 2rem;
  }
}

/* Tablet optimization */
@media (min-width: 601px) and (max-width: 1024px) {
  .sidebar {
    width: 300px;
  }
  
  .message {
    max-width: 75%;
  }
  
  .modal-content {
    max-width: 500px;
  }
}

/* Prevent text selection on UI elements for better touch experience */
.sidebar-tabs,
.chat-header,
.modal-header,
.user-item,
.context-menu {
  -webkit-user-select: none;
  user-select: none;
}

/* Smooth scrolling */
.chat-messages,
.sidebar-content {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Active states for touch */
@media (hover: none) {
  .btn-primary:active,
  .btn-secondary:active,
  .icon-btn:active,
  .send-btn:active,
  .call-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
  }
  
  .user-item:active {
    background: var(--tg-bg-tertiary);
  }
  
  .message.own:active {
    background: var(--tg-own-message-hover);
  }
  
  .message:not(.own):active {
    background: var(--tg-bg-tertiary);
  }
}

/* ============================================
   CONTEXT HINT
   ============================================ */

.context-hint {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tg-bg-secondary);
  padding: 0.625rem 1rem;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

.hint-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--tg-text-secondary);
}

.hint-key {
  background: var(--tg-bg-tertiary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--tg-text);
}

/* ============================================
   CALLS - Voice/Video Calls
   ============================================ */

.chat-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.call-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tg-bg-tertiary);
  border: none;
  color: var(--tg-online);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tg-transition);
}

.call-btn:hover {
  background: var(--tg-online);
  color: white;
  transform: scale(1.05);
}

.call-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Call Modal */
.call-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 300;
}

.call-modal.active {
  display: flex;
}

.call-content {
  text-align: center;
  padding: 2rem;
}

.call-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #59c7f9 0%, #3390ec 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin: 0 auto 1.5rem;
  animation: callPulse 1.5s ease-in-out infinite;
}

@keyframes callPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(51, 144, 236, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(51, 144, 236, 0); }
}

.call-status {
  font-size: 1.25rem;
  color: var(--tg-text);
  margin-bottom: 0.5rem;
}

.call-timer {
  font-size: 2rem;
  color: var(--tg-text-secondary);
  font-family: monospace;
  margin-bottom: 2rem;
}

.call-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.call-btn-action {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-btn-action.accept {
  background: var(--tg-online);
  color: white;
}

.call-btn-action.accept:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(10, 198, 48, 0.4);
}

.call-btn-action.decline {
  background: #ff6b6b;
  color: white;
}

.call-btn-action.decline:hover {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
}

/* Incoming Call Toast */
.incoming-call {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--tg-bg-secondary);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: slideInRight 0.3s ease;
  border-left: 3px solid var(--tg-online);
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.incoming-call .caller-info {
  flex: 1;
}

.incoming-call .caller-name {
  font-weight: 600;
  color: var(--tg-text);
  font-size: 1rem;
}

.incoming-call .caller-tag {
  color: var(--tg-text-secondary);
  font-size: 0.875rem;
}

.incoming-call .call-actions-small {
  display: flex;
  gap: 0.5rem;
}

.incoming-call .btn-icon {
  width: 40px;
  height: 40px;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  :root {
    --tg-sidebar-width: 100%;
    --tg-header-height: 56px;
    --tg-input-height: 52px;
  }
  
  html {
    font-size: 14px;
  }
  
  /* Auth screen mobile */
  .auth-container {
    padding: 1.5rem;
    max-width: 100%;
  }
  
  .logo-icon {
    width: 100px;
    height: 100px;
    font-size: 50px;
  }
  
  .auth-logo h1 {
    font-size: 1.5rem;
  }
  
  /* Main layout mobile */
  #main-screen {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--tg-border);
  }
  
  .chat-area {
    flex: 1;
    min-height: 60vh;
  }
  
  /* User info mobile */
  .user-info {
    padding: 0.75rem 1rem;
    min-height: 56px;
  }
  
  .user-info .avatar {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  /* Notifications mobile */
  .notifications-section {
    max-height: 120px;
  }
  
  .notifications-list {
    max-height: 80px;
  }
  
  /* Friends list mobile */
  .friends-section {
    flex: 1;
    min-height: 0;
  }
  
  .friends-list {
    max-height: none;
  }
  
  .friend-item {
    padding: 0.75rem 1rem;
    min-height: 56px;
  }
  
  .friend-item .avatar {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  /* Chat header mobile */
  .chat-header {
    padding: 0.75rem 1rem;
    min-height: 56px;
  }
  
  .chat-header h2 {
    font-size: 1rem;
  }
  
  .chat-subtitle {
    font-size: 0.75rem;
  }
  
  /* Messages mobile */
  .messages-container {
    padding: 0.75rem;
  }
  
  .messages {
    gap: 0.5rem;
  }
  
  .message {
    max-width: 90%;
    padding: 0.625rem 0.875rem;
  }
  
  .message .avatar {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }
  
  .message .username {
    font-size: 0.8125rem;
  }
  
  .message .text {
    font-size: 0.9375rem;
  }
  
  /* Message form mobile */
  .message-form {
    padding: 0.75rem;
    gap: 0.5rem;
  }
  
  .message-form .input-wrapper {
    padding: 0 0.75rem;
  }
  
  .message-form input {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 0.625rem 0;
  }
  
  .send-btn {
    width: 44px;
    height: 44px;
    font-size: 1.125rem;
  }
  
  /* Modals mobile */
  .modal-content {
    max-width: 95%;
    max-height: 90vh;
    padding: 1.25rem;
  }
  
  .modal-header h3 {
    font-size: 1.125rem;
  }
  
  /* Call modal mobile */
  .call-content {
    padding: 1.5rem;
  }
  
  .call-avatar {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
  }
  
  .call-status {
    font-size: 1.125rem;
  }
  
  .call-timer {
    font-size: 1.75rem;
  }
  
  .call-btn-action {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
  }
  
  /* Toast mobile */
  .toast {
    max-width: 90%;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
  
  /* Online status mobile */
  .online-status {
    padding: 0.25rem 0.5rem;
  }
  
  .online-count {
    font-size: 0.75rem;
  }
  
/* Call button mobile */
  .call-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  
  /* Mobile menu button */
  .mobile-menu-btn {
    display: flex;
    width: 40px;
    height: 40px;
    margin-right: 0.5rem;
  }
  
  /* Sidebar overlay for mobile */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
  }
  
  .sidebar-overlay.active {
    display: block;
  }
  
  .sidebar.mobile-open {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    z-index: 51;
    transform: translateX(0);
    animation: slideInLeft 0.3s ease;
  }
  
  @keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
  }
  
  .sidebar:not(.mobile-open) {
    transform: translateX(-100%);
  }
}

/* Small phones */
@media (max-width: 480px) {
  html {
    font-size: 13px;
  }
  
  .auth-container {
    padding: 1rem;
  }
  
  .logo-icon {
    width: 80px;
    height: 80px;
    font-size: 40px;
  }
  
  .sidebar {
    max-height: 35vh;
  }
  
  .chat-area {
    min-height: 65vh;
  }
  
  .message {
    max-width: 95%;
    padding: 0.5rem 0.75rem;
  }
  
  .message .avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }
  
  .message-actions {
    opacity: 1;
    position: static;
    transform: none;
    margin-bottom: 0.25rem;
  }
  
  .message .header {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  
  .notif-item {
    padding: 0.75rem;
  }
  
  .notif-item .actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .notif-item .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  .friend-item .remove-btn {
    opacity: 1;
    width: 32px;
    height: 32px;
  }
  
  .blocked-user-item {
    padding: 0.75rem;
  }
  
  .unblock-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  .call-avatar {
    width: 80px;
    height: 80px;
    font-size: 2rem;
  }
  
  .call-status {
    font-size: 1rem;
  }
  
  .call-timer {
    font-size: 1.5rem;
  }
  
  .call-btn-action {
    width: 48px;
    height: 48px;
    font-size: 1.125rem;
  }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
  #main-screen {
    flex-direction: row;
  }
  
  .sidebar {
    width: 280px;
    height: 100vh;
    max-height: none;
    border-right: 1px solid var(--tg-border);
    border-bottom: none;
  }
  
  .chat-area {
    min-height: auto;
  }
  
  .auth-container {
    padding: 1rem;
  }
  
  .logo-icon {
    width: 80px;
    height: 80px;
    font-size: 40px;
    margin-bottom: 1rem;
  }
  
  .auth-logo {
    margin-bottom: 1rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn-icon:hover,
  .friend-item:hover,
  .message:hover {
    background: transparent;
  }
  
  .btn-icon:active,
  .friend-item:active,
  .message:active {
    background: var(--tg-bg-hover);
  }
  
  .message-actions {
    opacity: 1;
    position: static;
    transform: none;
    margin-bottom: 0.25rem;
  }
  
  .friend-item .remove-btn {
    opacity: 1;
  }
  
  /* Larger touch targets */
  .btn,
  .btn-icon,
  .friend-item,
  .notif-item .btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .message-form input {
    min-height: 44px;
  }
}

/* iOS safe area */
@supports (padding-top: env(safe-area-inset-top)) {
  .chat-header {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
  
  .message-form {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  
  .modal-content {
    margin-top: env(safe-area-inset-top);
    margin-bottom: env(safe-area-inset-bottom);
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Mobile menu button - hidden on desktop */
.mobile-menu-btn {
  display: none;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
}

/* ============================================
   SETTINGS MODAL
   ============================================ */

.settings-modal-content {
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
}

.settings-tabs {
  display: flex;
  background: var(--tg-bg-tertiary);
  padding: 0.25rem;
  gap: 0.25rem;
  border-bottom: 1px solid var(--tg-border);
}

.settings-tab {
  flex: 1;
  padding: 0.75rem;
  background: transparent;
  border: none;
  color: var(--tg-text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--tg-transition);
}

.settings-tab:hover {
  color: var(--tg-text);
  background: rgba(255, 255, 255, 0.05);
}

.settings-tab.active {
  background: var(--tg-primary);
  color: white;
}

.settings-panel {
  display: none;
  padding: 1.5rem;
}

.settings-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

.settings-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--tg-border);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--tg-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}

/* Theme Selector */
.theme-selector {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.theme-option {
  flex: 1;
  min-width: 100px;
  cursor: pointer;
}

.theme-option input {
  display: none;
}

.theme-preview {
  display: block;
  padding: 1rem;
  border-radius: 12px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--tg-transition);
  border: 2px solid transparent;
}

.theme-preview.light-theme {
  background: #f5f5f5;
  color: #333;
}

.theme-preview.dark-theme {
  background: #1a1a2e;
  color: white;
}

.theme-preview.system-theme {
  background: linear-gradient(135deg, #f5f5f5 50%, #1a1a2e 50%);
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.theme-option input:checked + .theme-preview {
  border-color: var(--tg-primary);
  box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.3);
}

/* Background Options */
.background-options {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.bg-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--tg-bg-tertiary);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--tg-transition);
  font-size: 0.9rem;
}

.bg-option:hover {
  background: var(--tg-bg-hover);
}

.bg-option input {
  accent-color: var(--tg-primary);
}

.gradient-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.gradient-preview {
  height: 60px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--tg-transition);
  border: 2px solid transparent;
}

.gradient-preview:hover {
  transform: scale(1.05);
}

.gradient-preview.selected {
  border-color: var(--tg-primary);
  box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.3);
}

.image-upload-area {
  margin-top: 1rem;
  padding: 1.5rem;
  background: var(--tg-bg-tertiary);
  border-radius: 12px;
  text-align: center;
  border: 2px dashed var(--tg-border);
}

.upload-hint {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--tg-text-muted);
}

/* Font Size Slider */
.font-size-slider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.font-preview {
  font-weight: 600;
  color: var(--tg-text-secondary);
}

.font-preview.small {
  font-size: 0.75rem;
}

.font-preview.large {
  font-size: 1.5rem;
}

.font-size-slider input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: var(--tg-bg-tertiary);
  border-radius: 3px;
  outline: none;
}

.font-size-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--tg-primary);
  border-radius: 50%;
  cursor: pointer;
}

.font-preview-text {
  padding: 1rem;
  background: var(--tg-bg-tertiary);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--tg-text);
  text-align: center;
}

/* Toggle Options */
.toggle-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.toggle-option.small {
  font-size: 0.8rem;
}

.toggle-option input {
  display: none;
}

.toggle-slider {
  width: 44px;
  height: 24px;
  background: var(--tg-bg-tertiary);
  border-radius: 12px;
  position: relative;
  transition: all var(--tg-transition);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all var(--tg-transition);
}

.toggle-option input:checked + .toggle-slider {
  background: var(--tg-primary);
}

.toggle-option input:checked + .toggle-slider::after {
  left: 22px;
}

.toggle-label {
  color: var(--tg-text);
  line-height: 1.4;
}

/* Device Selectors */
.device-selectors {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.device-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.device-group label {
  font-size: 0.875rem;
  color: var(--tg-text-secondary);
  font-weight: 500;
}

.device-group select {
  padding: 0.625rem;
  background: var(--tg-bg-tertiary);
  border: 1px solid var(--tg-border);
  border-radius: 8px;
  color: var(--tg-text);
  font-size: 0.9rem;
  cursor: pointer;
}

/* Gain Controls */
.gain-controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.gain-slider {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.gain-slider label {
  font-size: 0.875rem;
  color: var(--tg-text-secondary);
  font-weight: 500;
}

.slider-with-value {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.slider-with-value input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: var(--tg-bg-tertiary);
  border-radius: 3px;
}

.slider-with-value input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--tg-primary);
  border-radius: 50%;
  cursor: pointer;
}

.slider-with-value span {
  min-width: 50px;
  text-align: right;
  font-size: 0.875rem;
  color: var(--tg-text-secondary);
  font-family: monospace;
}

/* Level Meter */
.level-meter {
  height: 4px;
  background: var(--tg-bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.level-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--tg-online) 0%, #ffd700 50%, #ff6b6b 100%);
  border-radius: 2px;
  transition: width 0.1s ease;
}

/* Codec Select */
.codec-select {
  width: 100%;
  padding: 0.75rem;
  background: var(--tg-bg-tertiary);
  border: 1px solid var(--tg-border);
  border-radius: 8px;
  color: var(--tg-text);
  font-size: 0.9rem;
  cursor: pointer;
}

.codec-description {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--tg-text-muted);
}

/* Audio Options */
.audio-option {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--tg-border);
}

.audio-option:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.sub-option {
  margin-top: 0.75rem;
  margin-left: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sub-option label {
  font-size: 0.8rem;
  color: var(--tg-text-secondary);
}

.strength-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--tg-text-muted);
  margin-top: 0.25rem;
}

/* Noise Options */
.noise-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.noise-option {
  flex: 1;
  min-width: 80px;
}

.noise-option input {
  display: none;
}

.noise-option span {
  display: block;
  padding: 0.5rem 0.75rem;
  background: var(--tg-bg-tertiary);
  border-radius: 6px;
  text-align: center;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--tg-transition);
  border: 1px solid transparent;
}

.noise-option input:checked + span {
  background: var(--tg-primary);
  color: white;
  border-color: var(--tg-primary);
}

/* Sound List */
.sound-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sound-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--tg-bg-tertiary);
  border-radius: 8px;
  gap: 1rem;
}

.sound-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sound-name {
  font-weight: 500;
  color: var(--tg-text);
}

.sound-desc {
  font-size: 0.8rem;
  color: var(--tg-text-muted);
}

.sound-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sound-controls select {
  padding: 0.5rem;
  background: var(--tg-bg);
  border: 1px solid var(--tg-border);
  border-radius: 6px;
  color: var(--tg-text);
  font-size: 0.8rem;
}

/* Settings Actions */
.settings-actions {
  position: sticky;
  bottom: 0;
  background: var(--tg-bg-secondary);
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--tg-border);
  margin: 0 -1.5rem -1.5rem -1.5rem;
}

.close-settings {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
}

/* ============================================
   CALL FLOATING TOOLBAR
   ============================================ */

.call-floating-toolbar {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.5rem;
  border-radius: 16px;
  backdrop-filter: blur(10px);
  z-index: 310;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.call-modal.active .call-floating-toolbar {
  opacity: 1;
  pointer-events: all;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  position: relative;
}

.toolbar-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.toolbar-btn.dropdown {
  width: 24px;
  height: 48px;
  border-radius: 0 12px 12px 0;
  font-size: 0.6rem;
}

.toolbar-icon {
  font-size: 1.25rem;
}

.toolbar-label {
  font-size: 0.65rem;
  font-weight: 500;
}

.toolbar-slider {
  width: 60px;
  height: 4px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  outline: none;
}

.toolbar-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
}

/* Quality Popup */
.quality-popup {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  padding: 1rem;
  border-radius: 12px;
  min-width: 150px;
  backdrop-filter: blur(10px);
}

.quality-metric {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

.quality-metric span:first-child {
  color: var(--tg-text-secondary);
}

.quality-metric span:last-child {
  color: var(--tg-online);
  font-family: monospace;
}

/* More Menu */
.more-menu {
  position: absolute;
  bottom: 60px;
  right: 0;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 12px;
  min-width: 180px;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.menu-item {
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: white;
  text-align: left;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.2s ease;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Settings Button in Header */
.settings-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--tg-text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--tg-transition);
}

.settings-btn:hover {
  background: var(--tg-bg-tertiary);
  color: var(--tg-text);
}

/* Mobile Settings */
@media (max-width: 768px) {
  .settings-modal-content {
    max-width: 95%;
    max-height: 90vh;
  }
  
  .settings-tabs {
    font-size: 0.8rem;
  }
  
  .theme-selector {
    flex-direction: column;
  }
  
  .theme-option {
    min-width: auto;
  }
  
  .noise-options {
    flex-direction: column;
  }
  
  .noise-option {
    min-width: auto;
  }
  
  .call-floating-toolbar {
    bottom: 100px;
    padding: 0.375rem;
    gap: 0.25rem;
  }
  
  .toolbar-btn {
    width: 44px;
    height: 44px;
  }
  
  .toolbar-icon {
    font-size: 1.125rem;
  }
  
  .toolbar-label {
    font-size: 0.6rem;
  }
}
