/* Web IRC Client Styles - Debauched Tea Party Theme */
/* Fixed positioning to pin between header (74px) and radio player (60px) */
/* IMPORTANT: All IRC styles are scoped to #web-irc-container to prevent conflicts */
#web-irc-container {
    position: fixed !important;
    top: 74px !important; /* Navigation height */
    bottom: 60px !important; /* Radio player height */
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    /* Height is automatically calculated from top and bottom */
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    border-radius: 0;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: row !important; /* Sidebar and main side by side */
    z-index: 1200 !important; /* Below nav (1202) and radio (1201), above content */
    isolation: isolate !important; /* Create new stacking context */
    box-sizing: border-box !important;
}

/* Account for admin bar - adjust top position */
.admin-bar #web-irc-container {
    top: calc(32px + 74px) !important; /* Admin bar (32px) + Navigation (74px) */
}

@media screen and (max-width: 782px) {
    .admin-bar #web-irc-container {
        top: calc(46px + 74px) !important; /* Mobile admin bar (46px) + Navigation (74px) */
    }
}

/* Hide header */
.irc-header {
    display: none !important;
}

.irc-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
}

.irc-status-container {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.irc-status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    background-color: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.irc-status-indicator.connected {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* Container styles moved to top - this is now the main wrapper */

.irc-sidebar {
    width: 200px;
    min-width: 200px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0;
    overflow: hidden !important;
    flex-shrink: 0;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 100% !important;
    align-items: stretch;
    position: relative;
    transition: width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease, padding 0.3s ease, border 0.3s ease;
}

.irc-sidebar-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.6);
    cursor: default;
}

.irc-sidebar-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    flex: 1;
}

.irc-sidebar-toggle {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, color 0.2s ease, background-color 0.2s ease;
    border-radius: 4px;
    margin-left: 8px;
}

.irc-sidebar-toggle:hover {
    color: rgba(255, 255, 255, 0.9);
    background-color: rgba(59, 130, 246, 0.2);
}

.irc-sidebar-toggle[aria-expanded="false"] .irc-toggle-icon {
    transform: rotate(180deg);
}

.irc-sidebar-toggle[aria-expanded="true"] .irc-toggle-icon {
    transform: rotate(0deg);
}

.irc-toggle-icon {
    transition: transform 0.3s ease;
    width: 16px;
    height: 16px;
}

/* Expand button - shown when sidebar is collapsed */
/* Positioned outside container to escape isolation stacking context */
.irc-sidebar-expand {
    position: fixed !important;
    left: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-left: none !important;
    border-radius: 0 8px 8px 0 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    cursor: pointer !important;
    padding: 12px 6px !important;
    z-index: 1204 !important; /* Above everything - nav (1202), radio (1201), container (1200) */
    display: none; /* Remove !important so JavaScript can override */
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(59, 130, 246, 0.1) !important;
    min-width: 32px !important;
    min-height: 48px !important;
    pointer-events: auto !important;
}

.irc-sidebar-expand[style*="display: flex"],
.irc-sidebar-expand[style*="display:flex"] {
    display: flex !important;
}

.irc-sidebar-expand:hover {
    background: rgba(59, 130, 246, 0.3) !important;
    color: white !important;
    padding-left: 8px !important;
}

/* Show expand button when sidebar is collapsed */
/* Button is now a sibling of the container, JavaScript handles visibility */

.irc-server-status {
    display: none !important; /* Hide entire status section */
}

/* Hide all status text and indicator */
.irc-server-status > div {
    display: none !important;
}

/* Hide status indicator completely */
.irc-server-status .irc-status-indicator {
    display: none !important;
}

.irc-userlist {
    flex: 1 1 0% !important; /* Use 0% instead of auto to prevent expansion */
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
    height: 0 !important; /* Force flex to work */
    padding: 15px;
    padding-top: 10px;
}

/* Collapsed state - hide entire sidebar horizontally */
.irc-sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    border-right: none !important;
    overflow: visible !important; /* Allow expand button to show */
}

.irc-sidebar.collapsed .irc-userlist,
.irc-sidebar.collapsed .irc-server-status,
.irc-sidebar.collapsed .irc-sidebar-header {
    display: none !important;
}

/* Expand button visibility is now controlled by JavaScript */

#irc-users {
    flex: 1 1 0% !important; /* Use 0% instead of auto to prevent expansion */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
    max-height: 100% !important; /* Constrain to parent */
    height: 0 !important; /* Force flex to work - this is key */
}

.irc-main {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    background: transparent;
    overflow: hidden !important;
    width: 0; /* Force flex to work */
    position: relative !important;
}

.irc-tab-bar {
    display: flex !important;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 40px !important;
    max-height: 40px !important;
    height: 40px !important;
    flex-shrink: 0 !important;
}

.irc-messages {
    flex: 1 1 0% !important; /* Use 0% instead of auto to prevent expansion */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 15px;
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    margin: 10px;
    min-height: 0 !important;
    max-height: 100% !important; /* Constrain to parent */
    height: 0 !important; /* Force flex to work - this is key */
}

.irc-input {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    flex-shrink: 0 !important;
    margin-top: 0 !important; /* Don't push, let flex handle it */
    height: auto !important;
}

/* Sidebar styles */
.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-section h4 {
    margin: 0 0 10px 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.5px;
}

.sidebar-section p {
    margin: 5px 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    word-break: break-all;
}

/* Server status and userlist styles are now in the sidebar section above */

#irc-users li {
    padding: 6px 8px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

#irc-users li:hover {
    background-color: rgba(59, 130, 246, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

/* Role badges */
.irc-role-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
    min-width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.irc-role-badge[data-role="~"] {
    background-color: #ef4444; /* Red for owner */
}

.irc-role-badge[data-role="&"] {
    background-color: #f59e0b; /* Orange for admin */
}

.irc-role-badge[data-role="@"] {
    background-color: #3b82f6; /* Blue for op */
}

.irc-role-badge[data-role="%"] {
    background-color: #8b5cf6; /* Purple for half-op */
}

.irc-role-badge[data-role="+"] {
    background-color: #10b981; /* Green for voice */
}

/* Tab styles */
.irc-tab {
    padding: 8px 12px;
    cursor: pointer;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    display: flex;
    align-items: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s ease;
}

.irc-tab:hover {
    background: rgba(59, 130, 246, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.irc-tab.active {
    background: rgba(59, 130, 246, 0.2);
    color: rgba(255, 255, 255, 0.9);
    border-bottom: 2px solid #3b82f6;
}

.irc-tab.has-unread {
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
}

.unread-badge {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    margin-left: 8px;
    font-weight: normal;
}

.close-btn {
    margin-left: 8px;
    cursor: pointer;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.6);
    font-size: 16px;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: #ef4444;
}

/* Message styles */
.irc-message {
    margin-bottom: 4px;
    padding: 2px 0;
    word-wrap: break-word;
    color: rgba(255, 255, 255, 0.9);
}

.irc-message.own {
    color: #10b981;
}

.irc-message.mention {
    background-color: rgba(245, 158, 11, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    border-left: 3px solid #f59e0b;
}

.irc-message.system {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

.irc-message.action {
    color: #8b5cf6;
    font-style: italic;
}

.irc-message .meta {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
}

.irc-message .nick {
    font-weight: 600;
    color: #3b82f6;
    cursor: pointer;
    transition: color 0.2s ease;
}

.irc-message .nick:hover {
    color: #60a5fa;
    text-decoration: underline;
}

/* Input styles */
.irc-input-form {
    display: flex;
    gap: 10px;
}

#irc-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: rgba(15, 23, 42, 0.6);
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
}

#irc-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#irc-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

/* Send button - styled like navigation menu items */
.irc-input-form button[type="submit"],
.irc-input button[type="submit"],
#irc-input-form button[type="submit"],
.irc-send-btn {
    padding: 8px 24px !important;
    background: transparent !important;
    color: rgba(255, 255, 255, 0.9) !important;
    border: none !important;
    border-radius: 8px !important;
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    text-decoration: none !important;
    display: inline-block !important;
    white-space: nowrap !important;
    font-family: inherit !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Gradient underline effect */
.irc-input-form button[type="submit"]::before,
.irc-input button[type="submit"]::before,
#irc-input-form button[type="submit"]::before,
.irc-send-btn::before {
    content: '' !important;
    position: absolute !important;
    bottom: 0 !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 0 !important;
    height: 2px !important;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6) !important;
    border-radius: 2px !important;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.irc-input-form button[type="submit"]:hover::before,
.irc-input button[type="submit"]:hover::before,
#irc-input-form button[type="submit"]:hover::before,
.irc-send-btn:hover::before {
    width: 80% !important;
}

.irc-input-form button[type="submit"]:hover,
.irc-input button[type="submit"]:hover,
#irc-input-form button[type="submit"]:hover,
.irc-send-btn:hover {
    background-color: rgba(59, 130, 246, 0.1) !important;
    color: white !important;
    transform: translateY(-1px) !important;
}

.irc-input-form button[type="submit"]:active,
.irc-input button[type="submit"]:active,
#irc-input-form button[type="submit"]:active,
.irc-send-btn:active {
    transform: translateY(0) !important;
}

.irc-input-form button[type="submit"]:focus,
.irc-input button[type="submit"]:focus,
#irc-input-form button[type="submit"]:focus,
.irc-send-btn:focus {
    outline: none !important;
}

/* Context menu */
.user-context-menu {
    position: fixed;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    min-width: 150px;
    font-family: inherit;
}

.user-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.user-context-menu li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.2s ease;
}

.user-context-menu li:hover {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: white;
}

/* Responsive design - Consolidated with mobile styles above */

/* Scrollbar styling - match theme */
.irc-messages::-webkit-scrollbar,
#irc-users::-webkit-scrollbar,
.irc-sidebar::-webkit-scrollbar {
    width: 10px;
}

.irc-messages::-webkit-scrollbar-track,
#irc-users::-webkit-scrollbar-track,
.irc-sidebar::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

.irc-messages::-webkit-scrollbar-thumb,
#irc-users::-webkit-scrollbar-thumb,
.irc-sidebar::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 5px;
}

.irc-messages::-webkit-scrollbar-thumb:hover,
#irc-users::-webkit-scrollbar-thumb:hover,
.irc-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}

/* Responsive Design - Mobile and Tablet */
@media screen and (max-width: 1024px) {
    /* Tablet: Reduce sidebar width */
    .irc-sidebar {
        width: 160px;
        min-width: 160px;
    }
}

@media screen and (max-width: 768px) {
    /* Mobile: Keep horizontal layout, sidebar collapses horizontally */
    #web-irc-container {
        flex-direction: row !important; /* Keep horizontal on mobile */
        /* Height automatically calculated from top and bottom */
    }
    
    .irc-sidebar {
        width: 180px !important;
        min-width: 180px !important;
        max-width: 180px !important;
        height: 100% !important;
        max-height: 100% !important;
        border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
        border-bottom: none !important;
        flex-shrink: 0 !important;
    }
    
    .irc-sidebar.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
        padding: 0 !important;
        border-right: none !important;
    }
    
    .irc-sidebar-expand {
        top: 50% !important; /* Center vertically */
        transform: translateY(-50%) !important;
        z-index: 1204 !important; /* Above everything */
    }
    
    .irc-main {
        width: 100% !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        padding-bottom: 0 !important;
    }
    
    .irc-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding-bottom: 10px !important; /* Space for input */
    }
    
    .irc-input {
        flex-shrink: 0 !important;
        padding: 8px !important;
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
        display: flex !important;
        width: 100% !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
        background: rgba(15, 23, 42, 0.95) !important;
        margin-top: auto !important;
    }
    
    .irc-input input {
        font-size: 14px !important;
        padding: 8px !important;
        flex: 1 !important;
    }
    
    .irc-input button {
        padding: 8px 16px !important;
        font-size: 14px !important;
        flex-shrink: 0 !important;
    }
    
    .irc-userlist {
        max-height: none !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }
    
    #irc-users {
        max-height: none !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }
}

@media screen and (max-width: 480px) {
    /* Small Mobile: Further adjustments */
    .irc-sidebar {
        width: 150px !important;
        min-width: 150px !important;
        max-width: 150px !important;
        padding: 10px !important;
    }
    
    .irc-sidebar.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        max-width: 0 !important;
    }
    
    .irc-userlist {
        max-height: none !important;
        flex: 1 1 auto !important;
    }
    
    #irc-users {
        max-height: none !important;
        flex: 1 1 auto !important;
        font-size: 11px !important;
    }
    
    .irc-userlist h3 {
        font-size: 12px !important;
    }
    
    .irc-messages {
        font-size: 13px !important;
        padding: 8px !important;
    }
    
    .irc-message {
        padding: 6px 0 !important;
    }
    
    #web-irc-container {
        /* Height automatically calculated from top and bottom */
        padding-bottom: 0 !important;
    }
    
    .irc-sidebar-expand {
        top: 50% !important; /* Center vertically */
        transform: translateY(-50%) !important;
        z-index: 1204 !important; /* Above everything */
        padding: 10px 5px !important;
    }
    
    .irc-main {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        padding-bottom: 0 !important;
    }
    
    .irc-messages {
        padding-bottom: 10px !important;
    }
    
    .irc-input {
        padding: 6px !important;
        display: flex !important;
        width: 100% !important;
        position: sticky !important;
        bottom: 0 !important;
        z-index: 10 !important;
        background: rgba(15, 23, 42, 0.95) !important;
        margin-top: auto !important;
    }
    
    .irc-input input {
        font-size: 13px !important;
        padding: 6px !important;
        flex: 1 !important;
    }
    
    .irc-input button {
        padding: 6px 12px !important;
        font-size: 13px !important;
        flex-shrink: 0 !important;
    }
    
    .irc-sidebar-header h3 {
        font-size: 12px !important;
    }
}

/* Animation for new messages */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.irc-message {
    animation: slideIn 0.2s ease-out;
}
