/* ============================================
   S.T.A.L.K.E.R. КПК (ПДА) — Основные стили
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

:root {
    --bg-primary: #0d0d1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --text-primary: #c8d6c8;
    --text-secondary: #7a8a7a;
    --accent-orange: #c4883c;
    --accent-green: #4a7c4a;
    --accent-red: #8b3a3a;
    --border-color: #2a3a2a;
    --screen-glow: rgba(100, 200, 100, 0.06);
    --pda-body: #3a3e32;
    --pda-body-dark: #2a2e22;
    --pda-rubber: #1a1c18;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: #111;
    font-family: 'Share Tech Mono', monospace;
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* ============================================
   Обёртка КПК — десктоп
   ============================================ */
.pda-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(ellipse at center, #1a1a1a 0%, #0a0a0a 100%);
    position: relative;
    overflow: hidden;
}

/* Замыленный фон пейзажа Зоны */
.pda-wrapper::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background-image: url('../images/zone-bg.jpg');
    background-size: cover;
    background-position: center;
    filter: blur(8px) brightness(0.4) saturate(0.7);
    z-index: 0;
}

/* Тёмный оверлей + виньетка поверх фона */
.pda-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, rgba(10, 10, 10, 0.3) 0%, rgba(5, 5, 5, 0.7) 100%);
    z-index: 0;
}

.pda-device {
    position: relative;
    z-index: 1;
    width: 90vw;
    max-width: 1800px;
    aspect-ratio: 16 / 9;
    max-height: 90vh;
    background: linear-gradient(145deg, var(--pda-body) 0%, var(--pda-body-dark) 100%);
    border-radius: 18px;
    box-shadow:
        0 0 0 2px #222,
        0 0 0 4px #444,
        0 8px 32px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    overflow: hidden;
}

/* Текстура корпуса */
.pda-device::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        );
    border-radius: 18px;
    pointer-events: none;
    z-index: 1;
}

/* Верхняя резиновая накладка */
.pda-top-strip {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: var(--pda-rubber);
    border-radius: 18px 18px 0 0;
    z-index: 2;
}

/* Винты */
.pda-screw {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #666 0%, #333 50%, #555 100%);
    border-radius: 50%;
    border: 1px solid #222;
    z-index: 3;
}
.pda-screw::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 20%;
    right: 20%;
    height: 1px;
    background: #222;
    transform: rotate(45deg);
}
.pda-screw.top-left { top: 18px; left: 12px; }
.pda-screw.top-right { top: 18px; right: 12px; }
.pda-screw.bottom-left { bottom: 12px; left: 12px; }
.pda-screw.bottom-right { bottom: 12px; right: 12px; }

/* Область экрана */
.pda-screen-area {
    flex: 1;
    margin: 20px 12px 20px 16px;
    position: relative;
    z-index: 2;
}

.pda-screen {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 2px solid #111;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    /* contain: paint removed — lightbox uses JS positioning instead */
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.6),
        0 0 12px rgba(100, 200, 100, 0.08);
}

/* Эффект свечения экрана */
.pda-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, var(--screen-glow), transparent 70%);
    pointer-events: none;
    z-index: 100;
}

/* Scanlines */
.pda-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(0, 0, 0, 0.08) 1px,
        rgba(0, 0, 0, 0.08) 2px
    );
    pointer-events: none;
    z-index: 101;
}

/* Виньетирование */
.pda-vignette {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    z-index: 102;
}

/* Правая панель с кнопками */
.pda-side-panel {
    width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px 8px;
    z-index: 2;
}

.pda-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #555, #2a2a2a);
    border: 2px solid #222;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    cursor: default;
    transition: transform 0.1s;
}

.pda-btn:active {
    transform: scale(0.95);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.pda-btn.accent {
    background: radial-gradient(circle at 35% 35%, #c4883c, #7a5020);
    border-color: #5a3818;
}

/* ============================================
   Контент экрана
   ============================================ */
.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.screen-header .logo {
    font-size: 13px;
    color: var(--accent-orange);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.screen-header .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.screen-header .user-info .callsign {
    color: var(--text-primary);
}

.screen-header .user-info .avatar-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    object-fit: cover;
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    position: relative;
    z-index: 1;
}

/* Кастомный скроллбар */
.screen-content::-webkit-scrollbar {
    width: 6px;
}
.screen-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
.screen-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
.screen-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-green);
}

/* Нижняя навигация (вкладки) */
.screen-nav {
    display: flex;
    align-items: stretch;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    overflow-x: auto;
}

.screen-nav::-webkit-scrollbar {
    height: 0;
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 10px;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    border-top: 2px solid transparent;
    min-width: 70px;
    position: relative;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.nav-tab.active {
    color: var(--accent-orange);
    border-top-color: var(--accent-orange);
    background: rgba(196, 136, 60, 0.05);
}

.nav-tab svg {
    width: 18px;
    height: 18px;
    margin-bottom: 3px;
    fill: currentColor;
}

.nav-tab .badge {
    position: absolute;
    top: 4px;
    right: 12px;
    width: 16px;
    height: 16px;
    background: var(--accent-red);
    border-radius: 50%;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* Статусная строка (дата/время) внизу корпуса */
.pda-status-bar {
    position: absolute;
    bottom: 4px;
    left: 16px;
    right: 72px;
    text-align: center;
    font-size: 10px;
    color: #555;
    letter-spacing: 1px;
    z-index: 2;
}

/* ============================================
   Компоненты UI
   ============================================ */

/* Карточка */
.stalker-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 14px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.stalker-card:hover {
    border-color: rgba(196, 136, 60, 0.3);
}

/* Кнопка */
.stalker-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    letter-spacing: 0.5px;
}

.stalker-btn:hover {
    background: rgba(196, 136, 60, 0.15);
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.stalker-btn.primary {
    background: rgba(196, 136, 60, 0.2);
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.stalker-btn.primary:hover {
    background: rgba(196, 136, 60, 0.3);
}

.stalker-btn.danger {
    border-color: var(--accent-red);
    color: #c06060;
}

.stalker-btn.danger:hover {
    background: rgba(139, 58, 58, 0.2);
}

/* Поля ввода */
.stalker-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.stalker-input:focus {
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 1px rgba(196, 136, 60, 0.2);
}

.stalker-input::placeholder {
    color: var(--text-secondary);
}

textarea.stalker-input {
    resize: vertical;
    min-height: 80px;
}

select.stalker-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a8a7a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* Label */
.stalker-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Бейдж группировки */
.faction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    letter-spacing: 0.5px;
    border: 1px solid;
}

/* Пагинация */
.stalker-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.stalker-pagination a,
.stalker-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 12px;
    text-decoration: none;
    transition: all 0.2s;
}

.stalker-pagination a:hover {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

.stalker-pagination .active span {
    background: rgba(196, 136, 60, 0.2);
    border-color: var(--accent-orange);
    color: var(--accent-orange);
}

/* Ошибки */
.alert-error {
    background: rgba(139, 58, 58, 0.15);
    border: 1px solid var(--accent-red);
    color: #d08080;
    padding: 10px 14px;
    border-radius: 3px;
    margin-bottom: 12px;
    font-size: 12px;
}

.alert-success {
    background: rgba(74, 124, 74, 0.15);
    border: 1px solid var(--accent-green);
    color: #80c080;
    padding: 10px 14px;
    border-radius: 3px;
    margin-bottom: 12px;
    font-size: 12px;
}

/* Таблица */
.stalker-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.stalker-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 10px;
    border-bottom: 1px solid var(--border-color);
}

.stalker-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(42, 58, 42, 0.5);
}

.stalker-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Разделитель */
.stalker-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

/* Заголовок секции */
.section-title {
    font-size: 14px;
    color: var(--accent-orange);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* ============================================
   Анимация включения экрана
   ============================================ */
@keyframes screenOn {
    0% {
        opacity: 0;
        filter: brightness(3) contrast(0);
    }
    30% {
        opacity: 1;
        filter: brightness(1.5) contrast(0.5);
    }
    100% {
        opacity: 1;
        filter: brightness(1) contrast(1);
    }
}

.pda-screen.boot {
    animation: screenOn 0.6s ease-out forwards;
}

/* ============================================
   Мобильная адаптивность
   ============================================ */
@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    .pda-wrapper {
        padding: 0;
        min-height: 100vh;
        align-items: stretch;
    }

    .pda-wrapper::before,
    .pda-wrapper::after {
        display: none;
    }

    .pda-device {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        background: var(--bg-primary);
    }

    .pda-device::before,
    .pda-top-strip,
    .pda-screw,
    .pda-side-panel,
    .pda-status-bar {
        display: none;
    }

    .pda-screen-area {
        margin: 0;
        flex: 1;
    }

    .pda-screen {
        border: none;
        border-radius: 0;
    }

    .screen-content {
        padding: 12px;
    }

    .nav-tab {
        min-width: 56px;
        padding: 10px 4px 8px;
        font-size: 9px;
    }

    .nav-tab svg {
        width: 20px;
        height: 20px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .nav-tab span {
        display: none;
    }

    .nav-tab {
        padding: 12px 4px 10px;
    }

    .nav-tab svg {
        width: 22px;
        height: 22px;
        margin-bottom: 0;
    }
}

/* ============================================
   Форматированный текст (Discord-like)
   ============================================ */

/* Спойлер */
.spoiler {
    background: #333;
    color: transparent;
    border-radius: 3px;
    padding: 0 4px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.spoiler.revealed {
    background: rgba(74, 124, 74, 0.15);
    color: var(--text-primary);
    user-select: auto;
}

/* Инлайн-код */
.formatted-text code {
    background: rgba(42, 58, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9em;
    color: var(--accent-orange);
}

/* Блок кода */
.formatted-text pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.formatted-text pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.85em;
    color: var(--text-primary);
}

/* Цитата */
.formatted-text blockquote {
    border-left: 3px solid var(--accent-orange);
    margin: 8px 0;
    padding: 4px 12px;
    background: rgba(196, 136, 60, 0.06);
    color: var(--text-secondary);
}

/* Зачёркнутый */
.formatted-text del {
    color: var(--text-secondary);
    text-decoration: line-through;
}

/* Подчёркнутый */
.formatted-text u {
    text-decoration-color: var(--accent-green);
}

/* Упоминание @callsign */
.mention {
    color: var(--accent-orange);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s;
}

.mention:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Общие стили форматированного текста */
.formatted-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.6;
}

.formatted-text p {
    margin: 0 0 0.5em;
}

.formatted-text p:last-child {
    margin-bottom: 0;
}
