/* =========================================================================
   PUBLIC STYLING SYSTEM - lastnewgames.com
   ========================================================================= */

/* Base Layout & Typography */
body {
    background-color: #f5f5f7;
    color: #1d1d1f;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    padding: 0;
    margin: 0;
    font-size: 14px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.dev-search-link, .genre-filter-link {
    color: #0071e3;
    text-decoration: underline;
    font-weight: 500;
}

.app-store-container {
    max-width: 1060px;
    margin: 0 auto;
    padding: 40px 20px 80px 20px;
}

/* Apple Navigation Header */
.app-header {
    margin-bottom: 30px;
}

.header-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 25px;
    border-bottom: 1px solid #d2d2d7;
    padding-bottom: 15px;
}

.header-title-row h1 {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
    color: #1d1d1f;
}

/* Sub Navigation Menu */
.app-nav {
    display: flex;
    gap: 20px;
}

.app-nav-link {
    font-size: 15px;
    font-weight: 600;
    color: #86868b;
    text-decoration: none;
    transition: color 0.2s;
    padding-bottom: 4px;
}

.app-nav-link:hover, .app-nav-link.active {
    color: #0071e3;
}

/* Year Sub-navigation Menu (Reports) */
.year-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.year-link {
    padding: 8px 16px;
    border-radius: 20px;
    background: #ffffff;
    color: #48484a;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #d2d2d7;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.year-link:hover, .year-link.active {
    background: #0071e3;
    color: #ffffff;
    border-color: #0071e3;
}

/* Search & Filter Component */
.filter-section {
    background: #ffffff;
    border-radius: 22px;
    padding: 24px;
    margin-bottom: 35px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.02);
    border: 1px solid #f2f2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.search-pill-wrapper {
    display: flex;
    align-items: center;
    background-color: #f5f5f7;
    border-radius: 16px;
    padding: 8px 16px;
    border: 1px solid #e5e5ea;
    width: 100%;
    box-sizing: border-box;
}

.search-pill-wrapper .search-icon {
    margin-right: 10px;
    font-size: 16px;
    color: #86868b;
}

.search-pill-wrapper input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1f;
    width: 100%;
}

.search-pill-wrapper select {
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    font-weight: 600;
    color: #0071e3;
    margin-left: 10px;
    cursor: pointer;
    padding-right: 10px;
    -webkit-appearance: none;
}

.filter-toggles {
    display: flex;
    gap: 24px;
    align-items: center;
}

/* Apple Switch Styling */
.apple-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13.5px;
    user-select: none;
}

.apple-switch input {
    display: none;
}

.switch-visual {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background-color: #e5e5ea;
    position: relative;
    transition: background-color 0.2s;
}

.switch-visual::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #ffffff;
    top: 2px;
    left: 2px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}

.apple-switch input:checked + .switch-visual {
    background-color: currentColor;
}

.apple-switch input:checked + .switch-visual::after {
    transform: translateX(20px);
}

/* Sections & Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0;
    color: #1d1d1f;
}

.section-subtitle {
    font-size: 13px;
    color: #86868b;
    margin-top: 4px;
    font-weight: 500;
}

/* Results Grid & Cards */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 22px;
    margin-bottom: 40px;
}

.result-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 16px;
    display: flex;
    align-items: stretch;
    gap: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
    border: 1px solid #f2f2f7;
    transition: transform 0.2s, box-shadow 0.2s;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
}

.app-icon-squircle {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.05);
}

.app-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
    min-width: 0;
}

.app-title-name {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: #1d1d1f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-subtitle-desc {
    font-size: 12.5px;
    color: #86868b;
    margin-bottom: 5px;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.app-rating-row {
    font-size: 12px;
    font-weight: 600;
    color: #f39c12;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}

.app-rating-row span {
    color: #86868b;
    font-weight: 500;
}

/* Buttons */
.btn-apple-get {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f7;
    color: #0071e3;
    font-size: 13.5px;
    font-weight: 700;
    padding: 5px 22px;
    border-radius: 15px;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    height: 28px;
    box-sizing: border-box;
}

.btn-apple-get:hover {
    background-color: #0071e3;
    color: #ffffff;
}

/* KPI Grid & Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    border: 1px solid #f2f2f7;
    transition: transform 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
}

.kpi-title {
    font-size: 11px;
    font-weight: 700;
    color: #86868b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: #1abc9c;
    margin-bottom: 8px;
}

.kpi-footer {
    font-size: 11px;
    color: #86868b;
}

/* Charts Grid */
.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    border: 1px solid #f2f2f7;
}

.chart-title {
    font-size: 13px;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.chart-wrapper {
    position: relative;
    height: 250px;
}

/* Data Tables */
.data-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    margin-bottom: 50px;
}

.data-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    border: 1px solid #f2f2f7;
    overflow-x: auto;
}

.data-card table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.data-card th, .data-card td {
    border: none;
    border-bottom: 1px solid #f2f2f7;
    padding: 12px 16px;
    text-align: left;
    vertical-align: middle;
    font-size: 13.5px;
}

.data-card th {
    background-color: #f5f5f7;
    font-weight: 600;
    color: #86868b;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.data-card tr:last-child td {
    border-bottom: none;
}

.data-card td strong {
    color: #1d1d1f;
}

.badge {
    display: inline-block;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-fav {
    background-color: #9b59b6;
    color: #ffffff;
}

.badge-pub {
    background-color: #1abc9c;
    color: #ffffff;
}

.star-rating {
    font-weight: 700;
    color: #f39c12;
}

.all-link {
    color: #0071e3;
    text-decoration: none;
    font-weight: 600;
}

.all-link:hover {
    text-decoration: underline;
}

.app-icon {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    object-fit: cover;
    border: 1px solid rgba(0,0,0,0.06);
    display: block;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 40px 0;
}

.apple-btn-page {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #d2d2d7;
    background: #ffffff;
    color: #0071e3;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.apple-btn-page:hover:not(.disabled) {
    background: #0071e3;
    color: #ffffff;
    border-color: #0071e3;
}

.apple-btn-page.disabled {
    color: #d2d2d7;
    border-color: #e5e5ea;
    cursor: not-allowed;
    pointer-events: none;
}

.page-indicator-text {
    font-size: 13px;
    color: #86868b;
    font-weight: 500;
}

/* Dark Mode overrides */
html.dark-mode body {
    background-color: #000000 !important;
    color: #f5f5f7 !important;
}
html.dark-mode .app-store-container {
    background-color: transparent !important;
}
html.dark-mode .result-card,
html.dark-mode .kpi-card,
html.dark-mode .chart-card,
html.dark-mode .data-card,
html.dark-mode .filter-section {
    background-color: #1c1c1e !important;
    border-color: #2c2c2e !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
}
html.dark-mode h1,
html.dark-mode h2,
html.dark-mode h3,
html.dark-mode .app-title-name,
html.dark-mode .kpi-value,
html.dark-mode .chart-title,
html.dark-mode .data-card td strong,
html.dark-mode td strong {
    color: #ffffff !important;
}
html.dark-mode .section-subtitle,
html.dark-mode .app-subtitle-desc,
html.dark-mode .kpi-footer,
html.dark-mode .app-date-row,
html.dark-mode .catalog-size-label,
html.dark-mode .page-indicator-text {
    color: #86868b !important;
}
html.dark-mode .app-nav-link {
    color: #86868b !important;
}
html.dark-mode .app-nav-link:hover,
html.dark-mode .app-nav-link.active {
    color: #2997ff !important;
}
html.dark-mode .year-link,
html.dark-mode .genre-select,
html.dark-mode select,
html.dark-mode .search-pill-wrapper,
html.dark-mode .apple-btn-page {
    background-color: #2c2c2e !important;
    border-color: #3a3a3c !important;
    color: #ffffff !important;
}
html.dark-mode .year-link.active,
html.dark-mode .year-link:hover {
    background-color: #0071e3 !important;
    color: #ffffff !important;
    border-color: #0071e3 !important;
}
html.dark-mode .search-pill-wrapper input {
    background: transparent !important;
    color: #ffffff !important;
}
html.dark-mode .result-card[style*="background-color: #fffdec"] {
    background-color: #2d2605 !important;
    border-color: #4d3d0b !important;
}
html.dark-mode .result-card[style*="background-color: #f3fdf8"] {
    background-color: #042f1a !important;
    border-color: #0f4d2f !important;
}
html.dark-mode table th {
    background-color: #2c2c2e !important;
    color: #86868b !important;
}
html.dark-mode table td {
    border-bottom: 1px solid #2c2c2e !important;
    color: #e2e8f0 !important;
}
html.dark-mode .header-title-row {
    border-bottom-color: #2c2c2e !important;
}

.search-pill-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-grow: 1;
    max-width: 580px;
    flex-wrap: nowrap;
}

.catalog-size-label {
    font-size: 11px;
    color: #86868b;
    font-weight: 600;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Responsive & Mobile Optimizations */
@media (max-width: 768px) {
    .header-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .header-title-row h1 {
        font-size: 28px;
    }
    .filter-section {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
    .filter-toggles {
        justify-content: flex-start;
        gap: 15px;
        flex-wrap: wrap;
        width: 100%;
        margin-top: 0px;
    }
    .search-pill-group {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .catalog-size-label {
        text-align: left;
        margin-top: 2px;
    }
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    .section-controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    .chart-row {
        grid-template-columns: 1fr;
    }
    .year-nav {
        gap: 8px;
    }
    .year-link {
        padding: 6px 12px;
        font-size: 12px;
    }
}
