@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-Thin.woff2") format("woff2");
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-ThinItalic.woff2") format("woff2");
  font-weight: 100;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-ExtraLight.woff2") format("woff2");
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-ExtraLightItalic.woff2") format("woff2");
  font-weight: 200;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-Light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-LightItalic.woff2") format("woff2");
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-MediumItalic.woff2") format("woff2");
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-SemiBoldItalic.woff2") format("woff2");
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-BoldItalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-ExtraBold.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("./styles/fonts/JetBrainsMono-ExtraBoldItalic.woff2") format("woff2");
  font-weight: 800;
  font-style: italic;
  font-display: swap;
}

:root {
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 15px;
  background: #2D2D2D;
  color: #DDD;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 60px;
  --primary-color: #4A4A4A;
  --success-color: #7edba5;
  --danger-color: #d36d6d;
  --bg-dark: #2D2D2D;
  --bg-panel: #252525;
  --bg-content: #2D2D2D;
  --border-color: #555;
  --text-muted: #777;
  --message-bg: #1E1E1E;
  --message-bg-user: #3A3A3A;
  
  /* Responsive variables */
  --mobile-breakpoint: 768px;
  --tablet-breakpoint: 1024px;
  --mobile-sidebar-width: 280px;
  --mobile-header-height: 50px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-dark);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  color: #DDD;
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background-color: #2D2D2D;
  color: #DDD;
}

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  overflow: hidden;
  position: relative;
  min-width: 200px;
  max-width: 500px;
  resize: horizontal;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-right {
  border-right: none;
  border-left: 1px solid var(--border-color);
  order: 3;
}

.sidebar-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
}

.sidebar-resize-handle-left {
  right: auto;
  left: 0;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.resizing {
  background: var(--primary-color);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
  max-width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  color: #DDD;
}

.toggle-sidebar {
  background: transparent;
  border: none;
  color: #DDD;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toggle-sidebar:hover {
  background: #3A3A3A;
}

.connection-section,
.channel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.section-title {
  font-size: 0.75rem;
  color: #DDD;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-icon {
  flex-shrink: 0;
  opacity: 0.7;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  color: #DDD;
  margin-bottom: 4px;
}

.form-group input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #3A3A3A;
  color: #DDD;
  font-size: 0.85rem;
}

.form-group input:focus {
  border-color: #555;
  outline: none;
}

.button-group {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

button {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #3A3A3A;
  color: #DDD;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  flex: 1;
  min-width: 0;
}

button:hover:not(:disabled) {
  background: #4A4A4A;
}

button:active:not(:disabled) {
  background: #2A2A2A;
}

button:disabled {
  background: #2A2A2A;
  color: #777;
  cursor: not-allowed;
  opacity: 1;
}

.btn-primary {
  background: #3A3A3A;
  border-color: #555;
}

.btn-primary:hover:not(:disabled) {
  background: #4A4A4A;
}

.btn-danger {
  background: var(--danger-color);
  border-color: var(--danger-color);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.75rem;
  flex-wrap: wrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger-color);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success-color);
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.channel-item {
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
}

.channel-item:hover {
  background: #3A3A3A;
}

.channel-item.active {
  background: #3A3A3A;
  color: #DDD;
}

.channel-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.channel-icon svg {
  width: 100%;
  height: 100%;
}

.channel-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.people-section {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.people-search-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #3A3A3A;
  color: #DDD;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.people-search-input:focus {
  outline: none;
  border-color: #555;
}

.people-list-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.people-list {
  padding: 0;
  position: relative;
  min-height: 0;
  width: 100%;
}

.people-list-spacer {
  width: 100%;
  flex-shrink: 0;
  height: 0;
}

.people-item {
  padding: 6px 12px;
  border-radius: 4px;
  margin-bottom: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  transition: background-color 0.2s;
}

.people-item:hover {
  background: #3A3A3A;
}

.people-item.op {
  color: #ff5f87;
  font-weight: bold;
}

.people-item.voiced {
  color: #5af78e;
}

.people-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.people-icon svg {
  width: 100%;
  height: 100%;
}

.people-prefix {
  font-size: 0.75rem;
  width: 12px;
  text-align: center;
  flex-shrink: 0;
}

.people-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Main Content Styles */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-content);
  min-width: 0; /* Important for flexbox shrinking */
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  background: #252525;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.tabs::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

.tab {
  padding: 8px 16px;
  border-radius: 4px 4px 0 0;
  border: 1px solid #555;
  border-bottom: none;
  background: #2D2D2D;
  cursor: pointer;
  font-size: 0.85rem;
  color: #DDD;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
  max-width: 200px;
}

.tab.active {
  background: #3A3A3A;
  color: #DDD;
}

.tab-close {
  margin-left: 4px;
  opacity: 0.6;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.tab-close:hover {
  opacity: 1;
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
}

.message-line {
  display: flex;
  padding: 2px 0;
  color: #DDD;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-sender {
  min-width: 80px;
  max-width: 120px;
  font-weight: 500;
  padding-right: 8px;
  text-align: right;
  color: #DDD;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-sender.you {
  color: var(--primary-color);
}

.message-content {
  flex: 1;
  color: #DDD;
  min-width: 0;
  word-break: break-word;
}

.system-message {
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
  text-align: center;
}

.irc-message {
  color: #a0a0a0;
  font-size: 0.8rem;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-panel);
}

.composer-input {
  position: relative;
  display: flex;
  align-items: center;
  background: #3A3A3A;
  border-radius: 4px;
  padding: 0 16px;
  min-width: 0;
}

.composer-input input {
  flex: 1;
  border: none;
  background: transparent;
  color: #DDD;
  padding: 12px 0;
  font-size: 0.95rem;
  outline: none;
  font-family: 'JetBrains Mono', monospace;
  min-width: 0;
  width: 100%;
}

.composer-input input::placeholder {
  color: #777;
}

.suggestions {
  position: absolute;
  bottom: 110%;
  left: 0;
  right: 0;
  background: #252525;
  border: 1px solid #555;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
}

.suggestions button {
  border: none;
  background: transparent;
  text-align: left;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestions button:hover,
.suggestions button.active {
  background: #3A3A3A;
}

.suggestions.hidden {
  display: none;
}

/* Collapsed sidebar styles */
.sidebar.collapsed .section-title,
.sidebar.collapsed .form-group,
.sidebar.collapsed .button-group,
.sidebar.collapsed .status-indicator,
.sidebar.collapsed .channel-name,
.sidebar.collapsed .people-name {
  display: none;
}

.sidebar.collapsed .sidebar-header h1 {
  display: none;
}

.sidebar.collapsed .connection-section,
.sidebar.collapsed .channel-section,
.sidebar.collapsed .people-section {
  padding: 16px 8px;
}

.sidebar.collapsed .channel-item,
.sidebar.collapsed .people-item {
  justify-content: center;
  padding: 8px;
}

/* Mobile Overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 90;
}

.mobile-overlay.active {
  display: block;
}

/* Mobile Header */
.mobile-header {
  display: none;
  padding: 8px 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  gap: 12px;
  min-height: var(--mobile-header-height);
}

.mobile-menu-button {
  background: transparent;
  border: none;
  color: #DDD;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu-button:hover {
  background: #3A3A3A;
}

.mobile-title {
  font-size: 1rem;
  font-weight: 600;
  color: #DDD;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Scrollbars - Vertical */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  background: #1E1E1E;
  border-radius: 5px;
}

::-webkit-scrollbar-track {
  background: #1E1E1E;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: #3A3A3A;
  border-radius: 5px;
  min-height: 20px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555555;
}

::-webkit-scrollbar-thumb:active {
  background: #6A6A6A;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #3A3A3A #1E1E1E;
}

/* Responsive styles */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  
  .sidebar {
    min-width: 180px;
    max-width: 400px;
  }
  
  .message-sender {
    min-width: 70px;
    max-width: 100px;
    font-size: 0.85rem;
  }
  
  .messages {
    padding: 12px;
    font-size: 0.85rem;
  }
  
  .composer {
    padding: 12px;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  
  .composer-input input {
    font-size: 0.9rem;
    padding: 10px 0;
  }
  
  button {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--mobile-sidebar-width);
    max-width: 100vw;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 100;
    resize: none;
    min-width: unset;
    max-width: unset;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .sidebar-right {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }
  
  .sidebar-right.active {
    transform: translateX(0);
  }
  
  .mobile-header {
    display: flex;
  }
  
  .main-content {
    flex: 1;
    min-height: 0;
  }
  
  .tabs {
    padding: 4px 8px;
  }
  
  .tab {
    padding: 6px 12px;
    font-size: 0.8rem;
    max-width: 150px;
  }
  
  .messages {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  
  .message-line {
    flex-direction: column;
    padding: 4px 0;
    gap: 2px;
  }
  
  .message-sender {
    min-width: auto;
    max-width: none;
    text-align: left;
    padding-right: 0;
    font-size: 0.8rem;
    padding: 2px 0;
  }
  
  .composer {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
  }
  
  .button-group {
    flex-direction: column;
  }
  
  button {
    flex: none;
  }
  
  .sidebar-resize-handle {
    display: none;
  }
  
  /* Hide sidebar toggle in header when sidebar is open on mobile */
  .sidebar.active ~ .main-content .mobile-header .mobile-menu-button {
    visibility: hidden;
  }
}

@media (max-width: 480px) {
  :root {
    font-size: 14px;
  }
  
  .sidebar {
    width: 100vw;
  }
  
  .sidebar-header {
    padding: 12px;
    min-height: 50px;
  }
  
  .connection-section,
  .channel-section,
  .people-section {
    padding: 12px;
  }
  
  .channel-list {
    padding: 0 12px 12px;
  }
  
  .tab {
    padding: 6px 10px;
    font-size: 0.75rem;
    max-width: 120px;
  }
  
  .messages {
    padding: 6px 8px;
    font-size: 0.75rem;
  }
  
  .composer {
    padding: 8px;
  }
  
  .composer-input {
    padding: 0 12px;
  }
  
  .composer-input input {
    padding: 8px 0;
    font-size: 0.85rem;
  }
  
  .mobile-header {
    padding: 6px 12px;
  }
  
  .form-group input {
    padding: 6px 8px;
  }
  
  button {
    padding: 6px 8px;
    font-size: 0.75rem;
  }
}

@media (max-width: 320px) {
  :root {
    font-size: 13px;
  }
  
  .tab {
    max-width: 100px;
    padding: 4px 8px;
  }
  
  .messages {
    padding: 4px 6px;
  }
  
  .composer {
    padding: 6px;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  button, 
  .channel-item, 
  .people-item, 
  .tab {
    min-height: 44px; /* Better touch targets */
  }
  
  .toggle-sidebar,
  .mobile-menu-button {
    min-width: 44px;
    min-height: 44px;
  }
  
  .sidebar-resize-handle {
    width: 8px; /* Larger touch target for resize */
  }
  
  /* Reduce hover effects on touch devices */
  .channel-item:hover,
  .people-item:hover,
  .tab:hover {
    background: inherit;
  }
  
  .channel-item:active,
  .people-item:active,
  .tab:active {
    background: #3A3A3A;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  :root {
    font-size: 16px; /* Slightly larger text for better readability */
  }
}

/* Print styles */
@media print {
  .sidebar,
  .composer,
  .mobile-header,
  .tabs {
    display: none !important;
  }
  
  .main-content {
    display: block !important;
  }
  
  .messages {
    overflow: visible !important;
    height: auto !important;
  }
  
  body {
    overflow: visible !important;
  }
}

input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

input[type="number"]::-webkit-outer-spin-button, 
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Utility classes for responsive behavior */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hide-on-mobile {
  display: block;
}

.show-on-mobile {
  display: none;
}

@media (max-width: 768px) {
  .hide-on-mobile {
    display: none !important;
  }
  
  .show-on-mobile {
    display: block !important;
  }
  
  .show-on-mobile-flex {
    display: flex !important;
  }
}