/* APK Manager Styles - PlayStore Style */
:root {
    --apk-primary: #4285f4;
    --apk-secondary: #34a853;
    --apk-accent: #ea4335;
    --apk-warning: #ff9800;
    --apk-dark: #202124;
    --apk-light: #f8f9fa;
    --apk-border: #e0e0e0;
    --apk-radius: 8px;
    --apk-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --apk-shadow-hover: 0 2px 5px rgba(0,0,0,0.15);
    --apk-transition: all 0.2s ease;
}

/* Reset and Base */
.apk-manager-container * {
    box-sizing: border-box;
}

/* Grid Container - Mobile First */
.premium-apk-grid-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 8px;
    width: 100%;
    margin: 0 auto;
}

/* APK Card - PlayStore Style */
.premium-apk-card {
    background: white;
    border-radius: var(--apk-radius);
    overflow: hidden;
    box-shadow: var(--apk-shadow);
    transition: var(--apk-transition);
    border: 1px solid var(--apk-border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.premium-apk-card:hover {
    box-shadow: var(--apk-shadow-hover);
    transform: translateY(-2px);
}

.premium-apk-card.has-mod {
    border-top: 2px solid var(--apk-warning);
}

.apk-card-inner {
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Badges - Top Right */
.apk-card-badges {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.apk-badge {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1;
    margin-bottom: 3px;
}

.apk-badge.mod {
    background: var(--apk-warning);
    color: white;
}

/* App Icon - Left Side */
.apk-card-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 8px auto;
}

.apk-card-link {
    display: block;
}

.apk-icon-img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--apk-border);
    display: block;
    margin: 0 auto;
}

.apk-icon-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.apk-icon-text {
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Card Content - Compact */
.apk-card-content {
    flex: 1;
    text-align: center;
}

.apk-card-title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    height: 34px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.apk-card-title a {
    color: var(--apk-dark);
    text-decoration: none;
}

.apk-card-title a:hover {
    color: var(--apk-primary);
}

.apk-card-developer {
    font-size: 11px;
    color: #5f6368;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Rating Only - No Size/Downloads */
.apk-card-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
}

.apk-stars {
    color: var(--apk-warning);
    font-size: 11px;
    line-height: 1;
}

.apk-rating-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--apk-dark);
    line-height: 1;
}

/* MOD Preview - Compact */
.apk-mod-preview {
    background: rgba(255, 152, 0, 0.1);
    border-radius: 4px;
    padding: 4px 6px;
    margin-bottom: 8px;
}

.apk-mod-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--apk-warning);
    text-transform: uppercase;
}

.apk-mod-text {
    font-size: 10px;
    color: #5f6368;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Actions - Only Download Button */
.apk-card-actions {
    display: flex;
    gap: 6px;
}

.apk-download-button {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--apk-transition);
    background: linear-gradient(135deg, var(--apk-primary), var(--apk-secondary));
    color: white;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
}

.apk-download-button:hover {
    background: linear-gradient(135deg, var(--apk-secondary), var(--apk-primary));
    color: white;
    transform: translateY(-1px);
}

.download-icon {
    font-size: 12px;
}

/* Responsive Grid - Mobile Optimized */
@media (max-width: 359px) {
    .premium-apk-grid-container {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 6px;
    }
}

@media (min-width: 360px) and (max-width: 767px) {
    .premium-apk-grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 8px;
    }
    
    .apk-card-icon {
        width: 65px;
        height: 65px;
    }
    
    .apk-icon-img,
    .apk-icon-placeholder {
        width: 65px;
        height: 65px;
    }
    
    .apk-card-title {
        font-size: 14px;
    }
}

/* Tablet */
@media (min-width: 768px) {
    .premium-apk-grid-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        padding: 12px;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .apk-card-inner {
        padding: 14px;
    }
    
    .apk-card-icon {
        width: 70px;
        height: 70px;
        margin-bottom: 10px;
    }
    
    .apk-icon-img,
    .apk-icon-placeholder {
        width: 70px;
        height: 70px;
    }
    
    .apk-card-title {
        font-size: 14px;
        height: 38px;
    }
    
    .apk-card-developer {
        font-size: 12px;
    }
    
    .apk-download-button {
        font-size: 12px;
        padding: 9px 12px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .premium-apk-grid-container[data-desktop-columns="4"] {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        padding: 15px;
    }
    
    .premium-apk-grid-container[data-desktop-columns="5"] {
        grid-template-columns: repeat(5, 1fr);
        gap: 15px;
    }
    
    .premium-apk-grid-container[data-desktop-columns="6"] {
        grid-template-columns: repeat(6, 1fr);
        gap: 14px;
    }
    
    .apk-card-icon {
        width: 75px;
        height: 75px;
    }
    
    .apk-icon-img,
    .apk-icon-placeholder {
        width: 75px;
        height: 75px;
    }
    
    .apk-card-title {
        font-size: 15px;
        height: 40px;
    }
}
@media (min-width: 1200px) {
    .apk-screenshots-section {
        max-width: 1200px;
        padding: 0;
    }
    
    .screenshots-scroll-container {
        max-width: 1200px;
    }
}

@media (min-width: 1400px) {
    .apk-screenshots-section {
        max-width: 1300px;
    }
    
    .screenshots-scroll-container {
        max-width: 1300px;
    }
}

/* Large Desktop */
@media (min-width: 1200px) {
    .premium-apk-grid-container {
        gap: 18px;
        padding: 20px;
    }
}

/* No Results */
.apk-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
}

.apk-empty-state {
    max-width: 300px;
    margin: 0 auto;
}

.apk-empty-icon {
    font-size: 40px;
    margin-bottom: 15px;
    display: block;
    color: #dadce0;
}

.apk-no-results h3 {
    font-size: 18px;
    color: var(--apk-dark);
    margin: 0 0 10px 0;
}

.apk-no-results p {
    color: #5f6368;
    font-size: 14px;
}

/* Remove unwanted elements */
.apk-card-stats,
.apk-card-description,
.apk-view-button,
.apk-stat,
.apk-stat-icon,
.apk-stat-text {
    display: none !important;
}

/* Single APK Page Fix */
.apk-single-header {
    background: linear-gradient(135deg, var(--apk-primary) 0%, var(--apk-secondary) 100%);
    padding: 20px;
    border-radius: 12px;
    color: white;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .apk-single-header {
        display: flex;
        align-items: center;
        gap: 25px;
        padding: 25px;
    }
}

.apk-single-icon {
    flex: 0 0 100px;
}

.apk-icon-image {
    width: 100px;
    height: 100px;
    border-radius: 16px;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.apk-single-info {
    flex: 1;
}

.apk-single-title {
    font-size: 22px;
    margin: 0 0 8px 0;
    color: white;
}

@media (min-width: 768px) {
    .apk-single-title {
        font-size: 26px;
    }
}

.apk-single-developer {
    font-size: 15px;
    margin-bottom: 15px;
    opacity: 0.9;
}

.apk-single-meta {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.apk-single-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 20px;
}

.rating-stars {
    color: #FFD700;
    font-size: 14px;
}

.apk-single-size,
.apk-single-version {
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.apk-single-download {
    margin-top: 15px;
}

.apk-download-button.single {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: white;
    color: var(--apk-primary);
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    transition: var(--apk-transition);
}

.apk-download-button.single:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Loading State */
.apk-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
}

.apk-loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--apk-border);
    border-top-color: var(--apk-primary);
    border-radius: 50%;
    animation: apk-spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes apk-spin {
    to { transform: rotate(360deg); }
}

/* Utility Classes for Spacing */
.apk-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 10px;
}

/* Remove extra margins and paddings */
.premium-apk-grid-container > * {
    margin: 0;
    padding: 0;
}

/* Ensure cards fill grid cells properly */
.premium-apk-card {
    display: flex;
    flex-direction: column;
}

/* Fix for badge positioning */
.apk-card-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Remove any extra spacing in mobile */
@media (max-width: 767px) {
    body .premium-apk-grid-container {
        margin: 0;
        padding: 8px;
        width: 100%;
    }
    
    .premium-apk-card {
        margin: 0;
    }
    
    /* Force 2 columns exactly */
    .premium-apk-grid-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== FINAL SCREENSHOTS GALLERY ===== */

.apk-screenshots-section {
    margin: 40px 0 30px;
    padding: 0;
    position: relative;
    width: 100%;
}

.apk-screenshots-section h2 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 22px;
    font-weight: 600;
    padding: 0;
    text-align: left;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.screenshots-count {
    color: #666;
    font-size: 13px;
    font-weight: normal;
    background: #f5f5f5;
    padding: 3px 10px;
    border-radius: 10px;
}

/* Main Gallery Container */
.screenshots-gallery {
    position: relative;
    width: 100%;
    overflow: visible;
}

/* Gallery Container */
.gallery-container {
    position: relative;
    padding: 15px 0;
    width: 100%;
}

/* Screenshots Horizontal Scroll Container */
.screenshots-scroll-container {
    display: flex;
    gap: 12px;
    padding: 10px 5px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
}

.screenshots-scroll-container::-webkit-scrollbar {
    height: 4px;
}

.screenshots-scroll-container::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 2px;
}

.screenshots-scroll-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.screenshots-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Screenshot Item - Smaller Size */
.screenshot-item {
    flex: 0 0 auto;
    width: 160px; /* Smaller width */
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: white;
    border: 1px solid #eee;
}

.screenshot-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    border-color: #4285f4;
}

/* Screenshot Image - Smaller Height */
.screenshot-image {
    width: 100%;
    height: 280px; /* Smaller height */
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.screenshot-item:hover .screenshot-image {
    transform: scale(1.05);
}

/* Screenshot Number Badge */
.screenshot-number {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
}

/* Download Button */
.screenshot-download {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(66, 133, 244, 0.9);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
    z-index: 2;
}

.screenshot-item:hover .screenshot-download {
    opacity: 1;
    transform: translateY(0);
}

.screenshot-download:hover {
    background: #3367d6;
    transform: scale(1.1);
}

.screenshot-download i {
    font-size: 14px;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Desktop - Bigger Container */
@media (min-width: 1024px) {
    .screenshot-item {
        width: 180px; /* Slightly bigger on desktop */
    }
    
    .screenshot-image {
        height: 320px;
    }
    
    .screenshots-scroll-container {
        gap: 15px;
        padding: 15px 10px;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .screenshot-item {
        width: 170px;
    }
    
    .screenshot-image {
        height: 300px;
    }
    
    .apk-screenshots-section h2 {
        font-size: 20px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .apk-screenshots-section {
        margin: 30px 0 20px;
    }
    
    .apk-screenshots-section h2 {
        font-size: 18px;
        margin-bottom: 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .screenshots-count {
        align-self: flex-start;
    }
    
    .screenshot-item {
        width: 150px;
    }
    
    .screenshot-image {
        height: 260px;
    }
    
    .screenshots-scroll-container {
        gap: 10px;
        padding: 8px 5px;
    }
    
    .screenshot-number {
        width: 22px;
        height: 22px;
        font-size: 11px;
        top: 6px;
        left: 6px;
    }
    
    .screenshot-download {
        width: 26px;
        height: 26px;
        bottom: 6px;
        right: 6px;
    }
    
    .screenshot-download i {
        font-size: 12px;
    }
    
    /* Mobile scroll hint */
    .scroll-hint {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        color: #666;
        font-size: 13px;
        margin-top: 12px;
        padding: 8px;
        background: #f8f9fa;
        border-radius: 8px;
        animation: pulse-hint 2s infinite;
    }
    
    @keyframes pulse-hint {
        0%, 100% { opacity: 0.7; }
        50% { opacity: 1; }
    }
    
    .scroll-hint i {
        font-size: 16px;
        color: #4285f4;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .screenshot-item {
        width: 140px;
    }
    
    .screenshot-image {
        height: 240px;
    }
    
    .screenshots-count {
        font-size: 12px;
    }
}

/* ===== MODAL STYLES ===== */

.screenshot-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    overflow: hidden;
}

.screenshot-modal.active {
    display: block;
}

.modal-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 16px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

/* ===== ANIMATIONS ===== */

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

.apk-screenshots-section {
    animation: fadeIn 0.5s ease-out;
}

/* ===== LOADING PLACEHOLDER ===== */

.screenshot-loading {
    width: 100%;
    height: 280px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 10px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== DOWNLOAD BUTTON STATES ===== */

/* Loading State */
.apk-download-button.loading {
    position: relative;
    overflow: hidden;
}

.apk-download-button.loading:after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Downloaded State */
.apk-download-button.downloaded {
    animation: downloaded-pulse 0.5s ease;
}

@keyframes downloaded-pulse {
    0% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.05); }
    100% { transform: translateY(-50%) scale(1); }
}

.apk-download-button.mobile.downloaded {
    animation: mobile-downloaded-pulse 0.5s ease;
}

@keyframes mobile-downloaded-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* Disabled State */
.apk-download-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Tablet Responsive */
@media (min-width: 768px) and (max-width: 1024px) {
    .apk-single-header {
        padding: 20px;
        gap: 20px;
    }
    
    .apk-icon-image {
        width: 100px;
        height: 100px;
    }
    
    .apk-single-title {
        font-size: 24px;
    }
    
    .apk-single-download-desktop {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        margin-top: 20px;
        width: 100%;
    }
    
    .apk-download-button.desktop {
        width: 100%;
        justify-content: center;
    }
    
    .apk-single-download-mobile {
        display: none;
    }
}

/* Hide/Show based on device */
.apk-single-download-mobile {
    display: none;
}

@media (max-width: 767px) {
    .apk-single-download-desktop {
        display: none;
    }
    
    .apk-single-download-mobile {
        display: block;
        margin-top: 20px;
    }
}