/* Define theme variables */
:root[data-theme="dark"] {
    --background: #1b1b1b;
    --text: #e4e4e4;
    --text-secondary: #aaaaaa;
    --text-tertiary: #4abdac;
    --accent: #4abdac;
    --accent-hover: #4abdac;
    --border: #444444;
    --scrollbar: #555;
    --hover-bg: #444444;
    --modal-close-bg: #4abdac;
}

:root[data-theme="light"] {
    --background: rgb(213,213,213);
    --text: #333333;
    --text-secondary: #666666;
    --text-tertiary: #dc4a77;
    --accent: #dc4a77;
    --accent-hover: #dc4a77;
    --border: #cccccc;
    --scrollbar: #888888;
    --hover-bg: #f0f0f0;
    --modal-close-bg: #dc4a77;
}

body {
    background: var(--background);
    color: var(--text);
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal overflow at the body level */
}

.container-fluid {
    width: 100%;
    overflow-x: hidden; /* Ensure container doesn’t allow horizontal scroll */
}

.heading {
    background: var(--background);
    border-bottom: 1px solid var(--accent);
    padding: 10px 10px 0;
    position: sticky;
    top: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 15px;
}

#searchContainer {
    width: 250px;
    position: relative;
    background: var(--background);
}

.logo-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 20px;
}

#gameSearch {
    font-size: 0.9rem;
    background: var(--background);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
}

#gameSearch:focus {
    background: var(--background);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 5px var(--accent-hover);
}

#gameSearch::placeholder {
    color: var(--text);
    opacity: 0.7;
}

#searchResults {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1200;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    background: var(--background);
    border: 1px solid var(--accent);
    box-shadow: 0 2px 5px var(--accent-hover);
    display: none;
}

#searchResults.active {
    display: block;
}

.list-group-item {
    cursor: pointer;
    font-size: 0.85rem;
    padding: 8px;
    background: var(--background);
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1300;
}

.list-group-item:hover {
    background-color: var(--hover-bg);
    color: var(--text);
}

.search-result-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    background: var(--background);
}

.calendar-day {
    border: 1px solid var(--text);
    border-radius: 3%;
    padding: 3px;
    height: 150px;
    position: relative;
    overflow: hidden;
    background: var(--background);
}

.calendar-day.empty {
    background: var(--background);
    border: none;
}

.day-number {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--background);
    z-index: 1;
    padding: 4px;
    font-weight: bold;
    font-size: 12px;
    color: var(--text);
}

.day-name {
    display: none; /* Hidden by default */
}

.game-list {
    max-height: 110px;
    overflow-y: auto;
    margin-top: 20px;
    padding-right: 5px;
    font-weight: 500;
}

.game-list::-webkit-scrollbar {
    width: 8px;
}

.game-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar);
    border-radius: 4px;
}

.game-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar);
}

.game-title {
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    font-size: 0.85em;
    line-height: 1.2;
    padding: 2px 5px;
    word-wrap: break-word;
    color: var(--text);
}

.game-title:hover {
    color: var(--accent);
}

.selected-game {
    color: var(--accent);
    font-weight: bold;
}

.platform-btn {
    padding: 5px !important;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border-color: var(--border);
}

.platform-btn img {
    display: block;
    height: auto;
}

.platform-btn.btn-secondary img {
    filter: brightness(0) invert(1);
}

.platform-btn:hover img {
    opacity: 0.8;
}

.platform-btn.square-logo img {
    width: 25px !important;
    height: 25px !important;
    object-fit: contain;
}

.platform-btn.btn-secondary {
    background: var(--background);
    border-color: var(--background);
}

.card {
    height: 100%;
    background: var(--background);
    color: var(--text);
    padding: 5px;
    margin-top: 0px;
    border: 1px solid var(--text);
}

.card-body {
    background: var(--background);
    color: var(--text);
}

.card-title {
    font-weight: bold;
}

.month-navigation {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.month-toggles {
    display: flex;
    gap: 5px;
}

.month-toggles button {
    font-size: 1.5rem;
    padding: 4px 4px;
    line-height: 0.85;
    border: none;
    outline: none;
    color: var(--accent);
    font-weight: 1000;
    background-color: transparent;
    transition: background-color 0.3s;
    padding-bottom: 10px;
}

.month-toggles button:hover {
    background-color: var(--hover-bg);
    color: var(--accent);
}

.month-toggles .btn-outline-primary {
    border: none !important;
    outline: none !important;
    background-color: transparent !important;
}

.month-toggles .btn-outline-primary:hover {
    background-color: var(--hover-bg) !important;
}

#monthYear {
    margin: 0;
    color: var(--text);
}

.screenshots-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    margin-top: 10px;
    width: 100%;
}

.screenshot-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 4px;
}

.modal-img {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text);
    background: var(--modal-close-bg);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1060;
}

.modal-close-btn:hover {
    background: var(--background);
}

#imageModal .modal-dialog {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    max-width: 66.67%;
    margin: 0;
    width: auto;
}

#imageModal {
    pointer-events: none;
}

#imageModal .modal-dialog {
    pointer-events: auto;
}

.screenshot-img:hover {
    border: 2px solid var(--accent);
}

.filter-row {
    margin-bottom: 0.5rem;
    position: sticky;
    top: 40px;
    z-index: 1000;
    background: var(--background);
    padding: 0 10px 10px;
}

.details-pane p {
    margin-bottom: 4px;
}

/* Ribbon Dropdown Styles */
.ribbon-container {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1500;
}

.ribbon-trigger {
    background: var(--accent);
    color: var(--text);
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 20px 100%);
    transition: background-color 0.3s;
}

.ribbon-trigger:hover {
    background: var(--accent-hover);
}

.ribbon-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--background);
    border: 1px solid var(--accent);
    box-shadow: 0 2px 5px var(--accent-hover);
    min-width: 200px;
    padding: 10px;
    z-index: 1500;
}

.ribbon-dropdown.active {
    display: block;
}

.ribbon-content {
    color: var(--text);
    font-size: 0.9rem;
}

.ribbon-content p {
    margin: 0 0 10px 0;
}

.qr-code-img {
    width: 100px;
    height: 100px;
    display: block;
    margin: 0 auto;
}

.game-container {
    margin-bottom: 4px;
}

.platform-logos {
    display: flex;
    gap: 4px;
    margin-top: 2px;
    margin-left: 5px;
}

.platform-logo {
    object-fit: contain;
}

.details-toggle {
    display: none;
    background: var(--background);
    color: var(--text);
    border: 2px solid var(--accent);
}

/* Theme Toggle Button */
.theme-toggle {
    margin-left: 0px;
    margin-bottom: 5px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-icon {
    stroke: var(--text);
}

/* Portrait adjustments */
@media (max-width: 1024px) and (orientation: portrait) {
    .heading {
        flex-direction: column !important;
        align-items: center !important;
        padding: 0.1875rem 0.625rem 0.125rem;
        position: fixed !important;
        width: 100%;
        z-index: 1100;
        margin-top: 0;
        margin-bottom: 0;
    }
    .logo-container {
        position: static;
        transform: none;
        margin-bottom: 0;
    }
    .logo-container img {
        max-width: 100%;
        height: auto;
        margin-bottom: 0px !important;
    }
    #searchContainer {
        width: clamp(80%, 90%, 100%);
        margin-top: 0.3125rem;
        margin-bottom: 0;
    }
    #gameSearch {
        margin-top: 0.3125rem !important;
        margin-bottom: 0.3125rem !important;
    }
    .filter-row {
        position: fixed !important;
        top: clamp(5.65rem, 20vw, 7.5rem) !important;
        width: 100%;
        z-index: 1050;
        margin-bottom: 0 !important;
        padding: 0.1875rem 0.625rem 0.125rem;
        margin-top: 0.3125rem;
    }
    .container-fluid.mt-4 {
        margin-top: clamp(12.5rem, 32vw, 14.375rem) !important;
    }
    .filter-row .row {
        flex-direction: column;
        align-items: center;
        gap: 0.0625rem;
    }
    .month-navigation, #platformFilters {
        justify-content: center;
    }
    .calendar-grid {
        grid-template-columns: 1fr;
        padding: 0 0.625rem;
    }
    .calendar-day-header {
        display: none;
    }
    .calendar-day {
        max-height: 7rem;
        min-height: 6.25rem;
        margin-bottom: 0.625rem;
    }
    .day-number {
        position: absolute;
        top: 0.3125rem;
        left: 0.3125rem;
        font-size: 1rem;
    }
    .day-name {
        display: block;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        position: absolute;
        left: 0.3125rem;
        top: 50%;
        transform: translateY(-50%) rotate(180deg);
        font-size: 0.8rem;
        color: var(--text-secondary);
    }
    .game-list {
        margin-left: 1.875rem;
        margin-top: 2px !important;
    }
    .details-pane {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 80vh;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 1100;
        background: var(--background);
    }
    .details-pane.active {
        transform: translateY(0) !important;
    }
    .details-toggle {
        display: block;
        position: absolute;
        top: 0.625rem;
        right: 0.625rem;
        z-index: 1200;
        background: var(--background);
        color: var(--text);
        padding: 0.3125rem 1.25rem;
        border-radius: 5px;
        border: 2px solid var(--accent);
        height: 2.1875rem;
        width: auto;
    }
    .details-pane.active .details-toggle {
        position: absolute;
        top: 0.625rem;
        right: 0.625rem;
        transform: none;
    }
    #desktopDetailsPane {
        display: none;
    }
    .col-md-8 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    .col-md-4 {
        display: none !important;
    }
    .screenshot-img {
        pointer-events: none;
    }
    .screenshot-img:hover {
        border: none;
    }
    #imageModal {
        display: none !important;
    }
    .ribbon-container {
        top: 0;
        right: 0;
        max-width: 50px;
        max-height: 25px !important;
    }
    .ribbon-trigger {
        font-size: 0.55rem;
        padding: 0px 4px 0px 20px;
        max-height: 25px !important;
    }
    .ribbon-dropdown {
        min-width: 150px;
    }
    .qr-code-img {
        width: 80px;
        height: 80px;
    }
    .theme-toggle {
        margin-top: 2px;
    }
}

/* Landscape adjustments */
@media (max-width: 1024px) and (orientation: landscape) {
    .heading {
        flex-direction: row !important;
        justify-content: flex-start !important;
        align-items: center;
        padding: 0 0.625rem 0;
        flex-wrap: nowrap;
        position: fixed !important;
        width: 100%;
        z-index: 1100;
        margin-top: -0.225rem;
        margin-bottom: 0;
    }
    .logo-container {
        position: static;
        transform: none;
        margin-bottom: 0 !important;
        margin-left: clamp(5rem, 20vw, 6.25rem);
    }
    .logo-container img {
        max-width: clamp(25rem, 50vw, 31.25rem);
        height: auto;
        margin-bottom: 0 !important;
    }
    #searchContainer {
        width: clamp(10rem, 30vw, 12.5rem);
        order: -1;
        margin-top: 0.625rem !important;
        margin-bottom: 0 !important;
        margin-left: 0.625rem;
        margin-right: 0.625rem;
    }
    #gameSearch {
        margin-bottom: 0.3125rem !important;
    }
    .filter-row {
        position: fixed !important;
        top: clamp(2rem, 8vw, 2.75rem) !important;
        width: 100%;
        z-index: 1050;
        margin-bottom: 0 !important;
        padding: 0.1875rem 0.625rem 0.125rem;
    }
    .container-fluid.mt-4 {
       margin-top: clamp(4.375rem, 12vw, 6rem) !important;
    }
    .calendar-grid {
        grid-template-columns: repeat(7, 1fr);
        width: 100%;
        padding: 0 0.625rem;
    }
    .calendar-day-header {
        display: block;
        top: 0 !important;
        padding: 0.1875rem;
    }
    .calendar-day {
        height: 9.375rem;
        min-height: 9.375rem;
    }
    .day-number {
        font-size: 0.625rem;
        font-weight: bold;
    }
    .day-name {
        display: none;
    }
    .game-list {
        margin-left: 0;
        margin-top: 1rem;
        max-height: 7.5rem;
    }
    .details-pane {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 95vh;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 1600;
        background: var(--background);
    }
    .details-pane.active {
        transform: translateY(0) !important;
    }
    .details-toggle {
        position: absolute;
        top: 0.625rem;
        right: 0.625rem;
        z-index: 1600;
        background: var(--background);
        color: var(--text);
        padding: 0.3125rem 0.625rem;
        border: 1px solid var(--accent);
        border-radius: 5px;
        cursor: pointer;
        display: block;
    }
    .details-pane.active .details-toggle {
        display: block;
    }
    .col-md-8 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    .col-md-4 {
        display: none !important;
    }
    .screenshot-img {
        pointer-events: none;
    }
    .screenshot-img:hover {
        border: none;
    }
    #imageModal {
        display: none !important;
    }
    .ribbon-container {
        top: 0;
        right: 0;
    }
    .ribbon-trigger {
        padding: 4px 8px 4px 20px;
    }
    .ribbon-dropdown {
        min-width: 150px;
    }
    .qr-code-img {
        width: 80px;
        height: 80px;
    }
    .theme-toggle {
        margin-left: 0px;
    }
    .calendar-grid {
        padding-top: 3px;
    }
}

/* Desktop adjustments */
@media (min-width: 1025px) {
    #gameDetails {
        display: none !important;
    }
    .details-pane {
        position: static;
        transform: none;
        max-height: none;
        overflow-y: visible;
    }
    #desktopDetailsPane {
        display: block;
    }
    .details-toggle {
        display: none;
    }
    #desktopDetailsPane .card-title {
        text-align: center;
        font-weight: bold;
    }
    .filter-row {
        margin-bottom: 0;
        position: sticky;
        top: 40px;
        z-index: 1000;
        background: var(--background);
        padding: 0 10px 0px;
    }
}

/* Desktop and Landscape Adjustments */
@media (min-width: 1025px), (max-width: 1024px) and (orientation: landscape) {
    .calendar-day:nth-child(-n+7) .day-name {
        display: inline-block;
        position: absolute;
        top: 2px; /* Align vertically with day number */
        left: 50%;
        transform: translateX(-50%);
        font-weight: bold;
        padding: 2px;
        font-size: 12px;
        color: var(--text-tertiary);
    }
    .calendar-day:nth-child(-n+7) .day-number {
        position: absolute;
        top: 0;
        left: 0;
    }
    .calendar-day:nth-child(-n+7) .game-list {
        margin-top: 20px; /* Ensure content starts below both elements */
    }
}
