/* =============================================================================
   ИКОНКИ (icons/icons.js)
   Размер задаётся через font-size родителя, цвет — через color.
   ========================================================================== */

.ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    line-height: 1;
    vertical-align: -0.125em;
}

.ic > svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Иконка внутри кнопки с текстом */
button .ic,
.btn .ic,
a.btn .ic,
label .ic {
    margin-right: 0.35em;
}

/* Кнопка без текста — без отступа */
button .ic:only-child,
.btn .ic:only-child,
label .ic:only-child {
    margin-right: 0;
}

/* =============================================================================
 * shared.css — стили общих модулей: редактор примечаний (rich-text.js)
 * и полноэкранный просмотр фото (photo-viewer.js).
 * Подключается и калькулятором, и админкой.
 * ========================================================================== */

/* =============================================================================
   РЕДАКТОР ПРИМЕЧАНИЙ
   ========================================================================== */

.rte {
    border: 1px solid var(--border, #d2d2d7);
    border-radius: 8px;
    background: #fff;
    overflow: visible;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rte:focus-within {
    border-color: var(--primary, #0071e3);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.rte-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    padding: 5px 6px;
    background: var(--bg-elevated, #f5f5f7);
    border-bottom: 1px solid var(--border-light, #e5e5ea);
    border-radius: 7px 7px 0 0;
}

.rte-btn {
    min-width: 27px;
    height: 27px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary, #6e6e73);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    transition: all 0.12s ease;
}

.rte-btn:hover {
    background: #fff;
    border-color: var(--border, #d2d2d7);
    color: var(--text-primary, #1d1d1f);
}

.rte-btn:active,
.rte-menu.open > .rte-menu-btn {
    background: #fff;
    border-color: var(--primary, #0071e3);
    color: var(--primary, #0071e3);
}

.rte-sep {
    width: 1px;
    height: 18px;
    margin: 0 4px;
    background: var(--border, #d2d2d7);
}

.rte-color-chip {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* --- выпадающие меню (размер / цвет / фон) --- */
.rte-menu {
    position: relative;
}

/* position: fixed — чтобы меню не обрезалось прокручиваемым телом модалки.
   Координаты выставляет openMenu() в rich-text.js. */
.rte-menu-body {
    display: none;
    position: fixed;
    z-index: 12100;
    padding: 7px;
    background: #fff;
    border: 1px solid var(--border, #d2d2d7);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

/* Раскладка содержимого задаётся ТОЛЬКО в раскрытом состоянии:
   иначе display: grid/flex перебивает display: none выше
   (та же специфичность, правило ниже по файлу выигрывает) — и меню
   висели раскрытыми постоянно. */
.rte-menu.open > .rte-swatches {
    display: grid;
}

.rte-menu.open > .rte-size-list {
    display: flex;
}

.rte-swatches {
    grid-template-columns: repeat(5, 22px);
    gap: 5px;
}

.rte-swatch {
    width: 22px;
    height: 22px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 5px;
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease;
}

.rte-swatch:hover {
    transform: scale(1.12);
    border-color: var(--primary, #0071e3);
}

/* «Без фона» — перечёркнутый квадрат */
.rte-swatch-none {
    background:
        linear-gradient(to top right,
            transparent calc(50% - 1px), #d70015 50%,
            transparent calc(50% + 1px)) #fff;
}

.rte-size-list {
    flex-direction: column;
    gap: 2px;
    min-width: 130px;
}

.rte-size-item {
    padding: 5px 9px;
    border: none;
    background: transparent;
    border-radius: 5px;
    text-align: left;
    cursor: pointer;
    color: var(--text-primary, #1d1d1f);
    font-family: inherit;
    line-height: 1.25;
}

.rte-size-item:hover {
    background: var(--bg-elevated, #f5f5f7);
    color: var(--primary, #0071e3);
}

/* --- поле ввода --- */
.rte-editor {
    padding: 9px 11px;
    min-height: 72px;
    max-height: 340px;
    overflow-y: auto;
    outline: none;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-primary, #1d1d1f);
    word-break: break-word;
}

.rte-editor.is-empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted, #86868b);
    pointer-events: none;
}

.rte-editor ul,
.rte-editor ol {
    margin: 4px 0;
    padding-left: 22px;
}

.rte-compact .rte-editor {
    min-height: 54px;
    font-size: 13px;
}

/* Готовое примечание в режиме просмотра — те же отступы для списков */
.note-html ul,
.note-html ol {
    margin: 4px 0;
    padding-left: 22px;
}

.note-html p {
    margin: 0 0 5px;
}

.note-html p:last-child {
    margin-bottom: 0;
}

/* =============================================================================
   ПОЛНОЭКРАННЫЙ ПРОСМОТР ФОТО
   ========================================================================== */

body.pv-lock {
    overflow: hidden;
}

.pv-root {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
}

.pv-root.open {
    display: flex;
    animation: pv-fade 0.16s ease-out;
}

@keyframes pv-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.pv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 12, 14, 0.92);
    backdrop-filter: blur(3px);
}

.pv-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
    pointer-events: none;
}

.pv-counter {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.pv-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: auto;
}

.pv-tool {
    min-width: 34px;
    height: 34px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    transition: all 0.14s ease;
}

.pv-tool:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
}

.pv-zoom-value {
    font-size: 12.5px;
    font-weight: 600;
    min-width: 58px;
    font-variant-numeric: tabular-nums;
}

.pv-close {
    font-size: 22px;
    margin-left: 4px;
}

/* --- сцена с картинкой --- */
.pv-stage {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 62px 64px 68px;
}

.pv-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    transition: transform 0.16s ease-out;
    user-select: none;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.pv-root.is-zoomed .pv-img {
    cursor: grab;
}

.pv-root.is-dragging .pv-img {
    cursor: grabbing;
    transition: none;
}

/* --- навигация по слайдам --- */
.pv-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 46px;
    height: 46px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.14s ease;
}

.pv-root.is-multi .pv-nav {
    display: flex;
}

.pv-nav:hover {
    background: rgba(255, 255, 255, 0.24);
}

.pv-prev { left: 14px; }
.pv-next { right: 14px; }

.pv-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    gap: 7px;
    padding: 7px 12px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 100px;
}

.pv-root:not(.is-multi) .pv-dots {
    display: none;
}

.pv-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.38);
    cursor: pointer;
    transition: all 0.14s ease;
}

.pv-dot:hover {
    background: rgba(255, 255, 255, 0.7);
}

.pv-dot.active {
    background: #fff;
    width: 20px;
    border-radius: 4px;
}

@media (max-width: 640px) {
    .pv-stage { padding: 58px 12px 62px; }
    .pv-nav { width: 38px; height: 38px; font-size: 21px; }
    .pv-prev { left: 6px; }
    .pv-next { right: 6px; }
}

/* =============================================================================
   ГАЛЕРЕЯ ФОТО (превью в карточке заказчика / в форме админки)
   ========================================================================== */

.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.photo-thumb {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border, #d2d2d7);
    background: var(--bg-elevated, #f5f5f7);
    cursor: pointer;
    padding: 0;
    transition: all 0.14s ease;
}

.photo-thumb:hover {
    border-color: var(--primary, #0071e3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Кнопка удаления в углу превью (только в админке) */
.photo-thumb-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(20, 20, 22, 0.72);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.14s ease, background 0.14s ease;
}

.photo-thumb:hover .photo-thumb-remove {
    opacity: 1;
}

.photo-thumb-remove:hover {
    background: #d70015;
}

