/**
 * Dr. Servicios - Chequéa Styles
 * Full Screen TikTok/IG Style Feed
 */

/* Chequéa Section Styles - Full Screen TikTok/IG Style */
.chequea-section {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    overflow: hidden;
}

.chequea-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10002;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chequea-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chequea-back-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.chequea-logo {
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.chequea-container {
    width: 100%;
    /* Height from below stories bar to bottom */
    height: calc(100vh - 150px); /* header(56px) + stories(~94px) */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Position below header + stories */
    margin-top: 150px;
    background: #000;
    /* TikTok-style scroll snap */
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

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

/* Post card - TikTok style full viewport */
.post-card {
    width: 100%;
    height: calc(100vh - 150px); /* Full viewport height below stories */
    min-height: calc(100vh - 150px);
    position: relative;
    background: #000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* TikTok scroll snap */
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* Post header - absolute overlay at top */
.post-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.post-header.hide-info {
    opacity: 0;
    visibility: hidden;
}

.post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4ADE80, #10b981);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    border: 2px solid white;
}

.post-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.post-user-info {
    flex: 1;
}

.post-user-name {
    font-weight: 700;
    color: white;
    font-size: 15px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.post-user-category {
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.post-timestamp {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Media container - fullscreen TikTok style */
.post-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.post-media::-webkit-scrollbar {
    display: none;
}

.post-media img,
.post-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    flex-shrink: 0;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}

/* Media indicators for multiple photos/videos */
.post-media-indicators {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    border-radius: 20px;
}

.media-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    transition: all 0.3s;
}

.media-indicator.active {
    width: 24px;
    border-radius: 4px;
    background: white;
}

/* Legacy grid styles - hidden in full-screen mode */
.post-media-grid {
    display: none;
}

/* Audio player - inside card */
.post-audio {
    position: relative;
    margin: 12px 16px;
    padding: 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
}

.post-audio audio {
    width: 100%;
}

/* Bottom gradient overlay for text readability */
.post-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
    pointer-events: none;
    z-index: 5;
}

/* Description - overlay at bottom left */
.post-description {
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    right: 80px;
    padding: 0;
    color: #ffffff;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    max-height: 80px;
    overflow-y: auto;
    scrollbar-width: none;
    background: transparent;
    text-shadow:
        0 1px 2px rgba(0,0,0,1),
        0 2px 4px rgba(0,0,0,0.8),
        0 0 8px rgba(0,0,0,0.6);
    z-index: 15;
    -webkit-font-smoothing: antialiased;
}

.post-description::-webkit-scrollbar {
    display: none;
}

/* Hide-info states for tap toggle */
.post-description {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.post-description.hide-info {
    opacity: 0;
    visibility: hidden;
}

.chequea-provider-actions {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chequea-provider-actions.hide-info {
    opacity: 0;
    visibility: hidden;
}

/* Action buttons - TikTok style vertical on right */
.post-actions {
    position: absolute;
    right: 12px;
    bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 10;
}

.post-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    font-weight: 500;
    font-size: 13px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.post-action-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}

.post-action-btn:active {
    transform: scale(0.95);
}

.post-action-btn.liked {
    color: #ef4444;
    background: rgba(239,68,68,0.3);
}

.post-action-btn .icon {
    font-size: 22px;
}

.post-action-btn .count {
    position: absolute;
    bottom: -18px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* Comments section as bottom sheet */
.post-comments {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    z-index: 10003;
    overflow-y: auto;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.post-comments.show {
    transform: translateY(0);
}

.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
}

.comments-title {
    font-weight: 700;
    font-size: 18px;
    color: #111827;
}

.comments-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    color: #6b7280;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment-input-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    background: white;
    padding: 8px 0;
    z-index: 1;
}

.comment-input {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    font-size: 16px; /* ✅ iOS: Evita zoom automático */
    outline: none;
    transition: border 0.2s;
}

.comment-input:focus {
    border-color: #4ADE80;
}

.comment-submit-btn {
    padding: 10px 20px;
    background: #4ADE80;
    color: white;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.comment-submit-btn:hover {
    background: #22c55e;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.comment-item {
    display: flex;
    gap: 10px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e5e7eb;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
    background: #f3f4f6;
    padding: 10px 14px;
    border-radius: 12px;
}

.comment-author {
    font-weight: 600;
    font-size: 13px;
    color: #111827;
    margin-bottom: 2px;
}

.comment-text {
    font-size: 14px;
    color: #374151;
}

.no-posts {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.no-posts-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #9ca3af;
    font-size: 14px;
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #4ADE80;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* Mobile optimizations for Chequéa - TikTok style */
@media (max-width: 768px) {
    .chequea-container {
        /* iOS Safari: use -webkit-fill-available as fallback */
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px); /* Dynamic viewport height for mobile */
        margin-top: 130px;
        /* Prevent rubber-band scrolling on iOS */
        -webkit-overflow-scrolling: touch;
    }

    .post-card {
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px);
        min-height: calc(100vh - 130px);
        min-height: calc(100dvh - 130px);
    }

    .post-header {
        padding: 12px;
        /* iOS Safari: account for notch */
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }

    .post-actions {
        right: 10px;
        bottom: calc(100px + env(safe-area-inset-bottom, 0px));
        gap: 16px;
    }

    .post-action-btn {
        width: 44px;
        height: 44px;
    }

    .post-action-btn .icon {
        font-size: 20px;
    }

    .post-description {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        left: 12px;
        right: 70px;
        font-size: 13px;
        max-height: 70px;
    }

    .post-media-indicators {
        top: 60px;
        padding: 6px 12px;
    }

    .post-audio {
        margin: 10px 12px;
    }

    .chequea-header {
        padding: 12px 16px;
    }

    .chequea-back-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .chequea-logo {
        font-size: 20px;
    }
}

/* Prevent pull-to-refresh on mobile */
.chequea-container {
    overscroll-behavior: contain;
}

/* Smooth scrolling for touch devices */
@media (hover: none) and (pointer: coarse) {
    .post-media {
        scroll-behavior: smooth;
    }
}

/* Pulguero post card - Card layout */
.pulguero-post-card {
    border-left: 4px solid #10b981;
}

/* Pulguero info overlay - now inside card */
.pulguero-post-card .pulguero-info-overlay {
    padding: 12px 16px;
    background: #1a1a1a;
}

/* ====================================
   CHEQUÉA PROVIDER POSTS STYLES
   ==================================== */

/* Chequéa provider post card - Card layout */
.chequea-provider-post-card {
    border-left: 4px solid #22c55e;
}

/* Chequéa provider info overlay - now inside card */
.chequea-provider-info-overlay {
    padding: 12px 16px;
    background: #1a1a1a;
}

/* ========================================
   STORY STYLES
   ======================================== */

/* Story card styling */
.story-card {
    position: relative;
}

/* Story avatar with Instagram-like gradient ring */
.story-avatar-ring {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    padding: 3px;
    background: linear-gradient(45deg, #22c55e, #16a34a, #15803d);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.story-avatar-ring img,
.story-avatar-ring > div {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #000;
    object-fit: cover;
}

/* Story badge - Green for branding */
.story-badge {
    display: inline-block;
    padding: 2px 8px;
    background: linear-gradient(45deg, #22c55e, #16a34a, #15803d);
    color: white;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-shadow: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Story media overlay */
.story-media {
    cursor: pointer;
    transition: opacity 0.2s;
}

.story-media:hover {
    opacity: 0.95;
}

/* Story actions simplified */
.story-actions {
    gap: 20px;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .story-avatar-ring {
        width: 40px;
        height: 40px;
    }

    .story-badge {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* ========================================
   GROUPED STORY CARD STYLES (Embedded Viewer)
   ======================================== */

/* Grouped story card needs relative positioning for absolute children */
.story-card-grouped {
    position: relative;
}

/* Progress bars container - positioned below the header overlay */
.story-card-progress-container {
    position: absolute;
    top: 65px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    z-index: 200;
    padding: 0 4px;
}

.story-card-progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.story-card-progress-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 2px;
}

/* Navigation zones */
.story-card-nav-prev,
.story-card-nav-next {
    position: absolute;
    top: 80px;
    bottom: 200px;
    width: 35%;
    z-index: 120;
    cursor: pointer;
}

.story-card-nav-prev {
    left: 0;
}

.story-card-nav-next {
    right: 0;
}

/* Pause indicator */
.story-card-paused-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 130;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    padding: 20px;
}

.story-card-paused-indicator.show {
    opacity: 1;
}

/* Media container adjustments for grouped cards */
.story-card-grouped .story-card-media-container {
    position: relative;
}

.story-card-grouped .story-card-media-container img,
.story-card-grouped .story-card-media-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Ensure header is above progress bars visually */
.story-card-grouped .chequea-provider-header {
    z-index: 140;
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
    .story-card-progress-container {
        top: 60px;
        left: 10px;
        right: 10px;
        gap: 3px;
    }

    .story-card-progress-bar {
        height: 2px;
    }

    .story-card-nav-prev,
    .story-card-nav-next {
        top: 60px;
        bottom: 180px;
    }

    .story-card-paused-indicator {
        padding: 16px;
    }

    .story-card-paused-indicator svg {
        width: 36px;
        height: 36px;
    }
}

/* Save/Guardar button in Chequéa posts */
.chequea-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    flex-shrink: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.chequea-save-btn:hover {
    border-color: #4ADE80;
    color: #4ADE80;
    background: rgba(74, 222, 128, 0.15);
}

.chequea-save-btn.saved {
    background: rgba(74, 222, 128, 0.2);
    border-color: #4ADE80;
    color: #4ADE80;
}

.chequea-save-btn.saved svg {
    fill: #4ADE80;
}

.chequea-save-text {
    font-size: 12px;
    white-space: nowrap;
}
