* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    height: 100vh;
    overflow: hidden;
    background-color: #0e1621;
}

.app {
    display: flex;
    height: 100vh;
    width: 100vw;
    max-width: none;
    background-color: #17212b;
}

/* Desktop sidebar */
.sidebar {
    width: 350px;
    background-color: #17212b;
    border-right: 1px solid #1e2c3a;
    display: flex;
    flex-direction: column;
    position: relative;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 15px;
    background-color: #1e2c3a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #2b5278;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.username {
    color: white;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* Menu button */
.menu-btn {
    background: none;
    border: none;
    color: #6e8bb3;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.2s;
}

.menu-btn:hover {
    color: white;
}

/* User menu dropdown */
.user-menu {
    position: absolute;
    top: 70px;
    left: 10px;
    width: 280px;
    background-color: #1e2c3a;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    overflow: hidden;
}

.menu-section {
    padding: 8px 0;
    border-bottom: 1px solid #2b3b4c;
}

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

.menu-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.menu-item:hover {
    background-color: #2b5278;
}

.menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Chats list */
.chats-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #1e2c3a;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

.chat-item:hover {
    background-color: #1e2c3a;
}

.chat-item.active {
    background-color: #2b5278;
}

.chat-item .avatar {
    width: 50px;
    height: 50px;
    font-size: 24px;
}

.chat-item-info {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    color: white;
    font-weight: 500;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-lastmsg {
    color: #6e8bb3;
    font-size: 13px;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    color: #6e8bb3;
    font-size: 11px;
    position: absolute;
    top: 15px;
    right: 15px;
}

/* Chat area styles */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #0e1621;
    min-width: 0; /* Prevent flex overflow */
}

.chat-header {
    padding: 15px 20px;
    background-color: #17212b;
    border-bottom: 1px solid #1e2c3a;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-info .avatar {
    width: 45px;
    height: 45px;
    font-size: 22px;
}

.chat-name {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.chat-status {
    color: #6e8bb3;
    font-size: 12px;
    margin-top: 2px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
}

.message {
    max-width: 65%;
    margin-bottom: 12px;
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.4;
}

.message.received {
    background-color: #17212b;
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.sent {
    background-color: #2b5278;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    text-align: right;
}

/* Typing indicator */
.typing-indicator {
    padding: 12px 20px;
    color: #6e8bb3;
    font-size: 13px;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: #17212b;
    border-top: 1px solid #1e2c3a;
}

.typing-dots {
    animation: typing 1.4s infinite;
}

@keyframes typing {
    0%, 20% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

.message-input-container {
    padding: 15px 20px;
    background-color: #17212b;
    display: flex;
    gap: 10px;
    align-items: center;
}

.attach-btn, .send-btn {
    background: none;
    border: none;
    color: #6e8bb3;
    font-size: 22px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 50%;
    transition: all 0.2s;
}

.attach-btn:hover, .send-btn:hover {
    color: white;
    background-color: #1e2c3a;
}

.message-input {
    flex: 1;
    padding: 12px 18px;
    border: none;
    border-radius: 24px;
    background-color: #1e2c3a;
    color: white;
    outline: none;
    font-size: 15px;
}

.message-input::placeholder {
    color: #6e8bb3;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background-color: #17212b;
    border-radius: 12px;
    width: 500px;
    max-width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid #1e2c3a;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid #1e2c3a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background-color: #17212b;
    z-index: 10;
}

.modal-header h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: #6e8bb3;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-btn:hover {
    color: white;
    background-color: #1e2c3a;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 18px 24px;
    border-top: 1px solid #1e2c3a;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    position: sticky;
    bottom: 0;
    background-color: #17212b;
}

/* Avatar section in modals */
.avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.current-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: #2b5278;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
    border: 3px solid #2b5278;
}

.current-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.avatar-upload {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.avatar-url-input {
    width: 100%;
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.avatar-url-input input {
    flex: 1;
    padding: 10px 12px;
    background-color: #1e2c3a;
    border: 1px solid #2b3b4c;
    border-radius: 6px;
    color: white;
    font-size: 14px;
}

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

.form-group label {
    display: block;
    color: #6e8bb3;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    background-color: #1e2c3a;
    border: 1px solid #2b3b4c;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    transition: border-color 0.2s;
}

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

.btn-primary {
    padding: 10px 20px;
    background-color: #2b5278;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #3a6a9e;
}

.btn-secondary {
    padding: 10px 20px;
    background-color: #1e2c3a;
    border: none;
    border-radius: 8px;
    color: #6e8bb3;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #2b3b4c;
    color: white;
}

.btn-add-message {
    width: 100%;
    padding: 12px;
    background-color: #1e2c3a;
    border: 1px dashed #2b5278;
    border-radius: 8px;
    color: #6e8bb3;
    font-size: 14px;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.2s;
}

.btn-add-message:hover {
    background-color: #2b3b4c;
    color: white;
    border-color: #3a6a9e;
}

/* Editable messages list */
.messages-list {
    max-height: 300px;
    overflow-y: auto;
}

.message-edit-item {
    padding: 12px;
    background-color: #1e2c3a;
    border-radius: 8px;
    margin-bottom: 12px;
}

.message-edit-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.message-sender-select {
    background-color: #2b3b4c;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.message-text-input {
    width: 100%;
    padding: 10px;
    background-color: #2b3b4c;
    border: none;
    border-radius: 6px;
    color: white;
    margin: 8px 0;
    font-size: 14px;
}

.message-delay-input {
    width: 100px;
    padding: 6px;
    background-color: #2b3b4c;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 13px;
}

.remove-message-btn {
    background: none;
    border: none;
    color: #f44336;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.remove-message-btn:hover {
    background-color: rgba(244, 67, 54, 0.2);
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #17212b;
}

::-webkit-scrollbar-thumb {
    background: #2b5278;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a6a9e;
}

/* Events section styles */
.events-section {
    margin-top: 24px;
    border-top: 1px solid #1e2c3a;
    padding-top: 20px;
}

.events-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.events-header label {
    color: #6e8bb3;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-add-event {
    background-color: #2b5278;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-add-event:hover {
    background-color: #3a6a9e;
}

.events-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.event-item {
    background-color: #1e2c3a;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    border-left: 4px solid #2b5278;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.event-trigger {
    color: #6e8bb3;
    font-size: 13px;
    font-weight: 500;
}

.event-actions {
    display: flex;
    gap: 8px;
}

.event-edit-btn, .event-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.event-edit-btn:hover {
    background-color: #2b5278;
    color: white;
}

.event-delete-btn:hover {
    background-color: #f44336;
    color: white;
}

.event-message {
    color: white;
    font-size: 14px;
    margin-bottom: 10px;
    word-wrap: break-word;
    background-color: #2b3b4c;
    padding: 10px;
    border-radius: 6px;
    line-height: 1.4;
}

.event-details {
    display: flex;
    gap: 20px;
    color: #6e8bb3;
    font-size: 12px;
}

/* Form select */
.form-select {
    width: 100%;
    padding: 12px 14px;
    background-color: #1e2c3a;
    border: 1px solid #2b3b4c;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    cursor: pointer;
}

.form-select option {
    background-color: #1e2c3a;
    color: white;
}

/* Textarea */
textarea {
    width: 100%;
    padding: 12px 14px;
    background-color: #1e2c3a;
    border: 1px solid #2b3b4c;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

textarea:focus {
    outline: none;
    border-color: #2b5278;
}

/* Time input */
input[type="time"] {
    width: 100%;
    padding: 12px 14px;
    background-color: #1e2c3a;
    border: 1px solid #2b3b4c;
    border-radius: 8px;
    color: white;
    font-size: 15px;
}

input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.5;
    cursor: pointer;
}

input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Mobile navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #17212b;
    border-top: 1px solid #1e2c3a;
    padding: 8px 12px;
    z-index: 100;
}

.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #6e8bb3;
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
    background: none;
    border: none;
}

.mobile-nav-item.active {
    color: white;
    background-color: #1e2c3a;
}

.mobile-nav-icon {
    font-size: 22px;
}

/* Mobile back button */
.mobile-back-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    margin-right: 5px;
}

/* Responsive styles */
@media screen and (max-width: 768px) {
    .app {
        position: relative;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .chat-area {
        width: 100%;
    }

    .chat-header {
        padding-left: 60px;
        position: relative;
    }

    .mobile-back-btn {
        display: block;
        position: absolute;
        left: 10px;
        top: 50%;
        transform: translateY(-50%);
    }

    .mobile-nav {
        display: block;
    }

    .chat-area {
        padding-bottom: 70px;
    }

    .message-input-container {
        position: sticky;
        bottom: 70px;
        background-color: #17212b;
    }

    .message {
        max-width: 85%;
    }

    /* Adjust modals for mobile */
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .current-avatar {
        width: 80px;
        height: 80px;
        font-size: 40px;
    }

    .avatar-upload {
        flex-direction: column;
        width: 100%;
    }

    .avatar-upload button {
        width: 100%;
    }

    .events-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .btn-add-event {
        width: 100%;
    }

    .event-details {
        flex-direction: column;
        gap: 8px;
    }

    .user-menu {
        position: fixed;
        top: auto;
        bottom: 80px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: 300px;
    }
}

/* Small mobile devices */
@media screen and (max-width: 480px) {
    .sidebar-header {
        padding: 12px;
    }

    .chat-item {
        padding: 12px;
    }

    .chat-item .avatar {
        width: 45px;
        height: 45px;
        font-size: 22px;
    }

    .chat-item-name {
        font-size: 15px;
    }

    .chat-item-lastmsg {
        font-size: 12px;
    }

    .chat-item-time {
        font-size: 10px;
    }

    .messages-container {
        padding: 15px;
    }

    .message {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 14px;
    }

    .message-input-container {
        padding: 10px 15px;
    }

    .message-input {
        padding: 10px 15px;
        font-size: 14px;
    }

    .attach-btn, .send-btn {
        font-size: 20px;
        padding: 6px 8px;
    }

    .mobile-nav-item {
        padding: 6px 10px;
        font-size: 11px;
    }

    .mobile-nav-icon {
        font-size: 20px;
    }
}