/* Smartphone Mode Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow: hidden;
    width: 100%;
    height: 100%;
}

body {
    background: var(--bg-base, #09090b);
    color: #fff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    width: 100%;
    height: 100%;
    max-width: 100vw;
}

/* Main Container */
.video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available; /* iOS Safari viewport fix */
    overflow: hidden;
    background: var(--bg-base, #09090b);
    z-index: 1;
    /* iOS Safari rendering fix */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Video Card */
.video-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    padding: 20px 16px 80px;
    padding: env(safe-area-inset-top, 20px) 16px calc(80px + env(safe-area-inset-bottom, 0px));
    -webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-out;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    z-index: 10;
    /* iOS Safari visibility fix */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    visibility: visible;
    opacity: 1;
    background: var(--bg-base, #09090b);
}

.video-card.is-favorite {
    box-shadow: inset 0 0 100px rgba(255, 215, 0, 0.1);
}

.card-content {
    width: 100%;
    max-width: 400px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 16px;
    /* iOS Safari visibility */
    visibility: visible;
    opacity: 1;
}

/* Thumbnail */
.thumbnail-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-elevated, #18181b);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Video Info */
.video-info {
    padding: 0 8px;
    max-width: 100%;
    overflow: hidden;
    word-break: break-word;
}

.video-title {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-date {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

.video-group {
    font-size: 12px;
    color: var(--primary-color, #6366f1);
    margin-top: 4px;
}

/* Swipe Animations */
.video-card.swipe-up {
    transform: translateY(-100%);
    opacity: 0;
}

.video-card.swipe-down {
    transform: translateY(100%);
    opacity: 0;
}

.video-card.swipe-left {
    transform: translateX(-100%);
    opacity: 0;
}

.video-card.swipe-right {
    transform: translateX(100%);
    opacity: 0;
}

/* Swipe Indicators */
.swipe-indicator {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 100;
}

.swipe-indicator.active {
    opacity: 1;
}

.indicator-icon {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 4px;
}

.indicator-text {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.indicator-up {
    top: calc(env(safe-area-inset-top, 20px) + 20px);
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary-color, #6366f1);
}

.indicator-down {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary-color, #6366f1);
}

.indicator-left {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #ef4444;
}

.indicator-right {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #fbbf24;
}

/* Action Feedback */
.action-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 32px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 200;
    backdrop-filter: blur(10px);
}

.action-feedback.show {
    opacity: 1;
}

.action-feedback.favorite {
    background: rgba(251, 191, 36, 0.9);
    color: #000;
}

.action-feedback.hidden {
    background: rgba(239, 68, 68, 0.9);
}

/* Navigation Bar */
.smartphone-nav {
    position: fixed;
    /* iOS Safari gesture area fix: move up from bottom */
    bottom: 20px;
    left: 10px;
    right: 10px;
    height: 60px;
    background: var(--bg-elevated, #18181b);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: space-around;
    -webkit-justify-content: space-around;
    justify-content: space-around;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    z-index: 99999;
    /* Force clickable - iOS Safari fixes */
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-touch-callout: default;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
    /* iOS Safari rendering */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.nav-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    -webkit-transition: background 0.2s, color 0.2s, transform 0.1s;
    transition: background 0.2s, color 0.2s, transform 0.1s;
    text-decoration: none;
    /* iOS Safari touch fixes */
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(99, 102, 241, 0.5);
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    z-index: 100000;
    /* Force hardware acceleration */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.nav-btn:hover,
.nav-btn:active {
    background: rgba(99, 102, 241, 0.3);
    color: #fff;
    -webkit-transform: translateZ(0) scale(0.95);
    transform: translateZ(0) scale(0.95);
}

.video-counter {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    min-width: 60px;
    text-align: center;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-base, #09090b);
    z-index: 300;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color, #6366f1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading p {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.6);
}

/* Auth Error */
.auth-error {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-base, #09090b);
    z-index: 300;
    text-align: center;
    padding: 20px;
}

.auth-error h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.auth-error p {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 24px;
}

.login-btn {
    padding: 12px 32px;
    background: var(--primary-color, #6366f1);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--primary-light, #818cf8);
}

/* Filter Button Badge */
.filter-btn {
    position: relative;
}

.filter-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--primary-color, #6366f1);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Group Selection Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: end;
    -webkit-align-items: flex-end;
    align-items: flex-end;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    z-index: 999999;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    background: var(--bg-elevated, #18181b);
    border-radius: 16px 16px 0 0;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    border-radius: 8px;
    touch-action: manipulation;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

/* Group List */
.group-list {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.group-option {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    -webkit-transition: background 0.2s;
    transition: background 0.2s;
    touch-action: manipulation;
    max-width: 100%;
    overflow: hidden;
}

.group-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.group-option.selected {
    background: rgba(99, 102, 241, 0.2);
}

.group-option.selected .group-name {
    color: var(--primary-color, #6366f1);
    font-weight: 600;
}

.group-name {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.group-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

/* Desktop support (for testing) */
@media (min-width: 768px) {
    .card-content {
        max-width: 500px;
    }

    .video-title {
        font-size: 22px;
    }

    .thumbnail-wrapper {
        border-radius: 16px;
    }

    .modal-content {
        border-radius: 16px;
        margin-bottom: 20px;
    }
}
