/* ==========================================================================
   WP Ajax Chat - Modern & Sleek Theme
   ========================================================================== */

/* --- Global Styles & Font --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #121212; /* A very dark, modern background */
    color: #e4e6eb; /* Light grey text for readability on dark */
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* --- Main Chat Container --- */
.chat-container {
    width: 90%;
    max-width: 1100px;
    height: 90vh;
    background: #1a1a1d; /* Dark container */
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #333;
}

/* --- Header --- */
.chat-container header {
    background: #2b2d42; /* Slightly lighter than the main body */
    color: #ffffff;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
}

.chat-container header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
    color: #b0b3b8;
}

/* --- Main Content Area (Sidebar + Chat) --- */
main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- Users Sidebar --- */
.users-sidebar {
    width: 280px;
    background: #222327; /* Darker sidebar */
    border-right: 1px solid #333;
    overflow-y: auto;
    flex-shrink: 0;
}

.users-sidebar h3 {
    padding: 1.2rem 1.5rem;
    margin: 0;
    background: #1f1f23;
    color: #e4e6eb;
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.users-sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.user-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 15px;
    gap: 10px;
}
.user-item.active-chat {
    background: #2a2b2d;
}
.user-name {
    flex-grow: 1;
}
.user-actions {
    display: flex;
    gap: 5px;
}
.user-actions button {
    padding: 4px 8px;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.button-accept { background: #2ecc71; color: white; }
.button-remove { background: #e74c3c; color: white; }
.button-add { background: #3498db; color: white; }

/* --- Chat Window --- */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1f1f23;
}

.chat-header {
    padding: 1rem 1.5rem;
    background: #2a2b2d;
    border-bottom: 1px solid #444;
    font-weight: 500;
    color: #b0b3b8;
}

/* --- Messages Area --- */
.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Hide scrollbar but keep functionality */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #777;
}


.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message.received {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 20px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.sent .message-bubble {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-bottom-right-radius: 6px;
}

.message.received .message-bubble {
    background: #3a3b3c; /* Dark grey for received messages */
    color: #e4e6eb;
    border-bottom-left-radius: 6px;
}

.message-info {
    font-size: 0.7rem;
    color: #888;
    margin-top: 5px;
    padding: 0 8px;
}

/* --- Message Form --- */
.message-form {
    display: flex;
    padding: 1rem 1.5rem;
    background: #2a2b2d;
    border-top: 1px solid #444;
    gap: 10px;
}

.message-form input[type="text"] {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid #555;
    background: #3a3b3c;
    border-radius: 25px;
    color: #e4e6eb;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.message-form input[type="text"]:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.message-form input[type="text"]::placeholder {
    color: #888;
}

.message-form button {
    padding: 12px 24px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: transform 0.1s, box-shadow 0.2s;
}

.message-form button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.message-form button:active:not(:disabled) {
    transform: translateY(0);
}

.message-form button:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ==========================================================================
   Friend System Styles
   ========================================================================== */

/* --- Tabs --- */
.sidebar-tabs {
    display: flex;
    background: #1f1f23;
    border-bottom: 1px solid #444;
}
.tab-button {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.tab-button.active {
    color: #fff;
    background: #2a2b2d;
    border-bottom: 2px solid #667eea;
}

/* --- Tab Content --- */
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}
.empty-list {
    padding: 20px;
    text-align: center;
    color: #666;
}

/* --- User Items with Actions --- */
.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
}
.user-item.active-chat {
    background: #2a2b2d;
}
.user-name {
    flex-grow: 1;
}
.user-actions {
    display: flex;
    gap: 5px;
}
.user-actions button {
    padding: 4px 8px;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.button-accept { background: #2ecc71; color: white; }
.button-remove { background: #e74c3c; color: white; }
.button-add { background: #3498db; color: white; }

/* --- User Search --- */
.user-search {
    padding: 15px;
    border-top: 1px solid #444;
}
#user-search-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #555;
    background: #3a3b3c;
    border-radius: 5px;
    color: #e4e6eb;
    box-sizing: border-box;
}
#user-search-results {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}
.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #2a2b2d;
    border-radius: 4px;
    margin-bottom: 5px;
}
.search-empty {
    color: #888;
    font-size: 0.9rem;
}

/* --- Attachment Button --- */
.attachment-button {
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    padding: 5px 10px;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}
.attachment-button:hover {
    background-color: #444;
    color: #fff;
}

/* ==========================================================================
   Sidebar Header & Logout Button
   ========================================================================== */
.sidebar-header {
    padding: 15px;
    background: #1f1f23;
    border-bottom: 1px solid #444;
}

.current-user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.current-user-info span {
    color: #b0b3b8;
    font-weight: 500;
}

.logout-link {
    color: #e74c3c;
    text-decoration: none;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.logout-link:hover {
    background-color: rgba(231, 76, 60, 0.1); /* Subtle red background on hover */
}

/* ==========================================================================
   Authentication Forms (Login/Register) Styles - More Specific
   ========================================================================== */
.chat-container.auth-container .auth-main {
    display: flex;
    padding: 0;
    min-height: 400px; /* Give it some height */
    overflow-y: auto;
    max-height: 90vh;
}

/* --- Tabs (Now Vertical) --- */
.chat-container.auth-container .auth-tabs {
    display: flex;
    flex-direction: column; /* Stack buttons vertically */
    width: 120px; /* Give the tab column a fixed width */
    border-right: 1px solid #444; /* Separator on the right */
    border-bottom: none; /* Remove old separator */
}

.chat-container.auth-container .auth-tab-button {
    padding: 15px; /* A bit more padding for vertical layout */
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    text-align: left; /* Align text to the left */
    border-radius: 0; /* Override theme button radius */
}

.chat-container.auth-container .auth-tab-button.active {
    color: #fff;
    background: #2a2b2d;
    border-left: 3px solid #667eea; /* Active indicator on the left */
    font-weight: 600;
}

/* --- Tab Content & Forms --- */
.chat-container.auth-container .auth-tab-content {
    display: none;
    flex-grow: 1; /* Allow the content area to fill remaining space */
    padding: 30px; /* Add padding around the forms */
}

.chat-container.auth-container .auth-tab-content.active {
    display: block;
}

.chat-container.auth-container .auth-form .form-group {
    margin-bottom: 15px;
}

.chat-container.auth-container .auth-form label {
    display: block;
    margin-bottom: 5px;
    color: #b0b3b8;
}

.chat-container.auth-container .auth-form input[type="text"],
.chat-container.auth-container .auth-form input[type="email"],
.chat-container.auth-container .auth-form input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #555;
    background: #3a3b3c;
    border-radius: 5px;
    color: #e4e6eb;
    box-sizing: border-box;
    font-size: 1rem;
}

.chat-container.auth-container .auth-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* --- Submit Button --- */
.chat-container.auth-container .auth-submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: transform 0.1s, box-shadow 0.2s;
}

.chat-container.auth-container .auth-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.chat-container.auth-container .auth-submit-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Error Message --- */
.chat-container.auth-container .auth-error {
    margin-top: 15px;
    padding: 10px;
    background: #e74c3c;
    color: white;
    border-radius: 5px;
    text-align: center;
    display: none; /* Will be shown by JS when there's an error */
}

/* ==========================================================================
   Message Delete Button
   ========================================================================== */

.message-bubble {
    position: relative; /* Needed for positioning the delete button */
}

.delete-message-btn {
    position: absolute;
    top: -10px;
    right: -5px;
    cursor: pointer;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s ease-in-out;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Show the delete button on hover for sent messages */
.message.sent:hover .delete-message-btn {
    opacity: 1;
}

/* Fade-out animation for deletion */
.message.deleting {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#typing-indicator.active {
    opacity: 1;
}

#typing-indicator span {
    width: 8px;
    height: 8px;
    background: #888;
    border-radius: 50%;
    animation: typing-animation 1.4s infinite;
}

/* Create the three dots with a slight delay */
#typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
#typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-animation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* ==========================================================================
   Emoji Picker Button
   ========================================================================== */

.emoji-button-container {
    width: 45px;
    height: 45px;
    background: #3a3b3c;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0px;
    transition: background-color 0.2s;
}

.emoji-button-container:hover {
    background: #4a4b4c;
}

.emoji-button-container::after {
    content: '😊';
    font-size: 16px;
}

/* ==========================================================================
   Utility Buttons (Notepad & Calculator)
   ========================================================================== */

header {
    position: relative; /* Needed to position utility buttons */
}

.utility-buttons {
    display: flex;
    gap: 10px;
}

.utility-buttons button {
    background: #3a3b3c;
    border: none;
    color: #b0b3b8;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.utility-buttons button:hover {
    background: #4a4b4c;
    color: #ffffff;
}

/* --- Utility Windows --- */
.utility-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    background: #2a2b2d;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    width: 400px;
    max-width: 90vw;
}

.utility-window.visible {
    display: flex;
}

.utility-header {
    background: #1f1f23;
    padding: 10px 15px;
    border-bottom: 1px solid #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e4e6eb;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
}

.close-btn:hover {
    color: #e74c3c;
}

/* --- Notepad Specific --- */
#notepad-window {
    height: 400px;
}

#notepad-content {
    flex-grow: 1;
    border: none;
    background: #1a1a1d;
    color: #e4e6eb;
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    resize: none;
    outline: none;
}

/* --- Calculator Specific --- */
#calculator-window {
    height: auto;
}
.calculator-body {
    padding: 15px;
}
.calc {
  text-rendering: geometricPrecision;
  width: 260px;
  background: grey;
  margin: 10px auto 0 auto;
  border-radius: 5px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.2),
    inset 0 3px 0 rgba(255,255,255,0.2);
  padding: 20px
}
.calc-display {
  font-family: 'Roboto Condensed', sans-serif;
  color: rgba(255,255,255,0.8);
  background: rgba(0,0,0,.6);
  font-size: 35px;
  padding: 10px;
  text-align: right;
  border-radius: 2px;
  box-shadow: inset 0 5px 8px rgba(0,0,0,0.3), 0 1px 0 rgba(255,255,255,0.3);
}
.calc-display-main {
  height: 38px;
}
.calc-display-indicate {
  font-size: 10px;
  color: rgba(255,255,255,0.05);
  text-align: left;
  margin: -5px 0 -2px -5px;
  text-transform: uppercase;
  user-select: none;
  transition: color .1s ease-in;
}
.calc .max{
  color: rgba(255,150,150,0.8);
}
.calc-display-operations {
  font-size: 15px;
  color: rgba(255,255,255,0.5);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 3px;
  margin-top: 4px;
}
.calc .row {
  margin-left: -12px;
  margin-top: 10px;
}
.calc .row:after, .calc .bottom-row:after {
  content: "";
  display: block;
  clear: both;
}
.calc-left, .calc-right {
  float: left;
}
.calc-button {
  position: relative;
  top:0;
  height: 41px;
  color: rgba(0,0,0,0.6);
  font-size: 16px;
  font-family:"Arial Bold", Gadget, Arial, sans-serif;
  font-weight: 700;
  text-align: center;
  padding: 9px 0 11px 0;
  border-radius: 2px;
  float: left;
  width: 56px;
  background: rgba(255,255,255,0.8);
  margin-left: 12px;
  text-transform: uppercase;
  border: 0;
  box-shadow: 0 1px 1px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.6);
  transition: all .1s;
  cursor:pointer;
  user-select: none;
}
.calc-button:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.15),inset 0 1px 0 rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.95);
  color: rgba(0,0,0,0.8);
}
.calc-button:active {
  top:1px;
  box-shadow: 0 0 2px rgba(0,0,0,0.15),inset 0 1px 0 rgba(255,255,255,0.3);
}
.calc-button:focus {
  outline:0;
}
.calc .ac, .calc .ce {
  background: #FF8A80;
}
.calc .ac:hover, .calc .ce:hover {
  background: #FF5252;
}
.calc .minus {
  padding-top: 11px;
  padding-bottom: 9px;
}
.calc .zero {
  width: 124px;
}
.calc .eq{
  margin-top: 10px;
  padding: 35px 0 15px 0;
}
.calc .mult {
  text-transform: none;
  padding-top: 9px;
  padding-bottom: 11px;
}