@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Roboto', sans-serif;
  margin: 0;
  padding: 0;
  transition: background-color var(--transition-duration) ease, color var(--transition-duration) ease;
}

h1, p, div {
  text-align: center;
}

.dropbtn {
  background-color: #333;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #444;
  min-width: 160px;
  z-index: 1;
  border: 1px solid #333;
}

.dropdown-content a {
  color: white;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  transition: background-color 0.3s ease;
}

.dropdown-content a:hover {
  background-color: #555;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown:hover .dropbtn {
  background-color: #555;
}

/* CSS Custom Properties for Theme Support */
:root {
  --primary-color: #6200ee;
  --secondary-color: #03dac6;
  --background-color: #f5f5f5;
  --text-color: #333;
  --border-radius: 6px;
  
  /* Theme variables - default to light theme */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e0e0e0;
  --text-primary: #333333;
  --text-secondary: #666666;
  --border-color: #ddd;
  --success-color: #2e7d32;
  --danger-color: #c62828;
  --warning-color: #f57c00;
  --accent-color: #1976d2;
  --transition-duration: 0.3s;
  
  color-scheme: light dark;
}

/* Light mode theme */
body.light-mode {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e0e0e0;
  --text-primary: #333333;
  --text-secondary: #666666;
  --border-color: #ddd;
  --success-color: #2e7d32;
  --danger-color: #c62828;
  --warning-color: #f57c00;
  --accent-color: #1976d2;
  --background-color: #ffffff;
  --text-color: #333333;
}

/* Dark mode theme (explicit) */
body.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #333;
  --text-primary: #fff;
  --text-secondary: #888;
  --border-color: #333;
  --success-color: #4CAF50;
  --danger-color: #ff6b6b;
  --warning-color: #ff6b6b;
  --accent-color: #4cafef;
  --background-color: #1a1a1a;
  --text-color: #fff;
}

.gchat-box {
  border: 2px solid #dedede;
  background-color: light-dark(#f1f1f1, #111);
  border-radius: 5px;
  padding: 10px;
  margin: 10px 0;
  white-space: normal;
  max-height: 500px;
  overflow-y: scroll;
}

.darker {
  border-color: #ccc;
  background-color: #ddd;
}

/* .chat-box::after {
  content: "";
  clear: both;
  display: table;
} */

.button-container {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.button-24 {
  background: #FF4742;
  border: 1px solid #FF4742;
  border-radius: 6px;
  box-shadow: rgba(0, 0, 0, 0.1) 1px 2px 4px;
  box-sizing: border-box;
  color: #FFFFFF;
  cursor: pointer;
  display: inline-block;
  font-family: nunito, roboto, proxima-nova, "proxima nova", sans-serif;
  font-size: 16px;
  font-weight: 800;
  line-height: 16px;
  min-height: 40px;
  outline: 0;
  padding: 12px 14px;
  text-align: center;
  text-rendering: geometricprecision;
  text-transform: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  vertical-align: middle;
}

.button-24:hover {
  background-color: #FF4742;
  background-image: linear-gradient(white, white);
  background-position: 0 0;
  background-size: 100% 100%;
  color: #FF4742;
}
.button-24:focus {
  background-color: #FF4742;
  background-image: linear-gradient(white, white);
  background-position: 0 0;
  background-size: 100% 100%;
  color: #FF4742;
}
.button-24:active {
  background-color: initial;
  background-position: 0 0;
  color: #FF4742;
}

.button-24:active {
  opacity: .5;
}

.button-61 {
  align-items: center;
  appearance: none;
  border-radius: 4px;
  border-style: none;
  box-shadow: rgba(0, 0, 0, .2) 0 3px 1px -2px, rgba(0, 0, 0, .14) 0 2px 2px 0, rgba(0, 0, 0, .12) 0 1px 5px 0;
  box-sizing: border-box;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-family: Roboto, sans-serif;
  font-size: .875rem;
  font-weight: 500;
  height: 36px;
  justify-content: center;
  letter-spacing: .0892857em;
  line-height: normal;
  min-width: 64px;
  outline: none;
  overflow: visible;
  padding: 0 16px;
  position: relative;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  transition: box-shadow 280ms cubic-bezier(.4, 0, .2, 1);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  vertical-align: middle;
  will-change: transform, opacity;
}

.button-61:hover {
  box-shadow: rgba(0, 0, 0, .2) 0 2px 4px -1px, rgba(0, 0, 0, .14) 0 4px 5px 0, rgba(0, 0, 0, .12) 0 1px 10px 0;
}

.button-61:disabled {
  background-color: rgba(0, 0, 0, .12);
  box-shadow: rgba(0, 0, 0, .2) 0 0 0 0, rgba(0, 0, 0, .14) 0 0 0 0, rgba(0, 0, 0, .12) 0 0 0 0;
  color: rgba(0, 0, 0, .37);
  cursor: default;
  pointer-events: none;
}

.top-time {
  font-size: large;
}

.button-61:not(:disabled) {
  background-color: #f56b6b;
}

.button-61:focus {
  box-shadow: #00000033 0 2px 4px -1px, rgba(0, 0, 0, .14) 0 4px 5px 0, rgba(0, 0, 0, .12) 0 1px 10px 0;
}

.button-61:active {
  box-shadow: rgba(0, 0, 0, .2) 0 5px 5px -3px, rgba(0, 0, 0, .14) 0 8px 10px 1px, rgba(0, 0, 0, .12) 0 3px 14px 2px;
  background: #f56b6b;
}

.rizzler {
  color: rgb(255, 89, 0);
}

.hidden {
  display: none;
}

header {
  background-color: var(--primary-color);
  color: white;
  padding: 20px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

footer {
  background-color: var(--primary-color);
  color: white;
  text-align: center;
  padding: 10px;
  position: fixed;
  bottom: 0;
  width: 100%;
  box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
}

nav ul {
  list-style-type: none;
  padding: 0;
  display: flex;
  justify-content: center;
  gap: 20px;
}

nav ul li {
  display: inline;
}

nav ul li a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: bold;
  padding: 10px 15px;
  border-radius: var(--border-radius);
  transition: background-color 0.3s ease, color 0.3s ease;
}

nav ul li a:hover {
  background-color: var(--secondary-color);
  color: white;
}

.settings-form {
  max-width: 600px;
  margin: 20px auto;
  padding: 20px;
  background-color: var(--background-color);
  border: 1px solid var(--text-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.settings-form label {
  display: block;
  margin-bottom: 10px;
  font-weight: bold;
}

.settings-form input {
  width: 100%;
  padding: 10px;
  margin-bottom: 20px;
  border: 1px solid var(--text-color);
  border-radius: var(--border-radius);
}

.settings-form button {
  width: 100%;
  padding: 10px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.settings-form button:hover {
  background-color: var(--secondary-color);
}

/* Mobile Responsive Styles */

/* Hamburger menu button for mobile */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1001;
  background: #23272f;
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 44px;
  height: 44px;
  font-size: 1.2em;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.mobile-menu-toggle:hover {
  background: #2c2f36;
}

/* Mobile overlay for sidebar */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

/* Mobile styles for screens up to 768px */
@media screen and (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
    overflow-x: hidden;
  }

  /* Show mobile menu toggle */
  .mobile-menu-toggle {
    display: block;
  }

  /* Main container adjustments */
  .main-container {
    flex-direction: column !important;
    height: 100vh !important;
  }

  /* Friends sidebar mobile styles */
  #friends-hub {
    position: fixed !important;
    top: 0;
    left: -220px; /* Hidden by default */
    width: 220px !important;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    border-right: 2px solid #444;
  }

  #friends-hub.mobile-open {
    left: 0;
  }

  /* Main chat area adjustments */
  .chat-main-area {
    flex: 1 !important;
    margin-left: 0 !important;
    padding-top: 60px; /* Space for mobile header */
    min-height: 100vh;
  }

  /* News bar mobile adjustments */
  .news-bar {
    padding: 8px !important;
    font-size: 1em !important;
    position: relative;
    top: 0;
  }

  /* Button container mobile layout */
  .button-container {
    flex-direction: column !important;
    gap: 8px;
    padding: 10px;
    align-items: center;
  }

  .button-container h3 {
    margin: 4px 0;
    font-size: 1em;
    text-align: center;
  }

  /* Chat box mobile optimizations */
  .chat-box {
    margin: 10px;
    height: calc(100vh - 300px) !important;
    min-height: 300px;
  }

  #chat-header {
    padding: 8px !important;
    font-size: 0.9em;
  }

  #messages-container {
    padding: 10px !important;
  }

  /* Chat form mobile layout */
  #chat-form {
    display: flex !important;
    flex-direction: row !important;
    padding: 10px;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: var(--background-color);
    border-top: 1px solid #444;
  }

  #message {
    flex: 1 !important;
    padding: 12px !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
    border-radius: 6px !important;
  }

  #send-button {
    min-width: 60px !important;
    padding: 12px 16px !important;
  }

  /* Bottom buttons mobile layout */
  .bottom-buttons-container {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 10px !important;
    margin-bottom: 20px !important;
  }

  .bottom-buttons-container .button-61 {
    width: 100% !important;
    max-width: none !important;
    min-width: auto !important;
    padding: 12px !important;
    font-size: 1em !important;
  }

  /* Friend search mobile */
  #friend-search {
    width: calc(100% - 12px) !important;
    padding: 8px !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
  }

  /* Friends list mobile */
  #friends-list li {
    padding: 12px 8px !important;
    font-size: 1em;
    border-bottom: 1px solid #444;
  }

  /* Inbox popup mobile adjustments */
  #inbox-popup {
    position: fixed !important;
    top: 10px !important;
    left: 10px !important;
    right: 10px !important;
    max-width: none !important;
    width: auto !important;
    max-height: 80vh !important;
  }

  /* Friend request popup mobile */
  #friend-request-popup {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    right: 20px !important;
    width: auto !important;
    min-width: auto !important;
  }

  /* Context menu mobile */
  #native-context-menu {
    max-width: 90vw !important;
    font-size: 1em;
  }

  /* Touch-friendly button sizes */
  .button-24,
  .button-37,
  .button-61,
  .checko,
  .deladmin {
    min-height: 44px !important;
    padding: 12px 16px !important;
    font-size: 1em !important;
    touch-action: manipulation;
  }

  /* Add friend button mobile */
  #add-friend-btn {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.4em !important;
  }

  #inbox-btn {
    width: 36px !important;
    height: 36px !important;
  }

  /* Dropdown mobile adjustments */
  .dropdown-content {
    min-width: 200px !important;
    font-size: 1em;
  }

  .dropdown-content a {
    padding: 16px !important;
  }

  /* Settings form mobile */
  .settings-form {
    margin: 10px !important;
    padding: 15px !important;
  }

  .settings-form input {
    padding: 12px !important;
    font-size: 16px !important; /* Prevents zoom on iOS */
  }

  .settings-form button {
    padding: 12px !important;
    font-size: 1em !important;
  }

  /* Message bubbles mobile */
  .message-bubble {
    padding: 10px 12px !important;
    margin: 6px 0 !important;
  }

  .message-header {
    flex-wrap: wrap;
    gap: 4px;
  }

  .message-time {
    font-size: 0.75em !important;
  }

  /* Tag adjustments for mobile */
  .admin-tag,
  .owner-tag,
  .banned-tag {
    font-size: 0.6em !important;
    padding: 1px 4px !important;
  }

  /* Navigation mobile */
  nav ul {
    flex-direction: column !important;
    gap: 10px !important;
    padding: 10px;
  }

  nav ul li a {
    display: block;
    text-align: center;
    padding: 12px !important;
  }

  /* Header and footer mobile */
  header {
    padding: 15px 10px !important;
    font-size: 1.2rem !important;
  }

  footer {
    padding: 12px 10px !important;
    font-size: 0.9em;
  }
}

/* Extra small mobile devices (max-width: 480px) */
@media screen and (max-width: 480px) {
  #friends-hub {
    width: 280px !important; /* Wider sidebar for small screens */
    left: -280px;
  }

  .button-container h3 {
    font-size: 0.9em;
  }

  .chat-box {
    height: calc(100vh - 280px) !important;
  }

  /* Smaller text for very small screens */
  .message-bubble {
    font-size: 0.9em;
  }

  /* Compact inbox tabs */
  .inbox-tab {
    padding: 4px 8px !important;
    font-size: 0.8em !important;
  }

  /* Stack inbox header vertically on very small screens */
  #inbox-popup > div:first-child {
    flex-direction: column !important;
    gap: 8px !important;
    align-items: flex-start !important;
  }

  #inbox-popup > div:first-child > div:first-child {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100%;
  }
}

/* Landscape mobile adjustments */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .chat-box {
    height: calc(100vh - 200px) !important;
  }

  #chat-form {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px !important;
  }

  .button-container {
    padding: 5px !important;
  }

  .button-container h3 {
    margin: 2px 0 !important;
    font-size: 0.8em !important;
  }
}

/* Tablet adjustments (769px to 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  #friends-hub {
    width: 200px !important;
  }

  .button-container {
    padding: 12px;
  }

  .chat-box {
    margin: 12px;
  }

  /* Slightly smaller touch targets for tablets */
  .button-24,
  .button-37,
  .button-61 {
    min-height: 40px !important;
  }
}

/* High DPI display adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .mobile-menu-toggle {
    border: 0.5px solid #444;
  }
  
  .message-bubble {
    border-width: 0.5px;
  }
}

/* Dark mode mobile optimizations */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
  .mobile-menu-toggle {
    background: #1a1d23;
    border: 1px solid #333;
  }
  
  #chat-form {
    background: #121212;
    border-top-color: #333;
  }
  
  .mobile-overlay {
    background: rgba(0, 0, 0, 0.7);
  }
}

/* Light mode mobile optimizations */
@media (prefers-color-scheme: light) and (max-width: 768px) {
  .mobile-menu-toggle {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ccc;
  }
  
  #friends-hub {
    background: #f8f9fa !important;
    color: #333 !important;
    border-right-color: #dee2e6;
  }
  
  #chat-form {
    background: #ffffff;
    border-top-color: #dee2e6;
  }
}

/* Focus and accessibility improvements for mobile */
@media screen and (max-width: 768px) {
  button:focus,
  input:focus,
  textarea:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
  }

  /* Ensure text is readable and touch targets are accessible */
  .chat-message {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Better spacing for touch interaction */
  li {
    margin-bottom: 2px;
  }

  /* Ensure dropdowns work well on mobile */
  .dropdown:hover .dropdown-content {
    display: block;
  }

  /* Support for touch events */
  .dropdown:active .dropdown-content {
    display: block;
  }
}

/* Additional mobile optimizations */

/* Keyboard handling styles */
body.keyboard-open {
  height: 100vh;
  overflow: hidden;
}

body.keyboard-open .chat-box {
  height: calc(50vh - 100px) !important;
}

body.keyboard-open #chat-form {
  position: fixed !important;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

/* Touch feedback styles */
.mobile-device button:active,
.mobile-device .button-24:active,
.mobile-device .button-37:active,
.mobile-device .button-61:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

/* Improved scrolling for mobile */
.mobile-device {
  -webkit-overflow-scrolling: touch;
}

.mobile-device .chat-box,
.mobile-device #friends-list,
.mobile-device #messages-container {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Better text selection on mobile */
.mobile-device .message-content {
  -webkit-user-select: text;
  user-select: text;
}

/* Improve tap targets */
.mobile-device li,
.mobile-device .chat-message {
  min-height: 44px;
  display: flex;
  align-items: center;
}

/* Better focus styles for mobile */
.mobile-device input:focus,
.mobile-device textarea:focus,
.mobile-device button:focus {
  outline: 2px solid #4a90e2;
  outline-offset: 2px;
}

/* Prevent text size adjustment on orientation change */
.mobile-device {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Safe area handling for devices with notches */
@supports (padding: max(0px)) {
  .mobile-device {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  
  .mobile-device .mobile-menu-toggle {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
  }
  
  .mobile-device #chat-form {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

/* Tablet-specific optimizations */
.tablet-device #friends-hub {
  width: 250px !important;
}

.tablet-device .button-container {
  flex-direction: row !important;
  flex-wrap: wrap;
  justify-content: space-around;
}

.tablet-device .chat-box {
  margin: 15px;
}

/* Performance optimizations */
.mobile-device * {
  -webkit-tap-highlight-color: transparent;
}

/* Improved button styles for touch */
@media screen and (max-width: 768px) {
  .button-24,
  .button-37, 
  .button-61,
  button {
    min-height: 44px;
    min-width: 44px;
    font-size: 16px;
    line-height: 1.2;
    padding: 12px 16px;
  }
  
  /* Ensure dropdown menus work well on mobile */
  .dropdown-content {
    position: fixed !important;
    top: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: 20px;
    min-width: 200px;
    max-width: 90vw;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
  }
  
  /* Better modal positioning */
  .modal,
  #inbox-popup,
  #friend-request-popup {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw !important;
    max-width: 400px !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
  }
}

/* Loading states for mobile */
.mobile-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  font-size: 14px;
  color: #888;
}

.mobile-loading::after {
  content: '';
  width: 20px;
  height: 20px;
  margin-left: 10px;
  border: 2px solid #888;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .mobile-device .mobile-menu-toggle {
    border: 2px solid currentColor;
  }
  
  .mobile-device .button-24,
  .mobile-device .button-37,
  .mobile-device .button-61 {
    border: 2px solid currentColor;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .mobile-device * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .mobile-device #friends-hub {
    transition: none !important;
  }
}