/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 11px;
    background-color: #f0f0f0;
    color: #ff6464;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for mobile */
    overflow: hidden;
    border-left: 5px solid #067910 !important;
  border-right: 5px solid #067910 !important;
    margin: 0;
    padding: 0;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
}

.screen.active {
    display: flex;
}

/* Nickname Entry Screen */
#nickname-screen {
    justify-content: center;
    align-items: center;
    background: #067910;
}

.nickname-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    height: 100%;
}

.logo h1 {
    color: white;
    margin-bottom: 30px;
    font-size: 36px;
    text-align: center;
    font-weight: bold;
    margin: 0;
    margin-bottom: 40px;
}

.logo .com {
    color: #ff0000;
    font-weight: normal;
}

.form-container {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.form-label {
    color: white;
    font-size: 19px;
    font-weight: bold;
    font-family: Arial, Sans-Serif !important;
    margin-bottom: 4px;
    align-self: flex-start;
    width: 100%;
    text-align: center;
}

#nickname-input,
#password-input {
    width: 70%;
    padding: 4px;
    border: none;
    border-radius: 7px;
    font-size: 16px;
    outline: none;
    margin-bottom: 2px;
    box-sizing: border-box;
    background-color: white;
    border: 2px solid rgb(170, 170, 170);
    text-align: center;
}

#connect-btn {
    color: white;
    padding: 13px 3px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
    width: 80%;
    margin-top: 10px;
}

#connect-btn:hover {
   opacity: 0.8;
}

#connect-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.connection-status {
    margin-top: 20px;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    min-height: 20px;
    color: white;
    font-size: 14px;
}

.connection-status.error {
    background-color: rgba(220, 38, 38, 0.8);
}

.connection-status.success {
    background-color: rgba(34, 197, 94, 0.8);
}

.connection-status.info {
    background-color: rgba(59, 130, 246, 0.8);
}

/* Chat Interface - Mibbit Green Theme */
#chat-screen {
    flex-direction: column;
}

/* Tabs - Now in Green Header */
.tabs-container {
    background: transparent;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    font-size: 11px;
    gap: 5px;
    width: 100%;
    max-width: 100%;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    flex: 1;
    white-space: nowrap;
}

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

.tab {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 2px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    min-width: 50px;
    max-width: 100px;
    font-size: 11px;
    height: 16px;
    box-sizing: border-box;
    color: white;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab.active {
    background: transparent;
    color: white;
    font-weight: bold;
}

.tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.3);
}

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

.tab-close {
    margin-left: 4px;
    color: rgb(255 0 0);
    cursor: pointer;
    font-size: 9px;
    padding: 0 2px;
    font-weight: bold;
}

.tab.active .tab-close {
    color: #ff0000;
}

.tab-close:hover {
    color: #ff0000;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.tab.active .tab-close:hover {
    background-color: #eee;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    background-color: #ffffff;
    max-height: 100vh;
    max-height: 100dvh;
}

/* Chat Header - Green Mibbit Style */
.chat-header {
    background: #09700d;
    color: white;
    padding: 15px 8px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    height: 10px;
    font-size: 11px;
    font-weight: bold;
    border-bottom: px solid #1B5E20;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.app-title {
    color: white;
    font-size: 15px;
    font-weight: lighter;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

#current-channel {
    color: #E8F5E8;
    font-weight: normal;
}

#connection-indicator.connected {
    color: #C8E6C9;
}

#connection-indicator.disconnected {
    color: #FFCDD2;
}

/* Main Content Area */
.chat-main {
    display: flex;
    flex: 1;
    min-height: 0;
    background-color: #ffffff;
}

/* Messages Panel */
.messages-panel {
    flex: 1;
    border-right: 3px solid #067910;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2px;
    background-color: #f9fff5;
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 18px;
    line-height: 1.7em;
}

.message {
    margin: 1px 0;
    word-wrap: break-word;
    padding: 1px 2px;
    border-top: 1px solid rgb(240, 255, 240) !important;
}

.message-time {
    color: #888;
    font-size: 10px;
    margin-right: 3px;
}

.message-nick {
    font-weight: normal;
    color: rgb(236, 59, 61);
    margin-right: 5px;
    Tahoma, Geneva, sans-serif;
}

.message-text {
    color: #000;
}

.system-message {
    color: #666;
    font-style: italic;
}

.system-message .message-nick {
    color: #666;
    font-weight: normal;
}

/* Users Panel - Mibbit Style */
.users-panel {
    width: 130px;
    background-color: #f8f8f8;
    border-left: 2px #067910;
    display: flex;
    flex-direction: column;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px;
    font-size: 11px;
    background-color: #fbfbfb;
}

.user-item {
    padding: 2px 2px;
    font-size: 11px;
    color: #000;
    cursor: default;
    margin-bottom: -3px;
    display: flex;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-direction: row;
}

.user-item:hover {
    background-color: #e8f4fd;
}

/* Input Panel */
.input-panel {
    border-top: 6px solid #067910;
    background-color: #f0f0f0;
    padding: 2px;
}

#message-input {
    width: 100%;
    padding: 5px 4px;
    border: 3px solid #ffffff;
    font-size: 16px;
    font-family: 'Verdana', 'Arial', sans-serif;
    outline: none;
    background-color: #ffffff;
}

#message-input:focus {
    border-color: transparent; /* ya jo color chaho */
    outline: none;
}

#message-input:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Toolbar - Mibbit Style */
.toolbar {
    background-color: #067910;
    border-top: 1px #006E0A;
    padding: 5px 4px;
    display: flex;
    align-items: center;
    font-size: 15px;
    height: 35px;
}

.toolbar-btn {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    padding: 1px 3px;
    margin: 0 1px;
}

.toolbar-btn:hover {
    background-color: #d0d0d0;
}

.toolbar-btn.active {
    background-color: #4CAF50;
    color: white;
    text-decoration: none;
}

/* .toolbar-separator {
    color: #666;
    margin: 0 2px;
} */

.toolbar-right {
    margin-left: auto;
    font-size: 10px;
    color: #ffffff;
}

/* Emoji Picker */
.emoji-picker {
    position: absolute;
    bottom: 45px;
    left: 4px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 4px;
    z-index: 1000;
    display: none;
    max-width: 200px;
    max-height: 150px;
    overflow-y: auto;
}

.emoji-picker.visible {
    display: block;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
}

.emoji-item {
    width: 28px;
    height: 28px;
    cursor: pointer;
    border-radius: 2px;
    padding: 1px;
    transition: background-color 0.2s;
    border: none;
    object-fit: contain;
}

.emoji-item:hover {
    background-color: #e8f4fd;
}

/* Color Picker */
.color-picker {
    position: absolute;
    bottom: 45px;
    left: 70px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 4px;
    z-index: 1000;
    display: none;
}

.color-picker.visible {
    display: block;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.color-item {
    width: 16px;
    height: 16px;
    cursor: pointer;
    border: 1px solid #999;
}

.color-item:hover {
    border: 2px solid #000;
    width: 15px;
    height: 15px;
}

/* Emoji in messages */
.message-emoji {
    width: 35px;
    height: 35px;
    vertical-align: ;
    object-fit: contain;
    margin: 0 1px;
}

.clickable-emoji {
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 0.2s ease, transform 0.1s ease;
}

.clickable-emoji:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Text Formatting */
.bold-text {
    font-weight: bold;
}

/* Color text classes */
.text-white { color: white; }
.text-black { color: black; }
.text-navy { color: navy; }
.text-green { color: green; }
.text-red { color: red; }
.text-brown { color: brown; }
.text-purple { color: purple; }
.text-orange { color: orange; }
.text-yellow { color: yellow; }
.text-lime { color: lime; }
.text-teal { color: teal; }
.text-cyan { color: cyan; }
.text-blue { color: blue; }
.text-magenta { color: magenta; }
.text-gray { color: gray; }
.text-silver { color: silver; }

/* Context Menu - Dropdown Style */
.context-menu {
    position: absolute;
    background-color: white;
    border: 1px solid #999;
    border-radius: 0;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: none;
    min-width: 80px;
    font-size: 11px;
}

.context-menu.visible {
    display: block;
}

.context-menu-item {
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
    color: #000;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background-color: #4CAF50;
    color: white;
}

/* Inline Context Options */
.inline-context-options {
    background-color: #ffffff;
    margin: 2px 0;
    padding: 2px 0;
}

.inline-option {
    padding: 3px 8px;
    font-size: 10px;
    cursor: pointer;
    color: #333;
    border-bottom: 1px solid #ddd;
}

.inline-option:last-child {
    border-bottom: none;
}

.inline-option:hover {
    background-color: #ffd4f9;
    color: Black;
}

/* Rank Icon Styles */
.rank-icon {
    display: inline-block;
    width: 16px;
    text-align: center;
    margin-right: 2px;
    flex-shrink: 0;
}

/* Rank Classes for different user types */
.rank-ircop {
    font-weight: normal;
    color: #418f47;
}

.rank-owner {
    font-weight: normal;
    color: #418f47;
}

.rank-superadmin {
    font-weight: normal;
    color: #418f47;
}

.rank-admin {
    font-weight: normal;
    color: #418f47;
}

.rank-rj {
    font-weight: normal;
    color: #418f47;
}

.rank-vip {
    font-weight: normal;
    color: #418f47;
}

.rank-normal {
    font-weight: normal;
    color: #418f47;
}

/* Owner rank GIF styling */
.rank-gif {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 2px;
    flex-shrink: 0;
}

/* Private Message Styles - Removed background styling */

/* Notification styles */
.tab.has-activity {
    background-color: #ffffcc;
    font-weight: bold;
}

.tab.has-private-message {
    background-color: #ffcccc;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        overflow: hidden;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }

    .chat-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        display: flex;
        flex-direction: column;
        max-height: 100vh;
        max-height: 100dvh;
    }

    .chat-header {
        padding: 1px 3px;
        height: auto;
        min-height: 30px;
        flex-shrink: 0;
    }

    .app-title {
        font-size: 11px;
    }

    .tab {
        font-size: 9px;
        padding: 1px 3px;
        min-width: 30px;
        max-width: 50px;
        height: 16px;
        flex-shrink: 0;
    }

    .tabs-container {
        max-width: calc(100vw - 80px);
    }

    .chat-main {
        flex: 1;
        min-height: 0;
        display: flex;
    }

    .messages-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
        border-right: 1px solid #067910;
    }

    .messages-container {
        flex: 1;
        overflow-y: auto;
        font-size: 1.4em;
        line-height: 1.7em;
        padding: 2px;
    }

    .users-panel {
        width: 70px;
        border-left: 3px solid #067910;
        display: flex;
        flex-direction: column;
    }

    .user-item {
        font-size: 11px;
        padding: 1px 3px;
        line-height: 12px;
        margin-bottom: -1px;
        display: flex;
        align-items: center;
        white-space: nowrap;
        min-width: max-content;
    }

    .inline-option {
        font-size: 10px;
        padding: 1px 4px;
    }

    .input-panel {
        flex-shrink: 0;
        border-top: 4px solid #067910;
        background-color: #f0f0f0;
        padding: 2px;
    }

    #message-input {
        font-size: 14px;
        padding: 1px 4px;
        border: 3px solid #ffffff;
    }

    .toolbar {
        flex-shrink: 0;
        font-size: 9px;
        padding: 6px 2px;
        height: 45px;
        min-height: 45px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .toolbar-btn {
        font-size: 13px;
        padding: 1px 2px;
        margin: 0 1px;
    }

    .emoji-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .message-nick {
        font-size: 18px;
    }

    .message-text {
        font-size: 18px;

    }
}

@media (max-width: 480px) {
    body {
        overflow: hidden;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }

    .chat-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        display: flex;
        flex-direction: column;
        max-height: 100vh;
        max-height: 100dvh;
    }

    .chat-header {
        padding: 1px 3px;
        height: auto;
        min-height: 30px;
        flex-shrink: 0;
    }

    .app-title {
        font-size: 11px;
    }

    .tab {
        font-size: 9px;
        padding: 1px 3px;
        min-width: 30px;
        max-width: 50px;
        height: 16px;
        flex-shrink: 0;
    }

    .tabs-container {
        max-width: calc(100vw - 80px);
        scrollbar-width: thin;
    }

    .chat-main {
        flex: 1;
        min-height: 0;
        display: flex;
    }

    .messages-panel {
        flex: 1;
        display: flex;
        flex-direction: column;
        border-right: 1px solid #067910;
    }

    .messages-container {
        flex: 1;
        overflow-y: auto;
        font-size: 1.4em;
        line-height: 1.7em;
        padding: 2px;
    }

    .users-panel {
        width: 70px;
        border-left: 3px solid #067910;
        display: flex;
        flex-direction: column;
    }

    .user-item {
        font-size: 11px;
        padding: 1px 3px;
        line-height: 12px;
        margin-bottom: -1px;
        display: flex;
        align-items: center;
        white-space: nowrap;
        min-width: max-content;
    }

    .inline-option {
        font-size: 10px;
        padding: 1px 4px;
    }

    .input-panel {
        flex-shrink: 0;
        border-top: 4px solid #067910;
        background-color: #f0f0f0;
        padding: 2px;
    }

    #message-input {
        font-size: 14px;
        padding: 1px 4px;
        border: 3px solid #ffffff;
    }

    .toolbar {
        flex-shrink: 0;
        font-size: 9px;
        padding: 6px 2px;
        height: 45px;
        min-height: 45px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .toolbar-btn {
        font-size: 13px;
        padding: 1px 2px;
        margin: 0 1px;
    }

    .toolbar-separator {
        margin: 0 1px;
    }

    .toolbar-right {
        margin-left: auto;
        font-size: 8px;
    }

    .form-container {
        max-width: 280px;
        padding: 0 20px;
    }

    .emoji-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Keep original message size */
    .message-nick {
        font-size: 18px;
    }

    .message-text {
        font-size: 18px;

    }
}

/* Scrollbar Styles - Square edges */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 0;
}

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

/* Mobile tweak — make users list wider and shrink messages panel */
@media (max-width: 480px) {
  /* Make users-panel a bit wider on small screens */
  .users-panel {
    width: 100px !important;
    flex: 0 0 100px !important;
    min-width: 90px; /* don't let it get smaller than this */
  }

  /* Reduce messages panel to fill remaining space */
  .messages-panel {
    flex: 1 1 calc(100% - 100px) !important;
    max-width: calc(100% - 100px) !important;
  }

  /* Ensure messages container doesn't overflow horizontally */
  .messages-container {
    overflow-x: hidden;
    word-break: break-word;
  }
}

/* Fix PM tabs on mobile - hide user panel and expand messages */
@media (max-width: 768px) {
  /* Hide users panel when JS sets display: none (PM tabs) */
  .users-panel[style*="display: none"] {
    display: none !important;
  }

  /* When users panel is hidden, make messages panel take full width */
  .chat-main:has(.users-panel[style*="display: none"]) .messages-panel {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    border-right: none !important;
  }
}

/* Alternative fallback for browsers that don't support :has() */
@media (max-width: 768px) {
  .messages-panel.full-width {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    border-right: none !important;
  }
}

/* Additional mobile PM fix - ensure users panel is properly hidden */
@media (max-width: 768px) {
  /* When JavaScript hides users panel with style="display: none", ensure it stays hidden */
  .users-panel[style*="display: none"] {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    flex: 0 0 0 !important;
  }

  /* When users panel is hidden, expand messages panel to full width */
  .messages-panel:only-child,
  .chat-main:has(.users-panel[style*="display: none"]) .messages-panel {
    flex: 1 1 100% !important;
    max-width: 100% !important;
    border-right: none !important;
  }
}

/* Rank headings in user list */
.rank-heading {
    font-family: Arial, Helvetica, sans-serif !important;
    background-color: #008000;
    color: white;
    font-size: 10px;
    padding: 2px 4px;
    margin: 1px 0;
    text-align: center;
    border-radius: 0;
}

/* Prevent iOS zoom on input focus */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  select, textarea, input[type="text"], input[type="password"] {
    font-size: 16px !important;
  }
}

/* Hide scrollbars on mobile devices */
@media (max-width: 768px) {
  .users-list::-webkit-scrollbar {
    display: none;
  }

  .users-list {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
  }

  .messages-container::-webkit-scrollbar {
    display: none;
  }

  .messages-container {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
  }
}
/* Performance Optimizations - Step 1 */
.messages-container {
    contain: layout style paint;
    will-change: scroll-position;
    transform: translateZ(0);
}

.users-list {
    contain: layout style paint;
    will-change: scroll-position;
}

.emoji-picker {
    contain: layout style paint;
}

.color-picker {
    contain: layout style paint;
}

