/* CSS Document */

:root {
  --filter-highlight-color: #fff3cd;
  --filter-match-color: #28a745;
  --filter-none-color: #dc3545;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}
body {
	font-family: Arial, sans-serif;
	line-height: 1.6;
	color: #333;
	background: #f4f4f4;
}
.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 20px;
}
.header {
	background: #2c3e50;
	color: white;
	padding: 1rem 0;
	/* margin-bottom: 2rem; */
}
.header h1 {
	text-align: center;
}
.nav {
	text-align: center;
	/* margin-top: 1rem; */
}
.nav a {
	color: white;
	text-decoration: none;
	margin: 5px;
	padding: 5px 10px;
	border-radius: 3px;
}
.nav a:hover {
	background: rgba(255, 255, 255, 0.2);
}
.card {
	background: white;
	padding: 20px;
	margin: 20px 0;
	border-radius: 5px;
	box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.card-body {
	padding: 1.25rem 0.25rem;
}
.form-group {
	margin-bottom: 15px;
}
.form-group label {
	display: block;
	margin-bottom: 5px;
	font-weight: bold;
}
.form-group input, .form-group select, .form-group textarea {
	width: 100%;
	padding: 8px;
	border: 1px solid #ddd;
	border-radius: 3px;
}
.alert {
	padding: 10px;
	margin: 10px 0;
	border-radius: 3px;
}
.alert-error {
	background: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
}
.alert-warning {
	background: #fff3cd;
	color: #856404;
	border: 1px solid #ffeaa7;
}
.alert-success {
	background: #d4edda;
	color: #155724;
	border: 1px solid #c3e6cb;
}
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 20px;
}
.table-container {
    position: relative;
    overflow: auto;
    border: 1px solid #ddd;
    max-width: 100%;
	max-height: 40vh;
}
.table-container thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-container tfoot th {
	position: sticky;
	bottom: 0;
}

table {
	width: 100%;
	border-collapse: collapse;
}
table th, table td {
	/* padding: 10px 0px 10px 10px; */
	padding: 10px;
	text-align: left;
	border-bottom: 1px solid #ddd;
}
table th {
	background: WhiteSmoke;
}
table tr:not(.editing) {
	background: white;
}
col[actions] {
	min-width: 110px;
}

#select-all-platforms-header {
	min-width: 135px;
}
#select-all-platforms {
	text-align: right;
}
#select-all-platforms-label {
	font-style: italic;
	margin-right: 10px;
}
#select-all-platforms-checkbox {
	margin-right: 15px;
}

.games-table-container {
	min-height: 150vh;
}
.game-table {
}

.collection-btns {
	margin-bottom: 10px;
}

.row-links-table-container {
	width: 100%;
	overflow-x: auto;
}

.row-links-table-container table {
	width: 100%;
	min-width: 420px;
	table-layout: fixed;
}

.row-links-table-container th,
.row-links-table-container td {
	white-space: nowrap;
}
.row-target td,
.row-target th {
	font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", "monospace";
	font-size: 1rem;
	font-weight: bold;
	/* text-decoration: underline overline; */
	border-bottom: none;
    background-color: Gainsboro;
	width: 24px;
}
.row-target-label {
	padding: 0 10px !important;
    width: 90px !important;
	text-align: left;
    font-style: italic !important;
    font-weight: normal !important;
}
.row-target-cell {
	padding: 10px 4px;
	width: 24px !important;
}
.row-target-btn {
	padding: 0 4px;
	font-weight: bold;
}

/* Sticky columns - Edit and Game */
.sticky-col-1 {
    position: sticky;
    left: 0;
    z-index: 12;
}
.sticky-col-2 {
    position: sticky;
    left: 110px;
    z-index: 11;
}
/* Header sticky positioning */
th.sticky-row {
	position: sticky;
	top: 0;
	z-index: 20;
}
th.sticky-row-top {
	z-index: 30;
}
thead th.sticky-col-1,
thead th.sticky-col-2 {
    z-index: 13;
}
.game-name {
	font-weight: bold;
	background-color: inherit;
}
.game-platform {
	text-align: center;
	width: 1% !important;
	white-space: nowrap !important;
}
.game-date,
.game-notes {
	white-space: nowrap;
}

th.game-date,
td.game-date {
	min-width: 180px !important;
}
th.game-notes,
td.game-notes {
	padding-right: 10px;
	min-width: 250px !important;
}
/* Platform columns */
td:has(input[type="checkbox"]) {
    text-align: center;
    width: 80px;
}
input[type="checkbox"] {
	width: auto;
    transform: scale(2);
}

.platform-checkbox {
	width: 1% !important;
	white-space: nowrap !important;
}

.platform-checkbox input[type="checkbox"]:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}
.platform-checkbox input[type="checkbox"]:not(:disabled) {
    cursor: pointer;
    opacity: 1;
}

.platform-checkbox input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.9;
}
.game-name input,
.game-notes input {
	color: inherit;
	background: transparent;
	border: none;
	/* padding: 4px; */
}
.game-name input,
.game-name span {
	width: 280px;
	display: block;
}
.game-notes input {
	width: 200px;
	text-overflow: ellipsis;
}

.games-split-table-container input:disabled {
	font-family: inherit;
	background: transparent;
	color: black;
	opacity: 1;
	/* WebKit-specific properties to override iOS defaults */
	-webkit-text-fill-color: currentColor; /* Forces WebKit to use the 'color' property value */
	-webkit-opacity: 1; /* Ensures full opacity for the WebKit render layer */
}
.game-name input:disabled {
	font-size: 1em;
	font-weight: bold;
}
.game-name input:enabled,
.game-notes input:enabled {
	border: 1px solid #007bff;
    background: WhiteSmoke;
	background-color: white;
}
#total-games {
	font-weight: bold;
}
.card > *.btn {
	margin: 5px 10px;
}
.csv-btns {
	text-align: center;
}
.btn-csv {
	
}
.btn-save {
    background: #28a745;
    color: white;
}
.btn-save:hover {
    background: #1e7e34;
}

.editing {
    background-color: WhiteSmoke !important;
}
.saving {
    opacity: 0.6;
}

.toast-message {
	position: fixed;
	top: 20px;
	right: 20px;
	padding: 12px 20px;
	border-radius: 4px;
	color: white;
	font-weight: bold;
	z-index: 9999;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
	animation: slideInRight 0.3s ease-out;
}
.toast-message-success {
	background: #28a745;
}
.toast-message-error {
	background: red;
}
@keyframes slideInRight {
	from {
		transform: translateX(100%);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes slideOutRight {
	from {
		transform: translateX(0);
		opacity: 1;
	}
	to {
		transform: translateX(100%);
		opacity: 0;
	}
}

/* Mobile-responsive enhancements for the interactive table */

@media (max-width: 768px) {
    
	.table-container {
        border: none;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Toast messages on mobile */
    .toast-message {
        right: 10px !important;
        top: 10px !important;
        padding: 8px 12px !important;
        font-size: 12px !important;
        max-width: calc(100vw - 20px);
        word-wrap: break-word;
    }
}

@media (max-width: 480px) {
	.games-split-table-container .btn {
		display: block;
		/* margin-bottom: 8px; */
		text-align: center;
		width: 36px !important;
		padding: 4px !important;
	}
	table th.actions,
	table td.actions {
		width: 60px !important;
		text-align: center;
	}
	table th.game-name,
	table td.game-name {
		width: 150px !important;
		text-align: left;
	}
	.game-name input,
	.game-name span {
		width: 130px !important;
	}
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
	/* iOS recommended touch target */
	/*
	.btn {
        min-height: 44px;
        padding: 8px 12px;
    }
    */
    .platform-checkbox input[type="checkbox"] {
        min-width: 44px;
        min-height: 44px;
        transform: none;
    }
    
    .game-name input:enabled,
    .game-notes input:enabled {
        padding: 8px;
        border-radius: 4px;
    }
}

/* Improved focus states for accessibility */
.game-name input:focus,
.game-notes input:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Loading spinner for save states */
.saving::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Virtualized Split Table Styles */
.games-split-table-container {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto 1fr;
    gap: 0;
    max-height: 80vh;
    background: white;
    border: 2px solid #ddd;
    position: relative;
}

.games-split-table-container .btn {
	display: block;
	/* margin-bottom: 8px; */
	text-align: center;
	width: 48px;
}
/*
tr.editing td .btn {
	margin-bottom: 8px;
}
*/

table th.actions,
table td.actions {
    width: 70px;
    text-align: center;
}
table th.game-name,
table td.game-name {
    width: 300px;
    text-align: left;
}

/* Top-left corner (Actions + Game header) */
.games-corner {
    grid-row: 1;
    /* grid-column: 1 / 3; */
    overflow: hidden;
    border-right: 2px solid #ddd;
    border-bottom: 2px solid #ddd;
    background: WhiteSmoke;
    z-index: 13;
}

/* Top header row (Platform columns) */
.games-header-row {
    grid-row: 1;
    grid-column: 3;
    overflow: hidden;
    border-bottom: 2px solid #ddd;
    background: WhiteSmoke;
    z-index: 2;
}

.games-header-row-scroll {
    overflow-x: scroll;
    overflow-y: hidden;
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    box-sizing: border-box;
}

.games-header-row-scroll::-webkit-scrollbar {
    display: none;
}

/* Left header columns (Actions + Game name) */
.games-header-cols {
    grid-row: 2;
    grid-column: 1 / 3;
    overflow: hidden;
    border-right: 2px solid #ddd;
    background: white;
    z-index: 12;
    display: grid;
    grid-template-columns: auto auto;
}

.games-header-col-actions,
.games-header-col-name {
    overflow: hidden;
}

.games-header-col-scroll-actions,
.games-header-col-scroll-name {
    overflow-y: scroll;
    overflow-x: hidden;
    height: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
    box-sizing: border-box;
}

.games-header-col-scroll-actions::-webkit-scrollbar,
.games-header-col-scroll-name::-webkit-scrollbar {
    display: none;
}

tr.loading-msg td,
td.noGames {
	border: none !important;
	font-weight: bold;
}

/* Main data area */
.games-data-area {
    grid-row: 2;
    grid-column: 3;
    overflow: auto;
    position: relative;
}

.games-virtual-container {
    position: relative;
	min-height: 160px;
}

/* Table styles for split tables */
.games-split-table-container table {
    border-collapse: collapse;
    width: 100%;
}

.games-split-table-container tr {
	height: 80px;
}
.games-split-table-container tr.editing {
	height: 160px;
}

.games-split-table-container th,
.games-split-table-container td {
    padding: 10px;
    text-align: left;
    border: 1px solid #e0e0e0;
    white-space: nowrap;
	/* line-height: 60px; */
}

.games-split-table-container th {
    background: WhiteSmoke;
    /* font-weight: 600; */
	min-width: 56px;
	text-decoration: underline;
}

.games-corner table th {
    background: WhiteSmoke;
}

/* Platform columns - fixed width */
.games-data-area th {
    min-width: 120px;
    max-width: 120px;
    width: 120px;
    text-align: center;
    padding: 10px 5px;
}

.games-data-area td {
    min-width: 120px;
    max-width: 120px;
    width: 120px;
    text-align: center;
    padding: 10px 5px;
}

.games-data-area td input[type="checkbox"] {
    /* transform: scale(1.5); */
    cursor: pointer;
}

/* Stats display */
.virtualization-stats {
    /* position: absolute;
    top: -100px;
    right: 10px;
	*/
	display: none;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 100;
    pointer-events: none;
}

/* Search controls */
.games-search-controls {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
	flex-wrap: wrap;
}

.games-search-controls input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.games-search-controls input[type="text"]:focus {
    outline: 2px solid #007bff;
    border-color: #007bff;
}

.games-search-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 200px;
    cursor: pointer;
}

.games-search-controls select:focus {
    outline: 2px solid #007bff;
    border-color: #007bff;
}

.games-search-controls .btn-clear-filters {
    padding: 6px 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.games-search-controls .btn-clear-filters:hover {
    background: #5a6268;
}

#searchResults {
    font-size: 14px;
    margin-bottom: 10px;
    padding: 4px;
	background-color: var(--filter-highlight-color);
}

#searchResults.hidden {
    display: none;
}

#searchResults.visible {
    display: block;
}

#searchResults.match {
    color: var(--filter-match-color);
}

#searchResults.none {
    color: var(--filter-none-color);
}

/* Highlight matching games */
.game-match-highlight {
    background-color: var(--filter-highlight-color) !important;
}

.game-match-highlight input {
    background-color: var(--filter-highlight-color) !important;
}

mark {
    background-color: lightgreen!important;
    color: black !important;
    font-weight: bold;
}
