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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background: #f0f2f5;
  color: #333;
}

/* Flash Messages */
.flash-messages {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  max-width: 400px;
}

.flash {
  padding: 15px 20px;
  margin-bottom: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease-out;
}

.flash-success {
  background: #d4edda;
  color: #155724;
  border-left: 4px solid #28a745;
}

.flash-error {
  background: #f8d7da;
  color: #721c24;
  border-left: 4px solid #dc3545;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Auth Pages */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.auth-box h1 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 10px;
}

.subtitle {
  text-align: center;
  color: #7f8c8d;
  margin-bottom: 30px;
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 8px;
  font-weight: 500;
  color: #2c3e50;
}

.form-group input,
.form-group select {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-primary:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
}

.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: #7f8c8d;
}

.auth-link a {
  color: #3498db;
  text-decoration: none;
}

.auth-link a:hover {
  text-decoration: underline;
}

/* Main App Layout */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: white;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #2c3e50;
  color: white;
}

.sidebar-header h2 {
  font-size: 20px;
  margin-bottom: 5px;
}

.user-role {
  display: inline-block;
  padding: 4px 12px;
  background: #3498db;
  border-radius: 12px;
  font-size: 12px;
  text-transform: capitalize;
}

.logout-btn {
  display: inline-block;
  margin-top: 10px;
  color: #ecf0f1;
  text-decoration: none;
  font-size: 14px;
}

.logout-btn:hover {
  color: white;
}

/* Search */
.search-container {
  padding: 15px;
  border-bottom: 1px solid #e0e0e0;
  position: relative;
}

#search-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.search-results {
  position: absolute;
  top: 60px;
  left: 15px;
  right: 15px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-results.active {
  display: block;
}

.search-result-item {
  padding: 12px 15px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.search-result-item:hover {
  background: #f8f9fa;
}

.search-result-item:last-child {
  border-bottom: none;
}

/* Contacts List */
.contacts-list {
  flex: 1;
  overflow-y: auto;
}

.contact-item {
  padding: 15px 20px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

.contact-item:hover {
  background: #f8f9fa;
}

.contact-item.active {
  background: #e3f2fd;
  border-left: 3px solid #3498db;
}

.contact-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.contact-role {
  font-size: 12px;
  color: #7f8c8d;
  text-transform: capitalize;
}

.loading {
  padding: 20px;
  text-align: center;
  color: #7f8c8d;
}

/* Main Chat Area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #e8ebed;
}

.chat-header {
  padding: 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  font-weight: 600;
  font-size: 16px;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  scroll-behavior: smooth;
}

.no-chat-selected {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: #7f8c8d;
}

.message {
  display: flex;
  gap: 10px;
  max-width: 70%;
  position: relative;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.received {
  align-self: flex-start;
}

.message-content {
  position: relative;
}

.message-image {
  max-width: 400px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s;
}

.message-image:hover {
  transform: scale(1.02);
}

.decrypt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.message-image:hover .decrypt-overlay {
  opacity: 1;
}

.decrypt-text {
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.message-info {
  font-size: 11px;
  color: #7f8c8d;
  margin-top: 5px;
}

/* Message Input */
.message-input-container {
  background: white;
  border-top: 1px solid #e0e0e0;
  padding: 20px;
}

#message-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-row {
  display: flex;
  gap: 10px;
}

#message-text {
  flex: 1;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

#message-text:focus {
  outline: none;
  border-color: #3498db;
}

.input-actions {
  justify-content: space-between;
  align-items: center;
}

.file-input-wrapper {
  position: relative;
}

.file-label {
  display: inline-block;
  padding: 10px 16px;
  background: #ecf0f1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #2c3e50;
  transition: background 0.2s;
}

.file-label:hover {
  background: #d5dbdb;
}

#image-input {
  display: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s;
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 28px;
  font-weight: bold;
  color: #aaa;
  cursor: pointer;
}

.modal-close:hover {
  color: #333;
}

.modal-content h3 {
  margin-bottom: 20px;
  color: #2c3e50;
}

.decrypted-text {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #bdc3c7;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #95a5a6;
}

/* Delete Message Button */
.delete-message-btn {
  position: absolute;
  top: 10px;
  background: rgba(220, 53, 69, 0.9);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10;
  padding: 0;
}

/* Position on right for received messages (left side of screen) */
.message.received .delete-message-btn {
  right: -35px;
}

.message.received:hover .delete-message-btn {
  opacity: 1;
  right: -40px;
}

/* Position on left for sent messages (right side of screen) */
.message.sent .delete-message-btn {
  left: -35px;
}

.message.sent:hover .delete-message-btn {
  opacity: 1;
  left: -40px;
}

.delete-message-btn:hover {
  background: #dc3545;
  transform: scale(1.1);
}

.delete-message-btn svg {
  color: white;
}

.delete-message-btn:active {
  transform: scale(0.95);
}

/* 2-Step Send Flow Styles */
.steps-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 20px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
  position: relative;
  opacity: 0.5;
  transition: all 0.3s;
}

.step.active {
  opacity: 1;
}

.step.completed {
  opacity: 1;
  color: #27ae60;
}

.step-number {
  width: 30px;
  height: 30px;
  background: #bdc3c7;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-bottom: 5px;
  transition: all 0.3s;
}

.step.active .step-number {
  background: #3498db;
  transform: scale(1.1);
}

.step.completed .step-number {
  background: #27ae60;
}

.step-label {
  font-size: 12px;
  font-weight: 600;
}

.step-line {
  flex: 1;
  height: 2px;
  background: #e0e0e0;
  margin: -15px 10px 0;
}

.step-hint {
  font-size: 12px;
  color: #7f8c8d;
  margin-right: 10px;
  font-style: italic;
}

/* Encrypted Data Display Panel */
.encrypted-display {
  background: #2c3e50;
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
  color: #ecf0f1;
  animation: fadeIn 0.3s;
}

.display-header {
  background: #34495e;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #465c71;
}

.display-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #3498db;
}

.btn-text {
  background: none;
  border: none;
  color: #bdc3c7;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

.btn-text:hover {
  color: white;
  text-decoration: underline;
}

.code-block {
  padding: 15px;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
}

.code-label {
  color: #95a5a6;
  margin-bottom: 5px;
  font-weight: bold;
}

.code-content {
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 15px;
  word-break: break-all;
  max-height: 100px;
  overflow-y: auto;
  border: 1px solid #465c71;
}

.code-content:last-child {
  margin-bottom: 0;
}

.action-group {
  display: flex;
  align-items: center;
}

.btn-success {
  background: #27ae60;
  color: white;
}

.btn-success:hover {
  background: #219150;
}

.btn-success:disabled {
  background: #95a5a6;
}

.icon {
  margin-right: 5px;
}
