/* M3U8 Streaming Platform - Custom Styles */

/* iOS Safari Safe Area Support */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* Prevent horizontal scroll on all devices */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
}

/* Mobile Safari Viewport Fix */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Safari video playback fix */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Safari Smooth Scrolling */
* {
    -webkit-overflow-scrolling: touch;
}

/* Mobile Touch Improvements */
button, a, input, select, textarea {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
    /* Ensure minimum tap target size (iOS HIG: 44x44px) */
    min-height: 44px;
}

/* Prevent iOS Zoom on Input Focus */
input, select, textarea {
    font-size: 16px !important;
}

/* Safari Video Element Fixes */
video {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* Enable native fullscreen on iOS */
    -webkit-playsinline: true;
    webkit-playsinline: true;
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

#loadingPage.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Category States */
.category.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* Channel Grid */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    animation: fadeIn 0.4s ease-in-out;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Mobile Responsive Grid */
@media (max-width: 640px) {
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
        padding: 1rem !important;
    }
}

/* Small Mobile (iPhone SE, etc) */
@media (max-width: 375px) {
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
        padding: 0.75rem !important;
    }
}

/* Tabs Horizontal Scroll for Mobile */
.tabs-container {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.channel-card {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    /* Safari Hardware Acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    /* Prevent card overflow */
    max-width: 100%;
    overflow: hidden;
}

/* Modal States */
.video-modal.active,
.playlist-modal.active,
.loading-indicator.active {
    display: flex !important;
}

.tab-content.active {
    display: block !important;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.3);
    font-weight: 700;
}

.repo-item.selected {
    background: rgba(76, 175, 80, 0.5) !important;
    border: 2px solid #4CAF50 !important;
}

/* Status Messages */
.status-message {
    display: none;
}

.status-message.success {
    background: rgba(76, 175, 80, 0.3);
    border: 1px solid #4CAF50;
    display: block;
}

.status-message.error {
    background: rgba(244, 67, 54, 0.3);
    border: 1px solid #f44336;
    display: block;
}

.status-message.info {
    background: rgba(33, 150, 243, 0.3);
    border: 1px solid #2196F3;
    display: block;
}

/* Title Fix */
h1 {
    line-height: 1.2;
    overflow: visible;
}

h1 span {
    display: inline-block;
    padding: 0.25rem 0;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* Line Clamp Utility */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

/* Prevent text overflow globally */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

/* Container constraints */
.container {
    max-width: 100%;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(17, 24, 39, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgb(55, 65, 81);
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgb(75, 85, 99);
}

/* Focus & Selection */
*:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 87, 255, 0.5);
}

::selection {
    background: #0057FF;
    color: white;
}
