/* Additional styles for the app */

#auth-section {
    font-size: 0.9em;
    z-index: 1000;
    position: absolute;
    top: 10px;
    right: 10px;
}

#auth-section button {
    font-size: 0.9em !important;
}

#auth-section button {
    padding: 5px 10px;
    background: #b01;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#auth-section button:hover {
    background: #901;
}

#chat-container {
    font-size: 0.9em;
}

#chat-messages {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 10px;
    padding: 5px;
    background: #f9f9f9;
    border-radius: 3px;
}

#chat-messages .chat-message {
    margin: 8px 0;
    padding: 10px;
    background: white;
    border-radius: 5px;
    border-left: 3px solid #b01;
    max-width: 100%;
    box-sizing: border-box;
}

#chat-messages .chat-message-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 5px;
}

#chat-messages .chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #b01;
    object-fit: cover;
    background: #f0f0f0;
}

#chat-messages .chat-username {
    font-weight: bold;
    color: #b01;
    flex: 1;
}

#chat-messages .chat-time {
    font-size: 0.75em;
    color: #666;
}

#chat-messages .chat-message-text {
    margin-left: 40px;
    /* предотвращаем появление горизонтальной прокрутки у длинных сообщений */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/* Quill Editor Toolbar Tooltips */
.ql-toolbar button,
.ql-toolbar .ql-picker-label {
    position: relative;
}

.ql-toolbar button:hover::after,
.ql-toolbar .ql-picker-label:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    white-space: nowrap;
    font-size: 12px;
    margin-bottom: 5px;
    z-index: 1000;
    pointer-events: none;
}

.ql-toolbar button:hover::before,
.ql-toolbar .ql-picker-label:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% - 5px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    z-index: 1000;
    pointer-events: none;
}

#chat-input-container {
    display: flex;
    gap: 5px;
}

#chat-input {
    flex: 1;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

#chat-send {
    padding: 5px 10px;
    background: #b01;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#chat-send:hover {
    background: #901;
}

#editor-modal {
    z-index: 1000;
}

#editor-modal > div {
    max-height: 90vh;
    overflow-y: auto;
}

#editor-modal button {
    padding: 8px 15px;
    background: #b01;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#editor-modal button:hover {
    background: #901;
}

#editor-modal input,
#editor-modal select {
    border: 1px solid #ccc;
    border-radius: 3px;
}

#action-area button {
    padding: 8px 15px;
    background: #b01;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 10px;
}

#action-area button:hover {
    background: #901;
}

/* Quill editor styles */
#editor-quill {
    background: white;
}

.ql-editor {
    min-height: 300px;
}

/* Блок фото+подпись в редакторе — справа сверху, как в factor/Shut */
.ql-editor .scp-image-block {
    border: solid 1px #666;
    box-shadow: 0 1px 6px rgba(0,0,0,.25);
    width: 300px;
    float: right;
    clear: right;
    margin: 0 0 1em 1.5em;
    cursor: pointer;
    background: #fff;
}
.ql-editor .scp-image-block.block-right {
    float: right;
    clear: right;
}
.ql-editor .scp-image-block img {
    border: 0;
    width: 100%;
    display: block;
    pointer-events: none;
}
.ql-editor .scp-image-block .scp-image-caption {
    background-color: #eee;
    border-top: solid 1px #666;
    padding: 6px 10px;
    font-size: 80%;
    font-weight: bold;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}
.ql-editor .scp-image-block .scp-image-caption p {
    margin: 0;
    padding: 0;
}
.ql-editor .scp-image-block:hover {
    outline: 2px solid #b01;
    outline-offset: 2px;
}

/* Menu item styles - prevent long titles from wrapping */
.menu-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-item a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Ensure images are displayed correctly */
#page-content img {
    max-width: 100%;
    height: auto;
}

/* Блок фото+подпись в документе — справа сверху */
#page-content .scp-image-block {
    border: solid 1px #666;
    box-shadow: 0 1px 6px rgba(0,0,0,.25);
    width: 300px;
    float: right;
    clear: right;
    margin: 0 0 1em 1.5em;
    background: #fff;
}
#page-content .scp-image-block.block-right {
    float: right;
    clear: right;
}
#page-content .scp-image-block img {
    border: 0;
    width: 100%;
    display: block;
}
#page-content .scp-image-block .scp-image-caption {
    background-color: #eee;
    border-top: solid 1px #666;
    padding: 6px 10px;
    font-size: 80%;
    font-weight: bold;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}
#page-content .scp-image-block .scp-image-caption p {
    margin: 0;
    padding: 0;
}

/* Блок новостей на главной */
#news-section h2 {
    font-size: 1.25rem;
}
#news-scroll-wrap {
    scrollbar-width: thin;
}
#news-scroll-wrap::-webkit-scrollbar {
    height: 8px;
}
#news-scroll-wrap::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}
#news-scroll-wrap::-webkit-scrollbar-thumb {
    background: #b01;
    border-radius: 4px;
}
#news-cards a:hover {
    text-decoration: none;
}

/* Responsive — оптимизация под мобильные устройства */
@media (max-width: 767px) {
    #mobile-menu-btn {
        display: block !important;
    }
    
    #side-bar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        overflow-y: auto;
        z-index: 1000;
        background: #f9f9f9;
        border-right: 2px solid #b01;
        margin: 0;
        padding: 15px;
        box-sizing: border-box;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    
    body.mobile-menu-open #side-bar {
        transform: translateX(0);
    }
    
    body.mobile-menu-open #mobile-menu-overlay {
        display: block;
    }
    
    #mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }
    
    #auth-section {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        text-align: right;
        margin-bottom: 10px;
    }
    
    #auth-section button {
        padding: 8px 12px;
        min-height: 44px;
        font-size: 1em;
    }
    
    #chat-container {
        margin-top: 10px;
        display: block !important;
    }
    
    #container-wrap,
    #content-wrap {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    #main-content {
        padding: 10px !important;
        margin-left: 0 !important;
    }
    
    .menu-item a {
        padding: 12px 10px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    #page-content {
        font-size: 1rem;
        line-height: 1.5;
        word-wrap: break-word;
    }
    
    #page-content img {
        max-width: 100%;
        height: auto;
    }
    
    .scp-image-block {
        max-width: 100% !important;
        width: 100% !important;
        float: none !important;
        margin: 10px 0 !important;
    }
    
    #editor-modal {
        padding: 10px 0;
        align-items: flex-start;
    }
    
    #editor-modal > div {
        min-width: 95% !important;
        width: 95% !important;
        margin: 10px auto;
        padding: 15px;
        max-height: 95vh;
        overflow-y: auto;
    }
    
    #editor-quill {
        min-height: 280px !important;
    }
    
    #editor-form input,
    #editor-form select,
    #editor-form button {
        min-height: 44px;
        font-size: 16px;
    }
    
    #profile-page #main-content,
    #login-page #main-content {
        padding: 15px !important;
        max-width: 100%;
    }
    
    #profile-page .page-title h1,
    #login-page .page-title h1 {
        font-size: 1.25rem;
    }
    
    #action-area button {
        padding: 12px 16px;
        min-height: 44px;
        margin-bottom: 8px;
        font-size: 1em;
    }
    
    #chat-input-container {
        flex-wrap: wrap;
    }
    
    #chat-input, #chat-send {
        min-height: 40px;
    }
    
    #chat-send {
        min-height: 40px;
    }

    /* уменьшаем высоту области сообщений чата на телефонах,
       чтобы он не занимал почти весь экран */
    #chat-messages {
        max-height: 250px !important;
        min-height: 150px !important;
    }

    /* иконки тулбара Quill поменьше и не вылезают за границы кнопок */
    .ql-toolbar.ql-snow button,
    .ql-toolbar.ql-snow .ql-picker-label {
        font-size: 0.9em;
    }
}

/* Чат скрыт для неавторизованных (в т.ч. в мобильном меню) */
body[data-auth="guest"] #chat-container {
    display: none !important;
}

/* Редактор Quill: тулбар не вылезает за кнопки на мобильных */
@media (max-width: 767px) {
    .ql-toolbar.ql-snow {
        flex-wrap: wrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 6px 4px;
    }
    .ql-toolbar .ql-formats {
        margin-right: 8px;
        margin-bottom: 4px;
    }
}

/* Общий вид кнопок тулбара Quill */
.ql-toolbar.ql-snow button,
.ql-toolbar.ql-snow .ql-picker-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    min-width: 28px;
    height: 28px;
    box-sizing: border-box;
    color: #222 !important;
}

.ql-toolbar.ql-snow button svg,
.ql-toolbar.ql-snow .ql-picker-label svg {
    stroke: #222 !important;
}

.ql-toolbar.ql-snow button:hover,
.ql-toolbar.ql-snow .ql-picker-label:hover {
    background-color: #f0f0f0;
}

@media (max-width: 480px) {
    #auth-section button {
        padding: 6px 10px;
        font-size: 0.85em;
    }
    
    #page-title {
        font-size: 1.1rem;
    }
}

/* Удобная зона нажатия для кнопок на тач-устройствах */
button, .menu-item a, #action-area a {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Немного более серый фон сайта */
body {
    background-color: #f2f2f2;
}

/* Таблицы, вставленные из редактора */
.ql-editor .scp-table,
#page-content .scp-table {
    border-collapse: collapse;
    width: 100%;
    max-width: 100%;
    margin: 12px 0;
    background: #fafafa;
}

.ql-editor .scp-table th,
.ql-editor .scp-table td,
#page-content .scp-table th,
#page-content .scp-table td {
    border: 1px solid #ccc;
    padding: 6px 8px;
    text-align: left;
}

.ql-editor .scp-table thead th,
#page-content .scp-table thead th {
    background: #e8e8e8;
    font-weight: bold;
}

/* Горизонтальные разделители «отступы» */
.ql-editor .scp-divider,
#page-content .scp-divider {
    border: 0;
    border-top: 1px dashed #aaa;
    margin: 16px 0;
}

/* Награды в профиле */
.awards-grid .award-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 96px;
    text-align: center;
}

.awards-grid .award-badge {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid #b01;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.awards-grid .award-badge img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.awards-grid .award-badge-title {
    font-size: 0.75em;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 767px) {
    #profile-awards-list,
    #profile-public-awards-list {
        overflow-x: auto;
        justify-content: flex-start !important;
        padding-bottom: 6px;
    }
    .awards-grid .award-item {
        flex: 0 0 auto;
        margin-right: 4px;
    }
}
