* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #111;
    color: #fff;
}

button,
input {
    font: inherit;
}

/* LOGIN */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: #1b1b1b;
    padding: 35px 25px;
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
}

.login-icon {
    font-size: 42px;
    margin-bottom: 10px;
}

.login-box h1 {
    margin: 0 0 8px;
    font-size: 25px;
}

.login-box p {
    margin: 0 0 25px;
    color: #999;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-box input {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid #333;
    border-radius: 10px;
    background: #111;
    color: #fff;
    outline: none;
}

.login-box input:focus {
    border-color: #666;
}

.login-box button {
    border: 0;
    padding: 14px;
    border-radius: 10px;
    background: #fff;
    color: #111;
    font-weight: 600;
    cursor: pointer;
}

.error {
    background: #351717;
    color: #ff8d8d;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* CHAT */

.chat-page {
    height: 100dvh;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    background: #111;
}

.chat-header {
    height: 64px;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid #292929;
    background: #171717;
}

.chat-header strong {
    display: block;
    font-size: 16px;
}

#connection-status {
    display: block;
    font-size: 12px;
    color: #75d98a;
    margin-top: 3px;
}

.logout {
    color: #aaa;
    text-decoration: none;
    font-size: 14px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.loading {
    color: #777;
    text-align: center;
    margin-top: 30px;
}

/* PORUKE */

.message {
    position: relative;
    max-width: 78%;
    padding: 10px 13px;
    border-radius: 16px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.message.mine {
    align-self: flex-end;
    background: #fff;
    color: #111;
    border-bottom-right-radius: 5px;
}

.message.theirs {
    align-self: flex-start;
    background: #252525;
    color: #fff;
    border-bottom-left-radius: 5px;
}

.message-text {
    white-space: pre-wrap;
}

.message-time {
    font-size: 10px;
    opacity: 0.5;
    margin-top: 4px;
}

.message-bottom {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* DODATO: SEEN INDIKATOR */
.seen-indicator {
    font-size: 11px;
    margin-left: 6px;
    color: #888;
    font-weight: 500;
}

.seen-indicator.seen {
    color: #4fc3f7;
}

/* SLIKE I VIDEO */

.message-image {
    display: block;
    max-width: 280px;
    max-height: 400px;
    width: auto;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    object-fit: contain; /* Dodato za očuvanje proporcija pri prikazu */
}

/* DODATO: VIDEO STIL U CHATU */
.message-video {
    display: block;
    max-width: 280px;
    max-height: 320px;
    width: auto;
    height: auto;
    border-radius: 12px;
    background: #000;
}

/* MENI ZA BRISANJE */

.message-menu {
    display: none;
    position: absolute;
    right: 0;
    bottom: -42px;
    z-index: 100;
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

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

.message-menu button {
    border: 0;
    background: transparent;
    color: #ff5555;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
}

.message-menu button:hover {
    background: #333;
}

/* INPUT */

.message-form {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid #292929;
    background: #171717;
}

.attachment-buttons {
    display: flex;
    gap: 5px;
}

.attachment-button {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #252525;
    cursor: pointer;
    font-size: 20px;
}

.message-form > input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 42px;
    padding: 0 13px;
    border: 1px solid #333;
    border-radius: 10px;
    background: #111;
    color: #fff;
    outline: none;
}

.message-form > input[type="text"]:focus {
    border-color: #555;
}

#send-button {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 0;
    border-radius: 10px;
    background: #fff;
    color: #111;
    font-size: 20px;
    cursor: pointer;
}

/* DODATO: LIGHTBOX (MODAL ZA PUN EKRAN) */
.media-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.media-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.media-modal-body {
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-modal-body img,
.media-modal-body video {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.8);
    object-fit: contain;
}

.media-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    font-size: 32px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s;
}

.media-modal-close:hover {
    background: rgba(255, 255, 255, 0.4);
}


/* MOBILE */

@media (max-width: 600px) {

    .message {
        max-width: 85%;
    }

    /* Prilagođeno da obuhvati i video na mobitelu */
    .message-image,
    .message-video {
        max-width: 240px;
    }

    .chat-header {
        padding: 0 13px;
    }

    .messages {
        padding: 12px;
    }

    .message-form {
        padding-left: 8px;
        padding-right: 8px;
    }

    .attachment-button,
    #send-button {
        width: 40px;
        height: 40px;
    }

    .message-menu {
        bottom: -42px;
    }
}