/* static/css/serviceobjectmanager.css
   ServiceObject + system_detail UI styles.
   Следует той же системе, что order-blocks.css (.od-* → .so-*).
*/

/* ====== Карточка-секция (вместо 25 копий inline-style) ====== */
.so-section {
    background-color: var(--primary-bg, #fff);
    color: var(--text-color, #000);
    border-radius: 8px;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.so-section__body {
    padding: 1.5rem;
}

.so-section__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.so-section__head h3,
.so-section__head h4 {
    margin: 0;
}

.so-section__icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    background: var(--message-block-bg, #f8f9fa);
    color: var(--info-color, #17a2b8);
    flex-shrink: 0;
}

/* ====== Цветной бейдж статуса/системы (40x40 → .so-status-badge) ====== */
.so-status-badge {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    color: #fff;
    flex-shrink: 0;
    font-size: 1rem;
}

.so-status-badge--sm {
    width: 32px;
    height: 32px;
    margin-right: 10px;
}

.so-status-badge--lg {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    font-size: 1.25rem;
}

/* ====== Круглые иконки-кнопки (38x38) ====== */
.so-circle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.so-circle-btn--sm { width: 32px; height: 32px; font-size: 0.85rem; }
.so-circle-btn--lg { width: 44px; height: 44px; font-size: 1.1rem; }

/* ====== Список заявок (как в order_card_compact) ====== */
.so-list-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--main-bg, #fff);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.so-list-item:hover {
    background: var(--order-link-hover, #c3e6cb);
    border-color: var(--order-link-border, #bee5eb);
    color: inherit;
    text-decoration: none;
}

.so-list-item__body {
    flex: 1 1 auto;
    min-width: 0;
}

.so-list-item__title {
    font-weight: 500;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.so-list-item__meta {
    font-size: 0.85rem;
    color: #6c757d;
}

/* ====== Системы объекта (chips) ====== */
.so-system-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--message-block-bg, #f8f9fa);
    border: 1px solid #e9ecef;
    border-radius: 20px;
    font-size: 0.9rem;
    margin: 4px 6px 4px 0;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.so-system-chip:hover {
    background: var(--order-link-hover, #c3e6cb);
    color: inherit;
    text-decoration: none;
}

.so-system-chip i {
    font-size: 0.95rem;
}

.so-system-chip--active {
    background: var(--info-color, #17a2b8);
    color: #fff;
    border-color: var(--info-color, #17a2b8);
}

/* ====== Header объекта (имя + статус + кнопки) ====== */
.so-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.so-header__title {
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.so-header__meta {
    color: #6c757d;
    font-size: 0.9rem;
    word-break: break-word;
}

.so-header__actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-shrink: 0;
}

/* ====== Адрес с навигатором ====== */
.so-address-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--info-color, #17a2b8);
    text-decoration: none;
}

.so-address-link:hover {
    color: #0d6efd;
    text-decoration: underline;
}

/* ====== Sticky CTA на mobile (создать объект) ====== */
.so-sticky-cta {
    display: none;
}

@media (max-width: 768px) {
    .so-sticky-cta {
        display: block;
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(8px);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
        z-index: 100;
        margin: 0 -16px;
    }

    .so-sticky-cta .btn {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }

    .so-section__body { padding: 1rem; }
    .so-header__title { font-size: 1.25rem; }
    .so-circle-btn--default { width: 44px; height: 44px; }
}

/* ====== Карта превью объекта (Phase C2) ====== */
.so-map-preview {
    width: 100%;
    height: 220px;
    border-radius: 6px;
    overflow: hidden;
    background: #f0f0f0;
    margin-bottom: 1rem;
}

/* ====== Empty state ====== */
.so-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #6c757d;
}

.so-empty i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
    color: #adb5bd;
}

/* ====== Mobile overflow fixes ======
   Issue 2026-07-20: на смартфоне страница «По всем объектам» была шире
   viewport — длинные названия объектов, адреса, secondary-menu вылезали
   за правый край. Эти правила гарантируют, что контент не выходит за 100%.
*/
.so-section,
.so-section__body,
.so-section__head {
    min-width: 0;
    max-width: 100%;
}

.so-list-item,
.so-list-item__body,
.so-list-item__title,
.so-list-item__meta,
.so-header,
.so-header__title,
.so-header__meta,
.so-header__actions {
    min-width: 0;
    max-width: 100%;
}

.so-list-item__title,
.so-list-item__meta,
.so-header__title,
.so-header__meta,
.so-system-chip,
.secondary-menu {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.secondary-menu {
    max-width: 100vw;
    left: 0;
    right: 0;
}

/* Защита от длинных неразрывных строк внутри карточек (truncatechars в шаблоне
   обрезает на 30 символов, но без word-break в CSS текст всё равно может
   растягивать контейнер) */
@media (max-width: 768px) {
    body, html {
        overflow-x: hidden;
    }
    .so-list-item {
        flex-wrap: wrap;
    }
    .so-list-item .badge {
        margin-left: auto;
    }
    /* secondary-menu: разрешаем горизонтальный скролл, но не даём ему
       выйти за viewport (Safari иногда игнорирует overflow-x: auto
       на fixed элементах — явный max-width страхует) */
    .secondary-menu {
        max-width: 100%;
        width: 100%;
    }
}
