/* Стили стикеров */

.sticker-pack-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000030;
    backdrop-filter: blur(4px);
}

.sticker-pack-modal-content {
    background: white;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: stickerPackModalFadeIn 0.2s ease;
}

@keyframes stickerPackModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.sticker-pack-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.sticker-pack-modal .modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
}

.sticker-pack-modal .close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    width: auto;
    padding: 0;
}

.sticker-pack-modal .close-btn:hover {
    color: #333;
}

.sticker-pack-stickers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.sticker-pack-sticker {
    cursor: pointer;
    transition: transform 0.1s;
    text-align: center;
}

.sticker-pack-sticker img,
.sticker-pack-sticker video {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    display: block;
}

.sticker-pack-sticker:hover {
    transform: scale(1.05);
}

.sticker-pack-actions {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.add-pack-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 30px;
    padding: 12px 24px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    width: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.add-pack-btn:hover {
    background: #0056b3;
}

.already-added {
    color: #28a745;
    font-weight: 500;
    font-size: 1rem;
}

.close-sticker-modal {
    color: white;
}

#sticker-preview-list {
    overflow: auto;
    max-height: 300px;
}

.msg--sticker {
    background: transparent !important;
    padding: 0 !important;
    margin: 4px 0;
    box-shadow: none;
    overflow: visible;
}

.msg--sticker .chat-sticker,
.msg--sticker .chat-sticker-video {
    max-width: 260px;
    max-height: 260px;
    width: auto;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
    background: transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
}

/* Ограничение стикеров даже если msg--sticker не проставился */
#chat-window .msg .chat-sticker,
#chat-window .msg .chat-sticker-video,
.mobile-chat-window .msg .chat-sticker,
.mobile-chat-window .msg .chat-sticker-video {
    max-width: 260px;
    max-height: 260px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Если стикер не помечен классом, но у него есть sticker_id */
#chat-window .msg img.chat-media[data-sticker-id]:not([data-sticker-id=""]),
#chat-window .msg video.chat-media[data-sticker-id]:not([data-sticker-id=""]),
.mobile-chat-window .msg img.chat-media[data-sticker-id]:not([data-sticker-id=""]),
.mobile-chat-window .msg video.chat-media[data-sticker-id]:not([data-sticker-id=""]) {
    max-width: 260px;
    max-height: 260px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
}

.sticker-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000020;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-modal.hidden {
    display: none !important;
}

.sticker-modal-content {
    background: rgba(36,49,65,1.0);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    color: white;
}

.sticker-search {
    padding: 12px;
    position: relative;
}

#sticker-search-input {
    width: 100%;
    padding: 8px;
    border: 0px solid #ddd;
    border-radius: 10px;
    background: rgb(28 39 53);
    color: white;
}

.sticker-search-results {
    position: absolute;
    top: 100%;
    left: 12px;
    right: 12px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100001;
    color: black;
}

.sticker-video {
    width: 100%;
    max-height: 800px;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
    background: transparent;
}

.sticker-search-results div {
    padding: 8px 12px;
    cursor: pointer;
}

.sticker-search-results div:hover {
    background: #f0f0f0;
}

.sticker-packs-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.sticker-pack {
    margin-bottom: 24px;
}

.sticker-pack-name {
    font-weight: bold;
    text-align: center;
    margin-bottom: 12px;
    font-size: 1.1rem;
    color: white;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.sticker-item {
    cursor: pointer;
    text-align: center;
}

.sticker-item img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.1s;
}

.sticker-item img:hover {
    transform: scale(1.05);
}

.sticker-empty {
    text-align: center;
    color: #999;
    padding: 20px;
}

.sticker-modal-header-osn h3 {
    margin-left: 10px;
    color: white;
}

.sticker-create-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-create-modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.create-pack-body {
    padding: 16px;
    overflow-y: auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input[type="text"],
.form-group input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.sticker-preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.sticker-preview-item {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.sticker-preview-item img {
    width: 100%;
    height: auto;
    display: block;
}

.sticker-preview-item button {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
}

.sticker-modal-header {
    display: flex;
    margin-right: 10px;
}

.msg.msg--sticker {
    position: relative;
    background: transparent !important;
    background-color: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible;
}

.msg.msg--sticker::before,
.msg.msg--sticker::after {
    display: none !important;
}

.sticker-panel-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sticker-tabs-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) rgba(255, 255, 255, 0.10);
}

.sticker-tabs-row::-webkit-scrollbar {
    height: 8px;
}

.sticker-tabs-row::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.10);
    border-radius: 999px;
}

.sticker-tabs-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.30);
    border-radius: 999px;
}

.sticker-tabs-row::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.45);
}

.sticker-tab {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    border: 1px solid #ddd;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
}

.sticker-tab.active {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.12);
}

.sticker-tab img,
.sticker-tab video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sticker-panel-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.sticker-panel-title-author {
    font-size: 0.85rem;
    font-weight: 500;
    color: #cfcfcf;
}

.sticker-panel-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.sticker-pack-delete-btn {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(220, 38, 38, 0.18);
    color: rgba(254, 202, 202, 1);
}

.sticker-pack-delete-btn:hover {
    background: rgba(220, 38, 38, 0.28);
}

.sticker-panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.sticker-panel-item {
    border-radius: 12px;
    overflow: hidden;
    background: none;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticker-panel-item img,
.sticker-panel-item video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: none;
}

.sticker-panel-empty {
    color: #777;
    padding: 12px 0;
    text-align: center;
}

.sticker-pack-legacy {
    margin-bottom: 16px;
}

@media (max-width: 1000px) {
    .msg--sticker .chat-sticker,
    .msg--sticker .chat-sticker-video,
    #chat-window .msg .chat-sticker,
    #chat-window .msg .chat-sticker-video,
    .mobile-chat-window .msg .chat-sticker,
    .mobile-chat-window .msg .chat-sticker-video,
    #chat-window .msg img.chat-media[data-sticker-id]:not([data-sticker-id=\"\"]),
    #chat-window .msg video.chat-media[data-sticker-id]:not([data-sticker-id=\"\"]),
    .mobile-chat-window .msg img.chat-media[data-sticker-id]:not([data-sticker-id=\"\"]),
    .mobile-chat-window .msg video.chat-media[data-sticker-id]:not([data-sticker-id=\"\"]) {
        max-width: 160px;
        max-height: 160px;
    }
}
