/* Import Vazirmatn font from Google Fonts. This line adds the font family to your project. */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700&display=swap');

/* Variables for consistent theming */
/* This file is the compiled output of src/scss/main.scss (if you were using Sass locally) */
body {
  margin: 0;
  /* Apply Vazirmatn as the primary font for the entire body. */
  font-family: 'Vazirmatn', sans-serif;
  background-color: #1a1a1a;
  color: #e0e0e0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  /* Ensures right-to-left text direction for Persian. */
  direction: rtl;
}

#app {
  width: 100%;
  max-width: 400px; 
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Global styles for inputs and buttons */
input[type="text"],
input[type="password"],
input[type="email"],
textarea {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 15px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  width: calc(100% - 20px);
  padding: 12px;
  margin-bottom: 15px;
  color: #e0e0e0;
  border: none;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for inputs */
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px #6a1b9a;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="email"]::placeholder,
textarea::placeholder {
  color: rgba(224, 224, 224, 0.6);
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for placeholders */
}

button {
  background-color: #6a1b9a;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
  font-family: 'Vazirmatn', sans-serif;
}
button:hover {
  background-color: #55167c;
}
button:disabled {
  background-color: #9245be;
  cursor: not-allowed;
}

/* Page container for consistent padding */
.page-container {
  flex-grow: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
}

.login-page {
  position: relative;
  /*width: 100%;*/
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 15px;
}

#background-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  filter: brightness(0.6);
}

.login-container {
  padding: 30px;
  text-align: center;
  width: 90%;
  max-width: 400px;
  z-index: 1;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 15px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.login-container h2 {
  margin-top: 0;
  color: white;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for headings */
}
.login-container input {
  width: calc(100% - 24px);
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 8px;
}
.login-container button {
  width: 100%;
  margin-bottom: 10px;
}

.divider {
  margin: 20px 0;
  color: rgba(255, 255, 255, 0.7);
  position: relative;
  text-align: center;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for divider text */
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background-color: rgba(255, 255, 255, 0.3);
}
.divider::before {
  left: 0;
}
.divider::after {
  right: 0;
}

.google-btn {
  background-color: #4285F4;
  display: flex;
  align-items: center;
  justify-content: center;
}
.google-btn img {
  width: 20px;
  height: 20px;
  margin-left: 10px;
}

.error-message {
  color: #f44336;
  margin-bottom: 15px;
  background-color: rgba(255, 0, 0, 0.1);
  padding: 10px;
  border-radius: 8px;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for error messages */
}

.contacts-page {
  justify-content: flex-start;
  padding: 0;
}

.app-header {
  width: 80%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  margin-bottom: 20px;
  border-radius: 0;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.app-header h1 {
  margin: 0;
  color: white;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for headings */
}

.search-bar {
  width: 80%;
  margin: 0 20px 20px 20px;
  padding: 10px;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.search-bar input {
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for search input */
}

.contacts-list {
  list-style: none;
  padding: 0;
  margin: 0 20px 20px 20px;
  width: 80%;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  flex-grow: 1;
  padding-bottom: 10px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 15px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.contacts-list li {
  padding: 15px;
  margin-bottom: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
}
.contacts-list li:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
  color: white;
  margin-left: 15px;
  flex-shrink: 0;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for avatar letter */
}

.contact-name {
  flex-grow: 1;
  font-size: 18px;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for contact name */
}

.contact-status {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for contact status */
}

.highlighted-contact {
  background-color: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.4);
}

.faded-contact {
  opacity: 0.6;
  color: #bdbdbd;
}

.loading-message {
  text-align: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for loading messages */
}

.logout-btn {
  background-color: #e57373;
  padding: 8px 15px;
  font-size: 14px;
}

.chat-page {
  justify-content: flex-start;
  padding: 0;
  position: relative;
}

.chat-header {
  width: 80%;
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-radius: 0;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
  margin-bottom: 0;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.chat-header h2 {
  margin: 0;
  color: white;
  flex-grow: 1;
  text-align: center;
  font-size: 20px;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for chat header */
}

.back-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transform: scaleX(-1);
}

.messages-container {
  flex-grow: 1;
  width: 80%;
  margin: 20px;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 15px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.message {
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 15px;
  margin-bottom: 10px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for message text */
}
.message.sent {
  background-color: rgba(106, 27, 154, 0.7);
  align-self: flex-end;
  color: white;
}
.message.received {
  background-color: rgba(255, 255, 255, 0.1);
  align-self: flex-start;
  color: #e0e0e0;
}

.message-timestamp {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 5px;
  text-align: left;
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for timestamps */
}

.message-input-area {
  display: flex;
  padding: 10px 20px;
  width: 80%;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0;
  border-bottom-left-radius: 15px;
  border-bottom-right-radius: 15px;
  align-items: center;
  flex-shrink: 0;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.message-input-area textarea {
  flex-grow: 1;
  margin-right: 10px;
  height: auto;
  min-height: 40px;
  max-height: 100px;
  overflow-y: auto;
  resize: none;
  padding: 8px 12px;
  border-radius: 8px;
}
.message-input-area button {
  padding: 10px 20px;
  height: auto;
  flex-shrink: 0;
}

.loading-messages {
  text-align: center;
  padding: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Vazirmatn', sans-serif; /* Ensure Vazirmatn for loading messages */
}

/* --- Media Queries for Responsiveness --- */

/* For screens smaller than 768px (tablets and smaller) */
@media (max-width: 768px) {
    #app {
        max-width: 100%; /* Allow app to take full width on smaller screens */
    }

    .login-container {
        width: 95%; /* Make login container wider on smaller screens */
        padding: 25px; /* Adjust padding */
    }

    .app-header, .chat-header {
        padding: 12px 15px; /* Smaller padding for headers */
        margin-bottom: 15px;
    }

    .search-bar {
        width: 80%; /* Adjust width for search bar */
        margin: 0 15px 15px 15px;
    }

    .contacts-list, .messages-container {
        width: 80%; /* Adjust width for lists/containers */
        margin: 15px;
        padding: 10px;
        max-height: calc(100vh - 160px); /* Adjust max-height if needed */
    }

    .message-input-area {
        padding: 8px 15px; /* Smaller padding for message input area */
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    textarea {
        padding: 10px; /* Smaller padding for inputs */
        margin-bottom: 10px;
    }

    button {
        padding: 10px 15px; /* Smaller padding for buttons */
        font-size: 15px;
    }

    .contact-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
        margin-left: 10px;
    }

    .contact-name {
        font-size: 16px;
    }

    .contact-status {
        font-size: 13px;
    }

    .message {
        padding: 8px 12px;
        font-size: 15px;
    }

    .message-timestamp {
        font-size: 9px;
    }
}

/* For screens smaller than 480px (most mobile phones) */
@media (max-width: 480px) {
    .login-container {
        width: 98%;
        padding: 20px;
    }

    .app-header, .chat-header {
        padding: 10px 10px;
        margin-bottom: 10px;
    }

    .app-header h1, .chat-header h2 {
        font-size: 18px;
    }

    .search-bar {
        width: 80%;
        margin: 0 10px 10px 10px;
        padding: 8px;
    }

    .contacts-list, .messages-container {
        width: 80%;
        margin: 10px;
        padding: 8px;
        max-height: calc(100vh - 140px); /* Further adjust max-height if needed */
    }

    .message-input-area {
        padding: 5px 10px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    textarea {
        padding: 8px;
        margin-bottom: 8px;
        font-size: 14px;
    }

    button {
        padding: 8px 12px;
        font-size: 14px;
    }

    .contact-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
        margin-left: 8px;
    }

    .contact-name {
        font-size: 15px;
    }

    .message {
        padding: 7px 10px;
        font-size: 14px;
    }
}