* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #ece7f2;
}

button,
input,
textarea {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.app {
    width: 100%;
    height: 100dvh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f4f1f7;
}

.chat-header {
    height: 72px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;
    padding: 10px 14px;
    background-color: #665cac;
    color: white;
}

.profile-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: white;
    color: #665cac;
    font-size: 16px;
    font-weight: bold;
}

.header-text {
    flex: 1;
    min-width: 0;
}

.header-text h1 {
    margin: 0;
    font-size: 17px;
}

.header-text p {
    margin: 4px 0 0;
    font-size: 12px;
    opacity: 0.85;
}

.menu-button {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background-color: transparent;
    color: white;
    font-size: 28px;
    cursor: pointer;
}

.menu-button:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.chat-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 16px 24px;
    overflow-y: auto;
    scroll-padding-bottom: 24px;
}

.message {
    position: relative;
    width: fit-content;
    max-width: 82%;
    flex-shrink: 0;
    padding: 10px 14px 22px;
    border-radius: 14px;
    font-size: 15px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

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

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

.message.sent.has-options:not(.attachment-message) {
    padding-right: 38px;
}

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

.message-time {
    position: absolute;
    right: 9px;
    bottom: 5px;
    color: #888;
    font-size: 10px;
}

.message-options {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 3;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.35);
    color: #595371;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.65;
}

.message-options:hover,
.message-options:focus-visible {
    background-color: rgba(255, 255, 255, 0.75);
    opacity: 1;
}

.attachment-message .message-options {
    background-color: rgba(0, 0, 0, 0.42);
    color: white;
}

.message-bar {
    position: static;
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 8px;
    padding: 10px;
    padding-bottom: max(
        10px,
        env(safe-area-inset-bottom)
    );
    background-color: white;
    border-top: 1px solid #ddd;
}

.attach-button,
.camera-button,
.send-button {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background-color: transparent;
    color: #665cac;
    font-size: 23px;
    cursor: pointer;
}

.attach-button:hover,
.camera-button:hover {
    background-color: #f1eef8;
}

.send-button {
    background-color: #665cac;
    color: white;
    font-size: 18px;
}

.send-button:hover {
    background-color: #574d9c;
}

.message-input {
    flex: 1;
    height: 42px;
    min-height: 42px;
    max-height: 110px;
    min-width: 0;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 22px;
    outline: none;
    overflow-y: auto;
    resize: none;
    font-size: 15px;
    line-height: 20px;
}

.message-input:focus {
    border-color: #665cac;
    box-shadow: 0 0 0 2px rgba(102, 92, 172, 0.1);
}

.attachment-message {
    min-width: 180px;
    padding: 7px 7px 22px;
    overflow: hidden;
}

.attachment-image {
    display: block;
    width: 100%;
    max-width: 280px;
    max-height: 350px;
    border-radius: 9px;
    object-fit: cover;
    cursor: zoom-in;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 280px;
    padding: 10px 34px 10px 10px;
    border-radius: 10px;
    cursor: pointer;
}

.file-card:hover {
    background-color: rgba(255, 255, 255, 0.35);
}

.file-icon {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: #e54848;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.file-name {
    overflow-wrap: anywhere;
    font-size: 14px;
    font-weight: bold;
}

/*
    Pregled fotografije
*/

.image-viewer[hidden] {
    display: none;
}

.image-viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 50px 20px 20px;
    background-color: rgba(0, 0, 0, 0.92);
}

.image-viewer-image {
    display: block;
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 5px;
    object-fit: contain;
}

.image-viewer-close {
    position: absolute;
    top: 12px;
    right: 18px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 34px;
    line-height: 40px;
    cursor: pointer;
}

.image-viewer-close:hover {
    background-color: rgba(255, 255, 255, 0.28);
}

body.image-viewer-open {
    overflow: hidden;
}

/*
    Pregled PDF dokumenta
*/

.pdf-viewer[hidden] {
    display: none;
}

.pdf-viewer {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    background-color: rgba(0, 0, 0, 0.92);
}

.pdf-viewer-toolbar {
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 16px;
    background-color: #242424;
    color: white;
}

.pdf-viewer-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

.pdf-viewer-open {
    flex-shrink: 0;
    padding: 9px 14px;
    border-radius: 18px;
    background-color: #665cac;
    color: white;
    text-decoration: none;
    white-space: nowrap;
    font-size: 14px;
}

.pdf-viewer-close {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 32px;
    cursor: pointer;
}

.pdf-viewer-frame {
    width: min(1100px, 96vw);
    flex: 1;
    margin: 10px auto 16px;
    border: 0;
    border-radius: 5px;
    background-color: white;
}

/*
    Meni sa radnjama
*/

.action-menu-overlay[hidden] {
    display: none;
}

.action-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px 16px 0;
    background-color: rgba(0, 0, 0, 0.48);
}

.action-menu {
    width: min(460px, 100%);
    padding: 16px;
    border-radius: 20px 20px 0 0;
    background-color: white;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
}

.action-menu-title {
    padding: 2px 6px 14px;
    overflow: hidden;
    color: #666;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.action-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-menu-button,
.action-menu-cancel {
    width: 100%;
    min-height: 48px;
    padding: 11px 16px;
    border: 0;
    border-radius: 12px;
    background-color: #f3f1f8;
    color: #28243d;
    text-align: left;
    font-size: 15px;
    cursor: pointer;
}

.action-menu-button:hover,
.action-menu-cancel:hover {
    background-color: #e9e5f4;
}

.action-menu-button.danger {
    background-color: #fff0f0;
    color: #c52626;
}

.action-menu-button.danger:hover {
    background-color: #ffe1e1;
}

.action-menu-cancel {
    margin-top: 12px;
    background-color: #665cac;
    color: white;
    text-align: center;
    font-weight: bold;
}

.action-menu-cancel:hover {
    background-color: #574d9c;
}

/*
    Kratko obaveštenje
*/

.toast-message {
    position: fixed;
    left: 50%;
    bottom: 90px;
    z-index: 3000;
    max-width: min(90vw, 420px);
    padding: 10px 18px;
    border-radius: 22px;
    background-color: rgba(25, 25, 25, 0.9);
    color: white;
    text-align: center;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 15px);
    transition:
        opacity 0.18s ease,
        transform 0.18s ease;
}

.toast-message.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (min-width: 700px) {
    .action-menu-overlay {
        align-items: center;
        padding: 20px;
    }

    .action-menu {
        border-radius: 20px;
    }
}

@media (max-width: 520px) {
    .chat-area {
        padding: 12px 10px 20px;
    }

    .message {
        max-width: 88%;
    }

    .pdf-viewer-toolbar {
        gap: 8px;
        padding: 8px 10px;
    }

    .pdf-viewer-open {
        padding: 8px 11px;
        font-size: 12px;
    }
}

@media (pointer: coarse) {
    .message-options {
        opacity: 0.8;
    }
}
button:disabled {
    opacity: 0.5;
    cursor: wait;
}
.access-error-message {
    background-color: #ffe5e5 !important;
    color: #9c2020 !important;
}

.message-input:disabled {
    background-color: #f1f1f1;
    cursor: not-allowed;
}

/*
    Instalacija aplikacije na telefon
*/

.install-banner[hidden],
.install-help-overlay[hidden] {
    display: none;
}

.install-banner {
    flex-shrink: 0;
    padding: 10px 12px 0;
    background-color: #f4f1f7;
}

.install-button {
    width: 100%;
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    border: 0;
    border-radius: 17px;
    background: linear-gradient(135deg, #665cac, #514790);
    color: white;
    box-shadow: 0 5px 16px rgba(72, 61, 145, 0.3);
    cursor: pointer;
}

.install-button:active {
    transform: scale(0.99);
}

.install-button-icon,
.install-help-logo {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: white;
    color: #665cac;
    font-size: 16px;
    font-weight: bold;
}

.install-button-text {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    text-align: left;
}

.install-button-text strong {
    font-size: 15px;
    line-height: 1.2;
}

.install-button-text small {
    font-size: 12px;
    opacity: 0.88;
}

.install-button-arrow {
    flex-shrink: 0;
    font-size: 30px;
    line-height: 1;
}

.install-help-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.62);
}

.install-help {
    width: min(430px, 100%);
    padding: 24px;
    border-radius: 22px;
    background-color: white;
    color: #211d38;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.28);
}

.install-help-logo {
    width: 62px;
    height: 62px;
    margin-bottom: 16px;
    background-color: #665cac;
    color: white;
    font-size: 20px;
}

.install-help h2 {
    margin: 0 0 10px;
    font-size: 22px;
    line-height: 1.2;
}

.install-help p {
    margin: 0 0 14px;
    color: #625d72;
    line-height: 1.45;
}

.install-help-steps {
    margin: 0 0 20px;
    padding-left: 25px;
}

.install-help-steps li {
    margin: 0 0 10px;
    padding-left: 4px;
    line-height: 1.4;
}

.install-help-close {
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 13px;
    background-color: #665cac;
    color: white;
    font-weight: bold;
    cursor: pointer;
}
