/* ═══════════════════════════════════════════════════════════════════════════
   Поиск по ИНН — стили виджета и страницы приложения
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: #f6fafb;
    font-size: 13px;
    line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ТЁМНАЯ ТЕМА (по умолчанию)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Корневой контейнер ───────────────────────────────────────────────────── */
.is-widget {
    padding: 8px 0;
    font-family: var(--font-sans, system-ui, sans-serif);
    background: transparent;
}

/* ── Карточка-обёртка ─────────────────────────────────────────────────────── */
.is-card {
    background: #171a4a;
    border: 0.5px solid rgba(120, 110, 255, 0.25);
    border-radius: 12px;
    overflow: hidden;
}

/* ── Шапка карточки ───────────────────────────────────────────────────────── */
.is-card-header {
    background: #0f1035;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 0.5px solid rgba(120, 110, 255, 0.25);
}

.is-card-header svg { flex-shrink: 0; }

.is-card-title {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ── Тело карточки ────────────────────────────────────────────────────────── */
.is-card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Строка поиска ────────────────────────────────────────────────────────── */
.is-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.is-input {
    flex: 1;
    background: #0f1035;
    border: 0.5px solid rgba(120, 110, 255, 0.35);
    border-radius: 8px;
    padding: 8px 11px;
    font-size: 13px;
    color: #fff;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.is-input::placeholder { color: rgba(255, 255, 255, 0.25); }
.is-input:focus         { border-color: rgba(124, 106, 247, 0.7); }

.is-btn {
    background: #5046e5;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.is-btn:hover    { background: #4038c7; }
.is-btn:active   { background: #352fa8; }
.is-btn:disabled { background: rgba(80, 70, 229, 0.4); cursor: not-allowed; }
.is-btn:disabled .is-btn-icon { display: none; }

/* ── Список результатов ───────────────────────────────────────────────────── */
.is-results {
    display: flex;
    flex-direction: column;
    border: 0.5px solid rgba(120, 110, 255, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.is-result-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: #0f1035;
    border-bottom: 0.5px solid rgba(120, 110, 255, 0.13);
    transition: background 0.15s;
    min-width: 0;
}

.is-result-row:last-child { border-bottom: none; }
.is-result-row:hover      { background: #141842; }

/* Бейдж КОМ / КОН */
.is-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    text-transform: uppercase;
    margin-top: 1px;
}

.is-badge--kom {
    background: rgba(80, 70, 229, 0.22);
    color: #9b88ff;
    border: 0.5px solid rgba(120, 110, 255, 0.3);
}

.is-badge--kon {
    background: rgba(29, 158, 117, 0.2);
    color: #4ee6b0;
    border: 0.5px solid rgba(29, 158, 117, 0.3);
}

/* Контейнер правой части (имя + дата + ответственный) */
.is-result-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Верхняя строка: название + дата */
.is-result-top {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

/* Кликабельное название — переносится, не обрезается */
.is-result-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: #7c6af7;
    text-decoration: none;
    line-height: 1.35;
    word-break: break-word;
    min-width: 0;
    cursor: pointer;
    transition: color 0.15s;
}

.is-result-name:hover { color: #a898ff; text-decoration: underline; }

/* Дата создания */
.is-result-date {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.28);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Ответственный — вторая строка, полное имя */
.is-result-resp {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.38);
    line-height: 1.3;
}

/* Счётчик результатов */
.is-count {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.28);
    text-align: right;
    padding: 0 2px;
}

/* ── Состояние: загрузка ──────────────────────────────────────────────────── */
.is-loading {
    padding: 11px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    background: #0f1035;
    border: 0.5px solid rgba(120, 110, 255, 0.2);
    border-radius: 8px;
}

.is-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(124, 106, 247, 0.2);
    border-top-color: #7c6af7;
    border-radius: 50%;
    animation: is-spin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes is-spin { to { transform: rotate(360deg); } }

/* ── Состояние: не найдено ────────────────────────────────────────────────── */
.is-empty {
    padding: 13px 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    background: #0f1035;
    border: 0.5px solid rgba(120, 110, 255, 0.2);
    border-radius: 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* ── Состояние: ошибка ────────────────────────────────────────────────────── */
.is-error {
    padding: 10px 12px;
    font-size: 12px;
    color: #f87777;
    background: rgba(226, 75, 74, 0.08);
    border: 0.5px solid rgba(226, 75, 74, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Ошибка валидации (под полем) ─────────────────────────────────────────── */
.is-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    padding: 0 2px;
}

.is-hint--err { color: #f87777; }


/* ═══════════════════════════════════════════════════════════════════════════
   СТРАНИЦА ПРИЛОЖЕНИЯ (index.php) — тёмная тема
   ═══════════════════════════════════════════════════════════════════════════ */

.app-wrap {
    width: 100%;
    max-width: 480px;
    background: #171a4a;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

/* Шапка приложения */
.app-header {
    background: #0f1035;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 0.5px solid rgba(120, 110, 255, 0.25);
    flex-shrink: 0;
}

.app-logo {
    width: 30px;
    height: 30px;
    background: #5046e5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.2px;
}

.app-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 1px;
}

/* Статус */
.app-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
}

.app-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ee6b0;
    flex-shrink: 0;
}

/* Вкладки — сегментированные кнопки */
.app-tabs {
    background: #0f1035;
    display: flex;
    border-bottom: 0.5px solid rgba(120, 110, 255, 0.25);
    padding: 8px 14px;
    gap: 4px;
    flex-shrink: 0;
}

.app-tab {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    padding: 6px 14px;
    cursor: pointer;
    /* сброс дефолтных стилей <button> */
    -webkit-appearance: none;
    appearance: none;
    border: none;
    outline: none;
    box-shadow: none;
    border-radius: 6px;
    background: transparent;
    transition: color 0.18s, background 0.18s;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1;
}

.app-tab:focus        { outline: none; box-shadow: none; }
.app-tab:focus-visible { outline: 2px solid rgba(124,106,247,0.5); outline-offset: 2px; }
.app-tab:hover { color: rgba(255, 255, 255, 0.75); background: rgba(120, 110, 255, 0.1); }

.app-tab.is-active {
    color: #fff !important;
    background: #5046e5 !important;
}

/* Контент вкладки */
.app-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.app-content[hidden] { display: none; }

.app-section-head {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

/* Строка поиска на странице индекс */
.app-search-row {
    display: flex;
    gap: 8px;
}

.app-input {
    flex: 1;
    background: #0f1035;
    border: 0.5px solid rgba(120, 110, 255, 0.35);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 13px;
    color: #fff;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}

.app-input::placeholder { color: rgba(255, 255, 255, 0.22); }
.app-input:focus         { border-color: rgba(124, 106, 247, 0.7); }

.app-btn {
    background: #5046e5;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.app-btn:hover    { background: #4038c7; }
.app-btn:active   { background: #352fa8; }
.app-btn:disabled { background: rgba(80, 70, 229, 0.4); cursor: not-allowed; }

/* Результаты поиска на странице index (переиспользуем is-* стили) */
.app-result-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: #0f1035;
    border-bottom: 0.5px solid rgba(120,110,255,0.13);
    transition: background 0.15s;
    min-width: 0;
}
.app-result-row:last-child { border-bottom: none; }
.app-result-row:hover { background: #141842; }

/* Настройки */
.settings-group {
    background: #0f1035;
    border: 0.5px solid rgba(120, 110, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
}

.settings-group-title {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 10px 14px 8px;
    border-bottom: 0.5px solid rgba(120, 110, 255, 0.15);
}

/* Карточки выбора темы */
.theme-cards {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
}

.theme-card {
    flex: none;
    width: 120px;
    border-radius: 9px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.15s;
    position: relative;
}

.theme-card:hover            { transform: translateY(-1px); }
.theme-card.is-selected      { border-color: #7c6af7; }

.theme-card-preview {
    height: 58px;
    position: relative;
    overflow: hidden;
}

.theme-card-preview--dark  { background: #171a4a; }
.theme-card-preview--light { background: #f9fafb; }

/* Мини-превью внутри карточки темы */
.tcp-bar  { height: 10px; border-radius: 3px; margin: 8px 8px 4px; }
.tcp-line { height: 7px;  border-radius: 3px; margin: 0 8px 4px; width: 65%; }
.tcp-btn  { height: 9px;  border-radius: 3px; margin: 0 8px; width: 38%; }

.tcp-bar--dark  { background: rgba(124,106,247,0.35); }
.tcp-line--dark { background: rgba(124,106,247,0.15); }
.tcp-btn--dark  { background: rgba(80,70,229,0.55); }

.tcp-bar--light  { background: #e5e7eb; }
.tcp-line--light { background: #f3f4f6; }
.tcp-btn--light  { background: rgba(99,102,241,0.5); }

.theme-card-label {
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

.theme-card--dark .theme-card-label {
    background: #0f1035;
    color: rgba(255,255,255,0.55);
}

.theme-card--light .theme-card-label {
    background: #fff;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
}

.theme-card.is-selected .theme-card-label  { color: #a898ff; }

/* Галочка на выбранной карточке */
.theme-check {
    position: absolute;
    top: 5px; right: 5px;
    width: 16px; height: 16px;
    background: #7c6af7;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
}

.theme-card.is-selected .theme-check { display: flex; }

.theme-check::after {
    content: '';
    width: 8px; height: 5px;
    border-left: 1.5px solid #fff;
    border-bottom: 1.5px solid #fff;
    transform: rotate(-45deg) translateY(-1px);
}

/* Кнопка сохранить в настройках */
.settings-save-row { padding: 4px 14px 12px; }

.settings-save-btn {
    width: 100%;
    background: #5046e5;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.settings-save-btn:hover { background: #4038c7; }

.settings-save-btn.is-saved {
    background: #059669;
    cursor: default;
}

/* Футер приложения */
.app-footer {
    padding: 10px 16px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.18);
    text-align: center;
    border-top: 0.5px solid rgba(120, 110, 255, 0.12);
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   СВЕТЛАЯ ТЕМА — класс .is-light на .is-widget / .app-wrap
   Приближена к нативному стилю Bitrix24
   ═══════════════════════════════════════════════════════════════════════════ */

/* Виджет светлая */
.is-light .is-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.is-light .is-card-header {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.is-light .is-card-title { color: #6b7280; }

.is-light .is-input {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #1f2937;
}
.is-light .is-input::placeholder { color: #9ca3af; }
.is-light .is-input:focus         { border-color: #6366f1; }

.is-light .is-btn  { background: #6366f1; }
.is-light .is-btn:hover { background: #4f46e5; }

.is-light .is-results {
    border: 1px solid #e5e7eb;
}

.is-light .is-result-row {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
}
.is-light .is-result-row:last-child { border-bottom: none; }
.is-light .is-result-row:hover      { background: #f9fafb; }

.is-light .is-badge--kom {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #dbeafe;
}
.is-light .is-badge--kon {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #d1fae5;
}

.is-light .is-result-name { color: #4f46e5; }
.is-light .is-result-name:hover { color: #312e81; }
.is-light .is-result-date { color: #9ca3af; }
.is-light .is-result-resp { color: #9ca3af; }
.is-light .is-count       { color: #9ca3af; }

.is-light .is-loading {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    color: #6b7280;
}
.is-light .is-spinner {
    border-color: #e5e7eb;
    border-top-color: #6366f1;
}
.is-light .is-empty {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    color: #9ca3af;
}
.is-light .is-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}
.is-light .is-hint     { color: #9ca3af; }
.is-light .is-hint--err { color: #dc2626; }

/* Страница приложения светлая */
.is-light.app-wrap { background: #fff; }

.is-light .app-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}
.is-light .app-name { color: #1f2937; }
.is-light .app-sub  { color: #9ca3af; }
.is-light .app-status { color: #9ca3af; }

.is-light .app-tabs {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}
.is-light .app-tab         { color: #9ca3af; }
.is-light .app-tab:hover   { color: #6b7280; background: #f3f4f6; }
.is-light .app-tab.is-active {
    color: #fff !important;
    background: #6366f1 !important;
}

.is-light .app-section-head { color: #9ca3af; }

.is-light .app-input {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #1f2937;
}
.is-light .app-input::placeholder { color: #9ca3af; }
.is-light .app-input:focus         { border-color: #6366f1; }

.is-light .app-btn       { background: #6366f1; }
.is-light .app-btn:hover { background: #4f46e5; }

.is-light .app-result-row {
    background: #fff;
    border-bottom: 1px solid #f3f4f6;
}
.is-light .app-result-row:last-child { border-bottom: none; }
.is-light .app-result-row:hover      { background: #f9fafb; }

.is-light .settings-group {
    background: #fff;
    border: 1px solid #e5e7eb;
}
.is-light .settings-group-title {
    color: #9ca3af;
    border-bottom-color: #f3f4f6;
}

.is-light .theme-card--dark .theme-card-label { background: #0f1035; color: rgba(255,255,255,0.5); }
.is-light .theme-card.is-selected              { border-color: #6366f1; }
.is-light .theme-check                         { background: #6366f1; }
.is-light .theme-card.is-selected .theme-card-label { color: #4f46e5; }

.is-light .settings-save-btn { background: #6366f1; }
.is-light .settings-save-btn:hover { background: #4f46e5; }
.is-light .settings-save-btn.is-saved { background: #059669; }
