/* chat/assets/css/style.css */
* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #f4f0fa;
    color: #2a1f3d;
    font-size: 15px;
}

a { color: #6b21a8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Zmniejszono wysokość górnego paska */
.topbar {
    background: #6b21a8;
    color: #fff;
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px; /* Zmniejszono z 56px */
    border-bottom: 2px solid #4c1d95; /* Cieńsza linia */
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 20px; /* Zmniejszono z 22px */
    color: #fff;
}

.brand .logo {
    background: #a855f7;
    color: #fff;
    width: 32px; /* Zmniejszono z 36px */
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    border: 2px solid #fff;
}

.topbar nav { display: flex; gap: 12px; font-size: 14px; }
.topbar nav a { color: #fff; font-weight: 500; }
.topbar nav a:hover { color: #e9d5ff; text-decoration: none; }

.menu {
    background: #7c3aed;
    padding: 6px 15px; /* Zmniejszono z 8px 20px */
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}
.menu a { color: #fff; font-size: 13px; }
.menu a:hover { color: #f3e8ff; }

.container { max-width: 1200px; margin: 20px auto; padding: 0 16px; }

.card {
    background: #fff;
    border: 2px solid #a855f7;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 6px rgba(107,33,168,0.08);
}

h1, h2, h3 { color: #6b21a8; }

.btn {
    display: inline-block;
    padding: 10px 20px;
    background: #7c3aed;
    color: #fff;
    border: 2px solid #6b21a8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}
.btn:hover { background: #6b21a8; text-decoration: none; }
.btn-danger { background: #dc2626; border-color: #991b1b; }
.btn-danger:hover { background: #991b1b; }
.btn-warn { background: #d97706; border-color: #92400e; }
.btn-warn:hover { background: #92400e; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

input[type=text], input[type=password], input[type=email], textarea, select {
    width: 100%;
    padding: 10px;
    border: 2px solid #c4b5fd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #faf5ff;
    color: #2a1f3d;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #7c3aed;
}

label { display: block; margin-top: 12px; margin-bottom: 4px; font-weight: 600; color: #4c1d95; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.alert-error { background: #fee2e2; border: 1px solid #ef4444; color: #991b1b; }
.alert-success { background: #dcfce7; border: 1px solid #22c55e; color: #166534; }
.alert-info { background: #ede9fe; border: 1px solid #a855f7; color: #5b21b6; }

/* Chat layout */
.chat-wrapper {
    display: grid;
    grid-template-columns: 80% 20%;
    grid-template-rows: auto 1fr auto;
    gap: 0;
    height: calc(100vh - 130px);
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 16px;
}

.chat-header {
    grid-column: 1 / 3;
    background: #6b21a8;
    color: #fff;
    border-radius: 10px 10px 0 0;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid #4c1d95;
    border-bottom: none;
}

.room-btn {
    background: #a855f7;
    color: #fff;
    border: 2px solid #fff;
    padding: 6px 12px; /* Zmniejszono */
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px; /* Dodano */
}

.messages-area {
    background: #fff;
    border-left: 2px solid #a855f7;
    border-right: 1px solid #a855f7;
    overflow-y: auto;
    padding: 12px; /* Zmniejszono z 16px */
}

.users-sidebar {
    background: #faf5ff;
    border-right: 2px solid #a855f7;
    border-top: 2px solid #a855f7;
    overflow-y: auto;
    padding: 10px;
}

.users-sidebar h3 {
    margin: 0 0 8px;
    font-size: 15px;
    color: #6b21a8;
}

.user-item {
    padding: 6px 8px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    background: #fff;
    margin-bottom: 4px;
    border-left: 3px solid #a855f7;
}
.user-item.role-sop { border-left-color: #dc2626; }
.user-item.role-op { border-left-color: #d97706; }
.user-item.role-halfop { border-left-color: #2563eb; }

.role-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: #7c3aed;
    color: #fff;
    font-weight: 700;
}
.role-badge.sop { background: #dc2626; }
.role-badge.op { background: #d97706; }
.role-badge.halfop { background: #2563eb; }

.input-bar {
    grid-column: 1 / 3;
    display: flex;
    gap: 8px; /* Zmniejszono */
    padding: 8px; /* Zmniejszono z 12px */
    background: #f3e8ff;
    border: 2px solid #a855f7;
    border-top: none;
    border-radius: 0 0 10px 10px;
}

.input-bar input { 
    flex: 1; 
    padding: 8px; /* Zmniejszono wewnętrzny padding */
}

.input-bar .btn {
    padding: 8px 16px; /* Węższy przycisk Wyślij */
}

/* --- ZMIANY W WYGLĄDZIE WIADOMOŚCI --- */
.message {
    margin-bottom: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    background: #faf5ff;
    border-left: 3px solid #a855f7;
    font-size: 14px;
    line-height: 1.3;
}

.message .meta {
    font-size: 11px;
    color: #7c3aed;
    margin-bottom: 2px;
}
.message .meta .nick { font-weight: 700; color: #4c1d95; }
.message .meta .time { color: #9333ea; }

.message.deleted { opacity: 0.6; font-style: italic; }

.emoji-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 3px; /* Zmniejszono */
    padding: 6px; /* Zmniejszono */
    background: #fff;
    border: 2px solid #a855f7;
    border-top: none;
    max-height: 70px; /* Zmniejszono z 90px */
    overflow-y: auto;
}
.emoji-panel button {
    background: #f3e8ff;
    border: 1px solid #c4b5fd;
    border-radius: 4px;
    padding: 2px 6px; /* Zmniejszono */
    cursor: pointer;
    font-size: 12px; /* Zmniejszono z 13px */
}
.emoji-panel button:hover { background: #ddd6fe; }

/* Modal pokoi */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(76,29,149,0.55);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border: 3px solid #6b21a8;
    border-radius: 10px;
    padding: 20px;
    width: 90%;
    max-width: 420px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}
.modal h3 { margin-top: 0; }
.room-list { overflow-y: auto; flex: 1; margin: 12px 0; }
.room-list a, .room-list button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px;
    margin-bottom: 6px;
    background: #f3e8ff;
    border: 1px solid #c4b5fd;
    border-radius: 6px;
    cursor: pointer;
    color: #4c1d95;
    font-size: 14px;
}
.room-list a:hover, .room-list button:hover { background: #e9d5ff; }
.room-list .room-active { background: #7c3aed; color: #fff; border-color: #6b21a8; }

footer {
    text-align: center;
    padding: 20px;
    color: #7c3aed;
    font-size: 13px;
    border-top: 2px solid #a855f7;
    background: #faf5ff;
    margin-top: 30px;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid #e9d5ff; text-align: left; }
th { background: #f3e8ff; color: #4c1d95; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-box { background: #f3e8ff; padding: 16px; border-radius: 8px; border: 2px solid #c4b5fd; }
.stat-box .num { font-size: 28px; font-weight: 700; color: #6b21a8; }
.stat-box .lbl { color: #7c3aed; font-size: 13px; }

.inline-form { display: inline; }

/* =========================================
   RESPONSYWNOŚĆ DLA TELEFONÓW (Mobile)
   ========================================= */
@media (max-width: 768px) {
    .chat-wrapper {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 85px); /* Jeszcze trochę więcej miejsca na czat */
        margin: 3px auto;
        padding: 0 4px;
        gap: 0;
    }

    /* Zmniejszony nagłówek pokoju */
    .chat-header {
        border-radius: 8px 8px 0 0;
        padding: 6px 10px; 
        font-size: 13.5px; 
    }

    /* Mniejszy przycisk Pokoju */
    .room-btn {
        padding: 4px 8px;
        font-size: 12px;
    }

    .messages-area {
        flex: 1;
        min-height: 150px;
        border-left: 2px solid #a855f7;
        border-right: 2px solid #a855f7;
        padding: 6px; /* Zmniejszono */
    }

    /* Jeszcze mniejsza czcionka wiadomości */
    .message {
        font-size: 13px; 
        line-height: 1.25;
        padding: 4px 8px;
        margin-bottom: 4px;
    }

    .message .meta {
        font-size: 10.5px;
    }

    /* --- PANEL ONLINE I EMOJI NA MOBILE --- */
    .users-sidebar {
        max-height: none; /* Pozwalamy rosnąć */
        padding: 4px 6px;
        border-bottom: none;
    }

    .users-sidebar h3 {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .mobile-toggle-users {
        padding: 2px 6px;
        font-size: 11px;
        margin-bottom: 2px;
    }

    /* Emotki - dopasowanie do zawartości, brak ucinania */
    .emoji-panel {
        max-height: auto; /* Usunięto sztywne ucinanie */
        padding: 4px;
        gap: 2px;
    }

    .emoji-panel button {
        padding: 2px 5px; /* Jeszcze mniejsze przyciski */
        font-size: 12px; 
    }

    /* Wąski pasek wpisywania wiadomości */
    .input-bar {
        padding: 4px; /* Zmniejszono z 6px */
        border-radius: 0 0 8px 8px;
        gap: 4px;
    }

    .input-bar input {
        font-size: 16px; /* Wymusza brak auto-zoom na iOS */
        padding: 5px 8px; /* Bardzo niski input */
    }

    /* Mniejszy przycisk Wyślij */
    .input-bar .btn {
        padding: 5px 10px;
        font-size: 13px;
    }

    .container {
        padding: 0 8px;
    }

    /* Mniejszy górny pasek na mobile */
    .topbar {
        padding: 0 10px;
        height: 42px; /* Jeszcze niższy */
        flex-wrap: nowrap;
    }

    .topbar .brand {
        font-size: 16px;
    }
    
    .topbar .brand .logo {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }

    .topbar nav {
        gap: 8px;
        font-size: 12px;
    }
    
    /* Reszta poprawek mobilnych */
    .users-sidebar {
        max-height: calc(100vh - 200px); 
        display: flex;
        flex-direction: column;
    }

    #users {
        overflow-y: auto; 
        flex: 1;
        display: none;
        max-height: 100px; 
        border-top: 1px solid #e9d5ff;
        padding-top: 4px;
        margin-top: 2px;
    }

    #users.show-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .user-item {
        margin-bottom: 0;
        padding: 2px 6px;
        font-size: 11px;
    }
    
    .mobile-toggle-users {
        display: inline-block; 
    }
}