:root {
    --primary-color: #5b4bff;
    --secondary-color: #ebedff;
    --text-color: #1f2937;
    --border-color: #d1d5db;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --notice-color: #ef4444;
    --tab-active: #ffffff;
    --tab-inactive: #f3f4f6;
    --background-gradient: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
    --highlight-color: #e6f3ff;
    --tag-highlight-color: #ffeb3b;
    --typing-glow: 0 0 8px rgba(91,75,255,0.7);
    --glow-color: rgba(91,75,255,0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background-gradient);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #8b5cf6 0%, #f97316 100%);
}

.login-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    padding: 40px;
    animation: fadeIn 0.5s ease-in-out;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.login-title {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 30px;
    color: var(--primary-color);
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(91,75,255,0.2);
}

.btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    min-height: 36px;
    transition: background 0.3s ease, transform 0.2s ease;
}

.btn:hover {
    background: #4c3ad9;
    transform: translateY(-2px);
}

.chat-container {
    display: none;
    width: 100vw;
    height: 100vh;
    background: white;
    overflow: hidden;
    flex-direction: column;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}

.chat-header {
    background: linear-gradient(90deg, #5b4bff 0%, #ec4899 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-title {
    font-size: 16px;
    font-weight: 500;
}

.connection-status {
    display: flex;
    align-items: center;
    font-size: 14px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 2s infinite ease-in-out;
}

.connected { background: var(--success-color); }
.disconnected { background: var(--error-color); }
.connecting { background: #f59e0b; }

.tab-bar {
    display: flex;
    background: var(--secondary-color);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    padding: 6px;
    flex-shrink: 0;
}

.tab {
    padding: 8px 14px;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 6px;
    background: var(--tab-inactive);
    display: flex;
    align-items: center;
    margin-right: 6px;
    font-size: 14px;
    min-height: 44px;
    transition: all 0.3s ease;
}

.tab.active {
    background: var(--tab-active);
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tab.unread {
    font-weight: bold;
    color: var(--primary-color);
    position: relative;
}

.tab.unread.glowing {
    animation: glow 1.5s infinite ease-in-out;
}

.tab.unread::after {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--error-color);
    border-radius: 50%;
    position: absolute;
    top: 4px;
    right: 4px;
}

.close-tab {
    margin-left: 6px;
    color: var(--notice-color);
    font-size: 12px;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-tab:hover {
    background: var(--border-color);
}

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

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9fafb;
    min-width: 200px;
}

.message {
    margin-bottom: 4px;
    line-height: 1.2;
    word-wrap: break-word;
    padding: 8px 10px;
    border-radius: 10px;
    background: white;
    animation: slideIn 0.3s ease-in-out;
    transition: background 0.3s ease, transform 0.2s ease;
}

.message:hover {
    background: #f0f2ff;
    transform: scale(1.01);
}

.message.tagged {
    background: var(--highlight-color);
}

.nick {
    font-weight: 500;
    cursor: pointer;
}

.nick:hover {
    text-decoration: underline;
}

.tagged-nick {
    background: var(--tag-highlight-color);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: bold;
}

.animated-nick-owner {
    animation: ownerGlow 6s infinite ease-in-out;
}

.animated-nick-superadmin {
    animation: superadminGlow 6s infinite ease-in-out;
}

.animated-nick-admin {
    animation: adminGlow 6s infinite ease-in-out;
}

.animated-nick-vip {
    animation: vipGlow 6s infinite ease-in-out;
}

.notice { 
    color: var(--notice-color);
    font-style: italic; 
    background: #fef2f2; 
}
.error { color: var(--error-color); background: #fef2f2; }
.join { color: var(--success-color); background: #ecfdf5; }
.part, .quit { color: var(--error-color); background: #fef2f2; }
.nick-change { color: #7c3aed; background: #f5f3ff; }
.action { color: var(--notice-color); background: #f0f2ff; }

.nicklist {
    width: 150px;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 10px;
    background: var(--secondary-color);
    transition: width 0.3s ease, opacity 0.3s ease;
    display: none;
}

.nicklist.visible {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.user-count {
    font-weight: 500;
    font-size: 12px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    color: var(--primary-color);
}

.nicklist-section {
    margin-bottom: 10px;
}

.nicklist-label {
    font-weight: 600;
    font-size: 12px;
    color: var(--primary-color);
    margin-bottom: 5px;
    padding-left: 5px;
}

.nickname {
    padding: 3px 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 2px;
    transition: all 0.3s ease;
}

.nickname:hover {
    background: #f0f2ff;
    transform: translateY(-1px);
}

.nickname.typing {
    box-shadow: var(--typing-glow);
    background: #e6f3ff;
}

.nick-prefix {
    margin-right: 4px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.ircop { color: #ff4500; font-weight: bold; }
.owner { 
    color: #ffd700; 
    font-weight: bold; 
    animation: ownerGlow 6s infinite ease-in-out; 
}
.superadmin { 
    color: #00ced1; 
    font-weight: bold; 
    animation: superadminGlow 6s infinite ease-in-out; 
}
.admin { 
    color: #1e90ff; 
    font-weight: bold; 
    animation: adminGlow 6s infinite ease-in-out; 
}
.rj { color: #ff69b4; font-weight: normal; }
.vip { 
    color: #32cd32; 
    font-weight: normal; 
    animation: vipGlow 6s infinite ease-in-out; 
}
.normal { color: var(--text-color); font-weight: normal; }

.context-menu {
    position: absolute;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    z-index: 100;
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}

.context-menu-item {
    padding: 8px 15px;
    cursor: pointer;
    transition: background 0.2s ease;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.context-menu-item:hover {
    background: var(--secondary-color);
}

.input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    background: white;
    flex-direction: column;
    flex-shrink: 0;
}

.input-toolbar {
    display: flex;
    margin-bottom: 5px;
    gap: 5px;
    flex-wrap: wrap;
}

.format-btn {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    min-height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.format-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.message-input-container {
    display: flex;
    width: 100%;
    background: #f9fafb;
    border-radius: 8px;
    padding: 5px;
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    background: transparent;
}

.message-input:focus {
    outline: none;
}

.send-button {
    margin-left: 10px;
    padding: 0 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    min-height: 36px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.send-button:hover {
    background: #4c3ad9;
}

.emoji-picker, .color-picker {
    position: absolute;
    bottom: 60px;
    left: 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    width: 250px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    animation: fadeIn 0.2s ease-in-out;
}

.emoji-category {
    font-weight: 500;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
}

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

.emoji {
    width: 30px;
    height: 30px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.emoji:hover {
    transform: scale(1.2);
}

.messages-container .emoji {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    object-fit: contain;
}

.color-option {
    width: 20px;
    height: 20px;
    display: inline-block;
    margin: 2px;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
    min-height: 36px;
    min-width: 36px;
}

.irc-color-black { color: #000000; }
.irc-color-dark-blue { color: #00007f; }
.irc-color-dark-green { color: #009300; }
.irc-color-light-red { color: #ff0000; }
.irc-color-dark-red { color: #7f0000; }
.irc-color-magenta { color: #9c009c; }
.irc-color-orange { color: #fc7f00; }
.irc-color-yellow { color: #ffff00; }
.irc-color-light-green { color: #00fc00; }
.irc-color-cyan { color: #009393; }
.irc-color-light-cyan { color: #00ffff; }
.irc-color-light-blue { color: #0000fc; }
.irc-color-light-magenta { color: #ff00ff; }
.irc-color-gray { color: #7f7f7f; }
.irc-color-light-gray { color: #d2d2d2; }
.irc-color-white { color: #ffffff; }

.irc-bold { font-weight: bold; }
.irc-underline { text-decoration: underline; }
.irc-italic { font-style: italic; }
.irc-strikethrough { text-decoration: line-through; }
.irc-monospace { font-family: monospace; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px var(--glow-color); }
    50% { box-shadow: 0 0 15px var(--glow-color); }
    100% { box-shadow: 0 0 5px var(--glow-color); }
}

@keyframes ownerGlow {
    0% { color: #ffd700; text-shadow: 0 0 5px #ffd700; }
    33% { color: #ff4500; text-shadow: 0 0 5px #ff4500; }
    66% { color: #dc143c; text-shadow: 0 0 5px #dc143c; }
    100% { color: #ffd700; text-shadow: 0 0 5px #ffd700; }
}

@keyframes superadminGlow {
    0% { color: #00ced1; text-shadow: 0 0 5px #00ced1; }
    33% { color: #20b2aa; text-shadow: 0 0 5px #20b2aa; }
    66% { color: #4682b4; text-shadow: 0 0 5px #4682b4; }
    100% { color: #00ced1; text-shadow: 0 0 5px #00ced1; }
}

@keyframes adminGlow {
    0% { color: #1e90ff; text-shadow: 0 0 5px #1e90ff; }
    33% { color: #6a5acd; text-shadow: 0 0 5px #6a5acd; }
    66% { color: #4b0082; text-shadow: 0 0 5px #4b0082; }
    100% { color: #1e90ff; text-shadow: 0 0 5px #1e90ff; }
}

@keyframes vipGlow {
    0% { color: #32cd32; text-shadow: 0 0 5px #32cd32; }
    33% { color: #adff2f; text-shadow: 0 0 5px #adff2f; }
    66% { color: #9acd32; text-shadow: 0 0 5px #9acd32; }
    100% { color: #32cd32; text-shadow: 0 0 5px #32cd32; }
}

@media (max-width: 768px) {
    .login-box {
        padding: 20px;
        max-width: 90%;
    }
    .chat-container {
        width: 100vw;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    .chat-header {
        padding: 10px 15px;
    }
    .chat-title {
        font-size: 14px;
    }
    .messages-container {
        padding: 10px;
    }
    .nicklist {
        width: 100px;
        padding: 8px;
    }
    .nickname {
        padding: 2px 6px;
        font-size: 11px;
    }
    .nick-prefix {
        width: 14px;
        height: 14px;
        margin-right: 3px;
    }
    .user-count {
        font-size: 11px;
    }
    .nicklist-label {
        font-size: 11px;
    }
    .tab {
        padding: 6px 12px;
        font-size: 13px;
        min-height: 36px;
    }
    .close-tab {
        font-size: 11px;
        width: 12px;
        height: 12px;
    }
    .message-input {
        font-size: 14px;
        padding: 10px 12px;
    }
    .send-button {
        padding: 0 12px;
        font-size: 13px;
        min-height: 36px;
    }
    .input-area {
        padding: 8px;
    }
    .format-btn {
        padding: 3px 6px;
        min-height: 36px;
        min-width: 36px;
    }
    .emoji-picker, .color-picker {
        width: 200px;
        max-height: 150px;
        bottom: 50px;
    }
    .emoji {
        width: 25px;
        height: 25px;
    }
}

@media (min-width: 769px) {
    .chat-container {
        width: 100vw;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
}
