/* Основные стили */
* {
    box-sizing: border-box;
}

body {
    background-color: #1E1E1E;
    color: #FFFFFF;
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    font-size: 16px;
    line-height: 1.5;
}

.login-container {
    background-color: #2D2D2D;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    margin: 50px auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

h1, h2, h3 {
    color: #FFD700;
    margin-top: 0;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
}

.header-mobile {
    display: none;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.content {
    background-color: #2D2D2D;
    padding: 1.5rem;
    border-radius: 8px;
}

/* Формы и элементы ввода */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #CCCCCC;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #3D3D3D;
    color: #FFFFFF;
    font-size: 16px;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Кнопки */
.btn, .btn-login, .btn-save {
    padding: 0.75rem 1.5rem;
    background-color: #FF3B30;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    display: inline-block;
    text-decoration: none;
    font-size: 16px;
}

.btn-logout {
    background-color: transparent;
    color: #FF3B30;
    border: 1px solid #FF3B30;
    padding: 0.5rem 1rem;
}

.btn-icon {
    color: #FFD700;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.btn-icon:hover, .btn-icon.active {
    background-color: #3D3D3D;
}

.btn-add-user, .btn-add-character, .btn-add-event {
    display: inline-block;
    padding: 10px 15px;
    background-color: #FFD700;
    color: #1E1E1E;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 1rem;
}

/* Списки */
.user-list, .character-list, .event-list {
    margin-bottom: 20px;
    border: 1px solid #444;
    border-radius: 5px;
    overflow: hidden;
}

.user-list-header, .user-row,
.character-list-header, .character-row,
.event-list-header, .event-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 0.5fr 1fr;
    padding: 10px 15px;
    align-items: center;
}

.user-list-header, .character-list-header, .event-list-header {
    background-color: #3D3D3D;
    font-weight: bold;
}

.user-row:nth-child(even),
.character-row:nth-child(even),
.event-row:nth-child(even) {
    background-color: #2A2A2A;
}

.user-row:hover, .user-row.selected,
.character-row:hover, .character-row.selected,
.event-row:hover, .event-row.selected {
    background-color: #3D3D3D !important;
    cursor: pointer;
}

.user-row.selected, .
.selected, .event-row.selected {
    box-shadow: inset 3px 0 0 #FFD700;
}

/* Действия */
.user-actions, .character-actions, .event-actions {
    display: flex;
    gap: 10px;
    padding: 10px;
    background-color: #2A2A2A;
    border-top: 1px solid #444;
}

.btn-edit, .btn-delete {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-edit {
    background-color: #FFD700;
    color: #1E1E1E;
}

.btn-delete {
    background-color: #FF3B30;
    color: white;
}

/* Сообщения */
.error, .success {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease-out;
}

.error {
    background-color: #FF3B30;
    color: white;
}

.success {
    background-color: #4CAF50;
    color: white;
}

/* Формы */
.character-form, .event-form, .user-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn-cancel {
    display: inline-block;
    padding: 10px 15px;
    background-color: #444;
    color: white;
    border-radius: 4px;
    text-decoration: none;
}

/* Скиллы */
.skill-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.skill-row input[type="text"] {
    flex: 2;
}

.skill-row input[type="number"] {
    flex: 1;
}

.btn-add-skill {
    padding: 8px 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 5px;
}

.btn-remove-skill {
    padding: 8px 12px;
    background-color: #FF3B30;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
    }
    
    header {
        flex-direction: row;
        align-items: stretch;
    }
    
    .header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .header-controls {
        display: none;
        flex-direction: row;
        gap: 5px;
        margin-top: 10px;
        width: 100%;
    }
    
    .player-page .header-controls {
        display: none;
        flex-direction: row;
        gap: 5px;
        margin-top: 10px;
        width: 100%;
    }
    
    .header-controls.active,
    .player-page .header-controls.active {
        display: flex;
    }
    
    /* Оптимизированные стили для строк таблиц */
    .user-list-header, 
    .user-row,
    .character-list-header,
    .character-row,
    .event-list-header,
    .event-row {
        grid-template-columns: 1.5fr 1fr 0.5fr 1fr !important;
        font-size: 14px;
        min-width: auto;
        padding: 8px 10px;
    }
    
    .user-list, 
    .character-list, 
    .event-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .input-group input,
    .input-group select,
    .input-group textarea {
        padding: 12px;
        font-size: 16px;
    }
    
    .btn, .btn-login, .btn-save, .btn-cancel {
        padding: 12px;
        font-size: 16px;
        min-height: 50px;
    }
    
    .content {
        padding: 15px;
    }
    
    .character-form, .event-form, .user-form {
        width: 100%;
    }
    
    .user-actions, 
    .character-actions,
    .event-actions {
        flex-direction: row;
        gap: 8px;
    }
    
    .btn-edit, .btn-delete {
        width: 100%;
    }
    
    .skill-row {
        flex-direction: row;
        gap: 8px;
    }
    
    .skill-row input {
        width: 100% !important;
    }
	
	.character-actions {
        flex-direction: row; /* Оставляем горизонтально даже на мобильных */
        flex-wrap: wrap; /* Если кнопки не помещаются, переносим на новую строку */
    }
    
    .character-actions button {
        flex: 1; /* Равномерно распределяем пространство */
        min-width: 120px; /* Минимальная ширина кнопки */
    }
}



.btn-save-exit {
    padding: 0.75rem 1.5rem;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    font-size: 16px;
}

.btn-save-exit:hover {
    background-color: #3e8e41;
}

@media (max-width: 768px) {
    .form-actions {
        flex-direction: row;
    }
    
    .form-actions button, 
    .form-actions a {
        width: 100%;
        justify-content: center;
    }
}

/* Статусы игр */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
}

.status-closed {
    background-color: #FF3B30;
    color: white;
}

.status-open {
    background-color: #4CAF50;
    color: white;
}

.status-completed {
    background-color: #9E9E9E;
    color: white;
}

/* Подсветка названий игр */
.event-name.missing-characters {
    color: #FFD700;
    font-weight: bold;
}

.event-name.all-characters {
    color: #4CAF50;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .event-list-header, 
    .event-row {
        grid-template-columns: 1fr 2fr 1fr !important;
    }
    
    .status-badge {
        font-size: 0.7em;
        padding: 2px 6px;
    }
}

/* Добавляем в конец файла */
.btn-password {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background-color: #4CAF50;
    color: white;
}

@media (max-width: 768px) {
    .user-actions, 
    .character-actions,
    .event-actions {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* GM Page Styles matching Characters page */
.gm-page .content {
    padding: 20px;
}

.gm-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.gm-controls .btn {
    padding: 10px 20px;
    background-color: #FFD700;
    color: #1E1E1E;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
}

.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background-color: #2A2A2A;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-card h3 {
    color: #CCCCCC;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
}

.stat-card p {
    color: #FFD700;
    font-size: 1.5rem;
    margin: 0;
    font-weight: bold;
}

/* Games list matching characters list style */
.game-list-container {
    margin-bottom: 20px;
    border: 1px solid #444;
    border-radius: 5px;
    overflow: hidden;
}

.game-list-header, .game-group-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    padding: 10px 15px;
    background-color: #3D3D3D;
    font-weight: bold;
}

.game-group-header {
    background-color: #2A2A2A;
    color: #FFD700;
    border-top: 1px solid #444;
    border-bottom: 1px solid #444;
}

.game-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    padding: 10px 15px;
    align-items: center;
    text-decoration: none;
    color: #FFFFFF;
}

.game-row:nth-child(even) {
    background-color: #2A2A2A;
}

.game-row:hover, .game-row.selected {
    background-color: #3D3D3D !important;
    cursor: pointer;
}

.game-row.selected {
    box-shadow: inset 3px 0 0 #FFD700;
}

.game-status {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-open {
    background-color: #4CAF50;
}

.status-closed {
    background-color: #FF3B30;
}

.status-completed {
    background-color: #9E9E9E;
}

.game-players-count {
    color: #AAAAAA;
    font-size: 0.9em;
}

.btn-add-game {
    display: inline-block;
    padding: 10px 15px;
    background-color: #FFD700;
    color: #1E1E1E;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .game-list-header, 
    .game-group-header,
    .game-row {
        grid-template-columns: 1.5fr 1fr !important;
        min-width: auto;
    }
    
    .game-list-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Play Game Page Styles */
.playgame-page .game-title {
    color: #FFD700;
    font-size: 1.5rem;
    margin-bottom: 20px;
    text-align: center;
}

.dice-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.dice {
    width: 80px;
    height: 80px;
    background-color: #FFFFFF;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: #1E1E1E;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s;
    position: relative;
}

.dice:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
}

.dice-options {
    position: absolute;
    bottom: -40px;
    left: 0;
    background: #2D2D2D;
    border-radius: 5px;
    padding: 5px;
    display: none;
    z-index: 10;
}

.dice:hover .dice-options {
    display: flex;
    gap: 5px;
}

.dice-option {
    width: 30px;
    height: 30px;
    background: #444;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
}

.dice-option:hover {
    background: #FFD700;
    color: #1E1E1E;
}

.dice-result {
    margin-top: 10px;
    text-align: center;
    font-size: 1.2rem;
    color: #FFD700;
}

.dice-label {
    text-align: center;
    margin-bottom: 5px;
    color: #CCCCCC;
}

.character-actions {
    display: flex;
    gap: 10px;
    padding: 10px;
    background-color: #2A2A2A;
    border-top: 1px solid #444;
    /* Удаляем flex-direction: column */
    flex-direction: row; /* Добавляем горизонтальное направление */
}

.character-actions button {
    padding: 8px 15px;
    background-color: #FFD700;
    color: #1E1E1E;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.character-actions button:hover {
    background-color: #FFC000;
}

/* Player Header Styles */
.player-page .btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #3D3D3D;
    color: #FFD700;
    transition: all 0.3s;
}

.player-page .btn-icon:hover, 
.player-page .btn-icon.active {
    background-color: #FFD700;
    color: #1E1E1E;
    transform: scale(1.1);
}

.player-page .btn-logout {
    background-color: transparent;
    color: #FF3B30;
    border: 1px solid #FF3B30;
    padding: 8px 15px;
    border-radius: 4px;
    transition: all 0.3s;
}

.player-page .btn-logout:hover {
    background-color: #FF3B30;
    color: white;
}

.skills-header {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr 1fr;
    padding: 10px 0;
    font-weight: bold;
    color: #CCCCCC;
    margin-bottom: 5px;
}

.skill-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.hidden-checkbox {
    display: flex;
    justify-content: center;
}

.hidden-checkbox input {
    width: 20px;
    height: 20px;
}

.character-skills {
    padding: 10px;
    background-color: #2A2A2A;
    border-top: 1px solid #444;
}

.skill-item {
    display: flex;
    margin-bottom: 5px;
    padding: 5px;
    background-color: #3D3D3D;
    border-radius: 4px;
}

.skill-item.hidden {
    background-color: #1E1E1E;
    color: #888;
}

.skill-name {
    font-weight: bold;
    margin-right: 5px;
}

.toggle-hidden-skills {
    margin-top: 10px;
    padding: 5px 10px;
    background-color: #444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.toggle-hidden-skills:hover {
    background-color: #555;
}

/* Мобильное меню */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    position: absolute;
    right: 15px;
    top: 15px;
}

.mobile-sidebar {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100%;
    background-color: #2D2D2D;
    z-index: 1000;
    transition: right 0.3s ease;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);
}

.mobile-sidebar.open {
    right: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #444;
}

.sidebar-header h1 {
    margin: 0;
    font-size: 1.2rem;
    color: #FFD700;
}

.close-sidebar {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.sidebar-nav {
    padding: 10px 0;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    transition: background-color 0.2s;
}

.sidebar-item:hover {
    background-color: #3D3D3D;
}

.sidebar-item i {
    width: 24px;
    text-align: center;
    margin-right: 15px;
    color: #FFD700;
}

.sidebar-item.logout i {
    color: #FF3B30;
}

.sidebar-item span {
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .header-controls {
        display: none;
    }
}

.user-actions, .character-actions, .event-actions {
    display: flex;
    gap: 10px;
    padding: 10px;
    background-color: #2A2A2A;
    border-top: 1px solid #444;
}

.btn-edit, .btn-delete, .btn-password {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-edit {
    background-color: #FFD700;
    color: #1E1E1E;
}

.btn-delete {
    background-color: #FF3B30;
    color: white;
}

.btn-password {
    background-color: #4CAF50;
    color: white;
}

@media (max-width: 768px) {
    .user-actions, 
    .character-actions,
    .event-actions {
        flex-direction: row;
        gap: 8px;
    }
    
    .btn-edit, .btn-delete, .btn-password {
        width: 100%;
    }
}


@media (max-width: 480px) {
    /* Общие стили для всех списков */
    .user-list-header, 
    .user-row {
        grid-template-columns: 2fr 1fr !important;
        font-size: 13px;
        gap: 5px;
    }
    
    .character-list-header,
    .character-row {
        grid-template-columns: 2fr 1fr 0.5fr !important;
        font-size: 13px;
        gap: 5px;
    }
    
    .event-list-header,
    .event-row {
        grid-template-columns: 1fr 4fr 1fr !important; /* Увеличено с 3fr до 4fr */
        font-size: 13px;
        gap: 5px;
    }
    
    /* Стили для заголовков и строк событий */
    .event-list-header span:nth-child(2),
    .event-row span:nth-child(2) {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 60px; /* Уменьшено с 70px до 60px */
        text-align: right;
        padding-left: 10px;
    }
    
    /* Перенос текста для названий событий */
    .event-row span:first-child {
        white-space: normal;
        word-break: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-right: 5px;
        min-width: 0; /* Важно для правильного работы text-overflow */
    }
	
	.event-name {
		width: 200pt;
	}

	.event-status {
		width: 10pt;
	}
	
    
    /* Скрытие колонок */
    .character-list-header span:nth-child(3),
    .character-row span:nth-child(3),
    .character-list-header span:nth-child(4),
    .character-row span:nth-child(4),
    .event-list-header span:nth-child(3),
    .event-row span:nth-child(3),
    .user-list-header span:nth-child(3),
    .user-row span:nth-child(3) {
        display: none;
    }
    
    /* Остальные общие стили */
    .header-controls {
        flex-wrap: wrap;
    }
    
    .btn-icon {
        margin: 5px;
    }
    
    .login-container {
        margin: 20px auto;
        padding: 15px;
    }
    
    /* Замена заголовка "Дата начала" */
    .event-list-header span:nth-child(2)::after {
        content: "дата нач.";
        font-size: 12px;
    }
    
    .event-list-header span:nth-child(2) {
        font-size: 0; /* Скрываем оригинальный текст */
    }
}


.game-group-header {
    background-color: #2A2A2A;
    color: #FFFFFF;
    padding: 10px 15px;
    font-weight: bold;
    border-top: 1px solid #444;
    border-bottom: 1px solid #444;
}


/* Для страницы gm.php - адаптация таблицы игр */
@media (max-width: 480px) {
    .game-list-header,
    .game-group-header,
    .game-row {
        grid-template-columns: 2fr 1fr !important; /* Только название и дата начала */
    }
    
    /* Скрываем третью колонку (статус) */
    .game-list-header span:nth-child(3),
    .game-row span:nth-child(3) {
        display: none;
    }
    
    /* Форматирование даты для мобильных */
    .game-row span:nth-child(2) {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 100px;
        text-align: right;
    }
    
    /* Замена заголовка "Дата начала" на "дата" */
    .game-list-header span:nth-child(2)::after {
        content: "дата";
        font-size: 12px;
    }
    
    .game-list-header span:nth-child(2) {
        font-size: 0; /* Скрываем оригинальный текст */
    }
	.game-row span:first-child {
        white-space: normal;
        word-break: break-word;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-right: 5px;
        min-width: 0; /* Важно для правильного работы text-overflow */
    }
	
	.character-actions {
        flex-direction: row; /* Оставляем горизонтально даже на мобильных */
        flex-wrap: wrap; /* Если кнопки не помещаются, переносим на новую строку */
    }
    
    .character-actions button {
        flex: 1; /* Равномерно распределяем пространство */
        min-width: 120px; /* Минимальная ширина кнопки */
    }
}





/* Стили для меню с иконками */
.game-icons-menu {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #3D3D3D;
    border-radius: 50%;
    color: #CCCCCC;
    text-decoration: none;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background-color: #4D4D4D;
    color: white;
    transform: scale(1.1);
}

.icon-btn.active {
    background-color: #FFD700;
    color: #1E1E1E;
    transform: scale(1.1);
}

.icon-btn i {
    font-size: 1.2rem;
}

@media (max-width: 480px) {
    .game-icons-menu {
        gap: 10px;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
    }
    
    .icon-btn i {
        font-size: 1rem;
    }
}