html, body {
    height: 100%;
    margin: 0;
    font-family: "Segoe UI", Roboto, sans-serif;
    background-color: #f5f6fa;
    color: #1f1f1f;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 {
    margin: 0 0 0.5rem;
    font-weight: 600;
}

.hidden {
    display: none !important;
}

.card {
    max-width: 320px;
    margin: 10vh auto;
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.card form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    gap: 0.35rem;
}

input {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #cdd4e0;
    font-size: 1rem;
}

input:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.2);
}

textarea,
select {
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #cdd4e0;
    font-size: 1rem;
    font-family: inherit;
}

textarea:focus,
select:focus {
    outline: none;
    border-color: #5a67d8;
    box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.2);
}

button {
    padding: 0.65rem 1.2rem;
    border: none;
    border-radius: 8px;
    background: #5a67d8;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

button:hover {
    background: #4c51bf;
}

.error {
    color: #d93025;
    font-size: 0.9rem;
}

.info-message {
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

#app {
    min-height: 100vh;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
#app-view {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    row-gap: 1rem;
    padding-bottom: 2rem;
}

.layout {
    flex: 0 0 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 280px;
    gap: 1rem;
    padding: 0.5rem 1.5rem 0.5rem;
    grid-auto-rows: minmax(0, 1fr);
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
    position: relative;
    z-index: 2;
}

.chats-panel,
.messages-panel,
.cart-panel {
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.messages-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-header {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

.messages-container {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.5rem;
    overscroll-behavior: contain;
}

.message-composer {
    margin-top: 0.75rem;
    margin-right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-self: stretch;
}

.message-composer textarea {
    resize: vertical;
    min-height: 72px;
    max-height: 200px;
    width: calc(100% - 0.5rem);
    align-self: flex-start;
    box-sizing: border-box;
}

.composer-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-self: flex-end;
}

.composer-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.composer-actions button.secondary {
    background: #edf2ff;
    color: #1f1f1f;
    font-size: 1.1rem;
    padding: 0.55rem 0.75rem;
}

.composer-actions button.secondary:hover {
    background: #dce4ff;
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f4ff;
    border: 1px solid #cdd4e0;
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
    max-width: 100%;
    overflow: hidden;
}

.attachment-preview button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #4a5568;
}

.attachment-preview button:hover {
    color: #d93025;
}

.chat-message {
    padding: 0.75rem;
    border-radius: 10px;
    background: #f3f4fc;
    border: 1px solid transparent;
}

.chat-message.user {
    background: #e1f4ff;
    border-color: #bee3f8;
}

.chat-message.manager {
    background: #edf2ff;
    border-color: #c3dafe;
}

.chat-message .meta {
    font-size: 0.8rem;
    color: #5f6b7a;
    margin-bottom: 0.35rem;
}

.chat-message .body {
    font-size: 0.95rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-message .attachment-link {
    margin-top: 0.5rem;
    display: inline-block;
    color: #4c51bf;
}

.chat-message .attachment-link:hover {
    text-decoration: underline;
}

.chat-message .attachment-image {
    margin-top: 0.5rem;
    max-width: 100%;
    max-height: 220px;
    border-radius: 10px;
    border: 1px solid #d1d5f0;
    object-fit: contain;
    cursor: zoom-in;
}

.chat-message .label {
    font-weight: 600;
}

.chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
    overscroll-behavior: contain;
}

#cart-container {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.5rem;
    overscroll-behavior: contain;
}

.chat-item {
    padding: 0.75rem;
    border-radius: 10px;
    background: #f7f8fc;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    border: 1px solid transparent;
}

.chat-item:hover {
    background: #eef1ff;
}

.chat-item.active {
    background: #4c51bf;
    color: #fff;
    transform: translateX(4px);
}

.chat-item .subtitle {
    font-size: 0.85rem;
    color: inherit;
    opacity: 0.8;
}

.cart-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cart-item {
    border: 1px solid #d8dce6;
    border-radius: 10px;
    padding: 0.75rem;
    background: #f9f9fc;
}

.cart-item h4 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
}

.cart-item .price {
    font-weight: 600;
}

.cart-total {
    margin-top: auto;
    font-size: 1rem;
    font-weight: 600;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.placeholder {
    color: #7c8ca1;
    text-align: center;
    margin-top: 2rem;
}

.drop-zone-active {
    box-shadow: inset 0 0 0 2px rgba(90, 103, 216, 0.4);
    background-color: rgba(90, 103, 216, 0.08);
}

body.modal-open {
    overflow: hidden;
}

.image-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.image-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
    animation: modal-fade-in 0.18s ease-out;
}

.image-modal-content img {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    background: #000;
}

.image-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    border: none;
    background: rgba(15, 23, 42, 0.65);
    color: #fff;
    font-size: 1.2rem;
    padding: 0.25rem 0.45rem;
    border-radius: 999px;
    cursor: pointer;
    line-height: 1;
}

.image-modal-close:hover {
    background: rgba(15, 23, 42, 0.85);
}

@keyframes modal-fade-in {
    from {
        transform: scale(0.97);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.admin-panel {
    background: #fff;
    margin: 0 1.5rem 0;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.admin-form .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.manager-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.25rem;
    overscroll-behavior: contain;
}

.manager-list li {
    padding: 0.75rem 0.85rem;
    background: #f4f6ff;
    border-radius: 10px;
    border: 1px solid #d7dcf5;
    font-size: 0.95rem;
}

.manager-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.manager-list-item .manager-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.92rem;
}

.manager-list-item .manager-meta .manager-id {
    color: #64748b;
    font-size: 0.85rem;
}

.manager-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.manager-delete {
    border: none;
    background: #fee2e2;
    color: #b91c1c;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.manager-delete:hover {
    background: #fecdd3;
    color: #7f1d1d;
}

.manager-delete:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .chats-panel,
    .messages-panel,
    .cart-panel {
        min-height: auto;
    }

    .cart-panel {
        order: 3;
    }
}
