* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  height: 100vh;
  direction: rtl;
}

.hidden { display: none !important; }

/* Login */
.screen { height: 100vh; }

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #00a884, #008f72);
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  width: 360px;
}

.login-box h1 {
  color: #00a884;
  margin-bottom: 8px;
  font-size: 28px;
}

.login-box p {
  color: #667781;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  direction: rtl;
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: #00a884;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  font-weight: 600;
}

.login-box button:hover { background: #008f72; }

.error {
  color: #dc3545;
  margin-top: 12px;
  font-size: 14px;
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #00a884;
  color: white;
  padding: 0 20px;
  height: 56px;
}

.header-nav { display: flex; gap: 4px; }

.nav-btn {
  background: transparent;
  color: rgba(255,255,255,0.7);
  border: none;
  padding: 8px 20px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 6px;
  font-weight: 500;
}

.nav-btn.active {
  color: white;
  background: rgba(255,255,255,0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-display {
  font-size: 13px;
  opacity: 0.9;
}

#logout-btn {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

/* Chat Layout */
.chat-layout {
  display: flex;
  height: calc(100vh - 56px);
}

.conversations-panel {
  width: 350px;
  background: white;
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
}

.panel-header h3 {
  color: #111b21;
  font-size: 18px;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
}

.conv-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  gap: 12px;
}

.conv-item:hover { background: #f0f2f5; }
.conv-item.active { background: #e8f5e9; }

.conv-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #dfe5e7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #667781;
  flex-shrink: 0;
}

.conv-info {
  flex: 1;
  min-width: 0;
}

.conv-name {
  font-weight: 600;
  color: #111b21;
  font-size: 15px;
}

.conv-last-msg {
  color: #667781;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.conv-time {
  color: #667781;
  font-size: 12px;
}

.unread-badge {
  background: #00a884;
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* Chat Panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #efeae2;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
}

.chat-contact-info strong {
  display: block;
  color: #111b21;
  font-size: 15px;
}

.chat-contact-info span {
  color: #667781;
  font-size: 13px;
  direction: ltr;
  display: inline-block;
}

.ai-btn {
  padding: 6px 16px;
  border-radius: 20px;
  border: 2px solid #00a884;
  background: white;
  color: #00a884;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.ai-btn.active {
  background: #00a884;
  color: white;
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.empty-chat {
  text-align: center;
  color: #667781;
  margin-top: 40%;
  font-size: 16px;
}

.message {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  word-wrap: break-word;
}

.message.in {
  background: white;
  align-self: flex-start;
  border-top-right-radius: 0;
}

.message.out {
  background: #d9fdd3;
  align-self: flex-end;
  border-top-left-radius: 0;
}

.message .msg-time {
  font-size: 11px;
  color: #667781;
  margin-top: 4px;
  display: block;
}

.message .msg-source {
  font-size: 10px;
  color: #00a884;
  font-weight: 600;
}

/* Chat Input */
.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  background: white;
  border-top: 1px solid #e0e0e0;
}

#chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 14px;
  direction: rtl;
}

#send-btn {
  background: #00a884;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 24px;
  cursor: pointer;
  font-weight: 600;
}

#send-btn:hover { background: #008f72; }

/* Templates */
.templates-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.templates-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.templates-header h3 {
  font-size: 22px;
  color: #111b21;
}

.btn-primary {
  background: #00a884;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

.btn-primary:hover { background: #008f72; }

.btn-secondary {
  background: #e0e0e0;
  color: #333;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.template-form {
  background: white;
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.template-form h4 {
  margin-bottom: 16px;
  color: #111b21;
}

.template-form input,
.template-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  direction: rtl;
  font-family: inherit;
}

.template-form textarea {
  height: 100px;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.template-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.template-info h4 {
  color: #111b21;
  margin-bottom: 6px;
}

.template-info p {
  color: #667781;
  font-size: 14px;
  margin-bottom: 8px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-draft { background: #e0e0e0; color: #666; }
.status-pending { background: #fff3cd; color: #856404; }
.status-approved { background: #d4edda; color: #155724; }
.status-rejected { background: #f8d7da; color: #721c24; }

.template-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
}

.btn-submit {
  background: #00a884;
  color: white;
}

.btn-delete {
  background: #dc3545;
  color: white;
}

/* Flag filters */
.flag-filters {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.filter-btn {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 13px;
  cursor: pointer;
}

.filter-btn.active {
  background: #00a884;
  color: white;
  border-color: #00a884;
}

/* Flag dots */
.flag-dot {
  font-size: 14px;
}

/* Monday status badge */
.monday-badge {
  font-size: 11px;
  background: #f0f0f0;
  padding: 1px 6px;
  border-radius: 8px;
  margin-right: 6px;
  color: #555;
}

.monday-status {
  font-size: 12px;
  color: #667781;
  background: #f0f4f0;
  padding: 2px 8px;
  border-radius: 8px;
}

/* AI pause timer */
.ai-pause-timer {
  font-size: 12px;
  color: #e67e22;
  font-weight: bold;
}

/* Knowledge page */
.knowledge-layout {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

.knowledge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.knowledge-hint {
  color: #667781;
  font-size: 14px;
  margin-bottom: 15px;
}

.knowledge-textarea {
  width: 100%;
  min-height: 400px;
  padding: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  font-family: inherit;
  direction: rtl;
  resize: vertical;
}

.knowledge-textarea:focus {
  outline: none;
  border-color: #00a884;
}

.knowledge-status {
  margin-top: 10px;
  font-size: 13px;
  color: #667781;
}
