/* client/css/main.css */

/* === СБРОС И БАЗОВЫЕ СТИЛИ === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Основные цвета */
    --color-bg: #1a1a2e;
    --color-bg-light: #16213e;
    --color-primary: #e94560;
    --color-secondary: #0f3460;
    --color-accent: #f5c518;
    --color-text: #eaeaea;
    --color-text-dim: #8a8a8a;
    --color-success: #4ade80;
    --color-warning: #fbbf24;
    --color-danger: #ef4444;

    /* UI цвета */
    --ui-bg: rgba(15, 15, 35, 0.9);
    --ui-border: rgba(100, 120, 180, 0.3);
    --ui-hover: rgba(100, 120, 180, 0.15);

    /* Статбары */
    --health-color: #ef4444;
    --energy-color: #3b82f6;
    --hunger-color: #f59e0b;
    --happiness-color: #a855f7;

    /* Шрифт */
    --font-pixel: 'Press Start 2P', cursive;
    --font-main: 'Segoe UI', system-ui, sans-serif;

    /* Размеры */
    --tile-size: 32px;
    --hud-height: 48px;
    --hotbar-slot-size: 48px;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--color-bg);
    font-family: var(--font-main);
    color: var(--color-text);
    cursor: default;
    user-select: none;
}

/* === ЭКРАН ЗАГРУЗКИ === */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.game-title {
    font-family: var(--font-pixel);
    font-size: 36px;
    color: var(--color-accent);
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(245, 197, 24, 0.5);
    animation: titlePulse 2s ease-in-out infinite;
}

.game-subtitle {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--color-text-dim);
    margin-bottom: 40px;
    letter-spacing: 4px;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.loading-bar {
    width: 300px;
    height: 12px;
    background: var(--color-bg-light);
    border-radius: 6px;
    overflow: hidden;
    margin: 0 auto 16px;
    border: 1px solid var(--ui-border);
}

.loading-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    border-radius: 6px;
    transition: width 0.3s ease;
}

.loading-text {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--color-text-dim);
}

/* === CANVAS === */
#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* === UI OVERLAY === */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* === HUD (верхняя панель) === */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--hud-height);
    background: var(--ui-bg);
    border-bottom: 1px solid var(--ui-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    backdrop-filter: blur(10px);
}

#hud-left, #hud-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hud-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid var(--ui-border);
}

.stat-icon {
    font-size: 14px;
}

.stat-value {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--color-text);
}

/* === СТАТБАРЫ ПЕРСОНАЖА === */
#player-stats {
    position: absolute;
    top: 60px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 180px;
}

.stat-bar-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.stat-bar-track {
    flex: 1;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--ui-border);
}

.stat-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease;
}

.health-fill {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.energy-fill {
    background: linear-gradient(90deg, #2563eb, #3b82f6);
}

.hunger-fill {
    background: linear-gradient(90deg, #d97706, #f59e0b);
}

.stat-bar-text {
    font-family: var(--font-pixel);
    font-size: 7px;
    width: 28px;
    text-align: right;
    color: var(--color-text-dim);
}

/* === ХОТБАР (нижняя панель) === */
#hotbar {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--ui-bg);
    border-radius: 12px;
    border: 1px solid var(--ui-border);
    backdrop-filter: blur(10px);
}

.hotbar-slot {
    width: var(--hotbar-slot-size);
    height: var(--hotbar-slot-size);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--ui-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hotbar-slot:hover {
    background: var(--ui-hover);
    border-color: rgba(100, 120, 180, 0.5);
}

.hotbar-slot.selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 10px rgba(245, 197, 24, 0.3);
    background: rgba(245, 197, 24, 0.1);
}

.hotbar-slot.drag-over {
    border-color: var(--color-accent);
    background: rgba(245, 197, 24, 0.15);
    transform: scale(1.05);
}

.hotbar-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-family: var(--font-pixel);
    font-size: 6px;
    color: var(--color-text-dim);
}

.hotbar-slot .item-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.hotbar-slot .item-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-family: var(--font-pixel);
    font-size: 7px;
    color: white;
    text-shadow: 1px 1px 0 black;
}

/* === КНОПКИ ДЕЙСТВИЙ === */
#action-buttons {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    width: 44px;
    height: 44px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.action-btn:hover {
    background: var(--ui-hover);
    border-color: var(--color-accent);
    transform: scale(1.1);
}

.action-btn:active {
    transform: scale(0.95);
}

/* === ЧАТ === */
#chat-box {
    position: absolute;
    bottom: 120px;
    left: 16px;
    width: 320px;
}

#chat-messages {
    max-height: 160px;
    overflow-y: auto;
    padding: 8px;
    margin-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--ui-border) transparent;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--ui-border);
    border-radius: 2px;
}

.chat-message {
    font-size: 12px;
    margin-bottom: 4px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    line-height: 1.4;
}

.chat-message .author {
    font-weight: bold;
    color: var(--color-accent);
}

.chat-message .system {
    color: var(--color-text-dim);
    font-style: italic;
}

#chat-input-wrapper {
    display: flex;
    gap: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

#chat-input-wrapper:focus-within {
    opacity: 1;
}

#chat-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 12px;
    font-family: var(--font-main);
    outline: none;
    backdrop-filter: blur(10px);
}

#chat-input:focus {
    border-color: var(--color-accent);
}

#chat-send {
    padding: 8px;
    background: var(--ui-bg);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

#chat-send:hover {
    background: var(--ui-hover);
}

/* === TOOLTIP === */
#tooltip {
    position: fixed;
    padding: 10px 14px;
    background: rgba(10, 10, 30, 0.95);
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    font-size: 12px;
    max-width: 250px;
    z-index: 1000;
    backdrop-filter: blur(10px);
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#tooltip .tooltip-title {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--color-accent);
    margin-bottom: 6px;
}

#tooltip .tooltip-desc {
    color: var(--color-text-dim);
    line-height: 1.4;
}

#tooltip .tooltip-stats {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--ui-border);
    font-size: 11px;
}

.hidden {
    display: none !important;
}

/* === Тултип предметов (инвентарь, хотбар) === */
.inv-tooltip {
    position: fixed;
    padding: 12px 16px;
    background: rgba(8, 8, 25, 0.97);
    border: 1px solid rgba(100, 120, 180, 0.4);
    border-radius: 10px;
    max-width: 280px;
    z-index: 10000;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    font-size: 11px;
}
.inv-tooltip .tt-name { font-family: var(--font-pixel); font-size: 9px; }
.inv-tooltip .tt-desc { color: #9a9a9a; line-height: 1.4; }

/* === ACTION PROMPT === */
#action-prompt {
    position: absolute;
    bottom: 170px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    background: var(--ui-bg);
    border: 1px solid var(--color-accent);
    border-radius: 20px;
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--color-accent);
    animation: promptBounce 1.5s ease-in-out infinite;
    backdrop-filter: blur(10px);
}

@keyframes promptBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

/* === МОДАЛЬНЫЕ ОКНА === */
#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    pointer-events: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    animation: fadeIn 0.2s ease;
}

.modal-window {
    background: var(--color-bg-light);
    border: 1px solid var(--ui-border);
    border-radius: 16px;
    padding: 24px;
    min-width: 400px;
    max-width: 80vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ui-border);
}

.modal-title {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--color-accent);
}

.modal-close {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ui-border);
    border-radius: 50%;
    color: var(--color-text-dim);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* === ПОЛОСА ПРОКРУТКИ === */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--ui-border);
    border-radius: 3px;
}
