/**
 * Inshorts-Style Layout - ShortNews PWA
 * Full-screen vertical scroll, one news per page
 */

:root {
    --primary-color: #FF6B6B;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --bg-white: #ffffff;
    --border-color: #ecf0f1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8f9fa;
    overflow-x: hidden;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.control-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.control-btn:hover {
    background: #f0f0f0;
}

/* Category Navigation */
.category-nav {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: white;
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.category-nav::-webkit-scrollbar {
    display: none;
}

.category-list {
    display: flex;
    padding: 0 10px;
    min-width: max-content;
}

.category-item {
    padding: 15px 20px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.category-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* News Container - Vertical Scroll Snap */
.news-container {
    margin-top: 110px;
    /* Header + Category Nav */
    height: calc(100vh - 110px);
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
}

.news-container::-webkit-scrollbar {
    display: none;
}

/* News Card - Full Screen */
.news-card {
    height: calc(100vh - 110px);
    scroll-snap-align: start;
    background: white;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* News Image */
.news-image-container {
    width: 100%;
    height: 45%;
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.news-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.news-category-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    backdrop-filter: blur(10px);
}

/* News Content */
.news-content {
    flex: 1;
    padding: 25px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.news-headline {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.4;
    margin-bottom: 15px;
}

.news-summary {
    font-size: 16px;
    line-height: 1.7;
    color: #555;
    margin-bottom: 20px;
    flex: 1;
}

/* News Meta */
.news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.news-source {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 500;
}

.news-time {
    font-size: 12px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Read More Button */
.read-more-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: transform 0.2s;
}

.read-more-btn:active {
    transform: scale(0.98);
}

/* Loading State */
.loading-state {
    height: calc(100vh - 110px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 15px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Empty State */
.empty-state,
.error-state {
    height: calc(100vh - 110px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    text-align: center;
}

.empty-state h3,
.error-state h3 {
    font-size: 20px;
    color: var(--text-dark);
}

.empty-state p,
.error-state p {
    color: var(--text-light);
}

/* Scroll Indicator */
.scroll-indicator {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 100;
    animation: bounce 2s infinite;
    pointer-events: none;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    40% {
        transform: translateX(-50%) translateY(-10px);
    }

    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Responsive */
@media (min-width: 768px) {
    /* Main Layout */
    .news-container {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
        margin-top: 100px; /* Header + Nav */
        
        /* Grid Layout */
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 30px;
        padding: 20px;
        
        /* Disable Scroll Snap & Full Height on Desktop */
        height: auto; 
        overflow-y: visible;
        scroll-snap-type: none;
    }

    /* Header & Nav */
    .app-header {
        max-width: 100%;
        padding: 0 40px;
    }

    .category-nav {
        max-width: 100%;
        padding-left: 20px;
        padding-right: 20px;
        justify-content: center;
    }
    
    .category-list {
        justify-content: center;
        width: 100%;
    }

    /* News Card - Card Style on Desktop */
    .news-card {
        height: auto; /* Content based height */
        min-height: 450px;
        scroll-snap-align: none;
        border-radius: 16px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.05);
        border: 1px solid rgba(0,0,0,0.05);
        overflow: hidden;
        transition: transform 0.3s, box-shadow 0.3s;
    }
    
    .news-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    }
    
    .news-image-container {
        height: 220px; /* Fixed height for consistency */
    }
    
    .news-content {
        padding: 20px;
    }
    
    .news-headline {
        font-size: 20px;
    }
    
    .news-summary {
        font-size: 14px;
        /* Limit lines */
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 15px;
    }
    
    /* Scroll Indicator - Hide on Desktop */
    .scroll-indicator {
        display: none !important;
    }
}

/* Dark Mode */
body.dark-mode {
    background: #1a1a1a;
}

body.dark-mode .app-header,
body.dark-mode .category-nav,
body.dark-mode .news-card {
    background: #2d2d2d;
    color: #e0e0e0;
}

body.dark-mode .news-headline {
    color: #ffffff;
}

body.dark-mode .news-summary {
    color: #b0b0b0;
}

body.dark-mode .category-item {
    color: #888;
}

body.dark-mode .category-item.active {
    color: var(--primary-color);
}

/* ========================================
   NEW STYLES FOR ENHANCEMENTS
   ======================================== */

/* User Dropdown */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-dark);
}

#userName {
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: #333;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--text-dark);
    font-size: 24px;
}

/* Auth Forms */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form input {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.submit-btn {
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.submit-btn:hover {
    background: #ff5252;
}

.submit-btn:active {
    transform: scale(0.98);
}

.error-message {
    color: #e74c3c;
    font-size: 13px;
    padding: 10px;
    background: #ffebee;
    border-radius: 6px;
}

.auth-switch {
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
    color: #666;
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Content Actions (Likes, etc.) */
.content-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
}

.like-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 2px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.like-btn:hover {
    border-color: var(--primary-color);
    background: #fff5f5;
}

.like-btn.liked {
    border-color: var(--primary-color);
    background: #fff5f5;
}

.like-btn .like-icon {
    font-size: 18px;
    transition: transform 0.3s;
}

.like-btn.liked .like-icon {
    animation: heartBeat 0.5s;
}

@keyframes heartBeat {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.3);
    }

    50% {
        transform: scale(1.1);
    }
}

.like-count {
    font-weight: 600;
    color: var(--text-dark);
}

.views-count {
    font-size: 13px;
    color: var(--text-light);
}

/* Share Button (Floating) */
.share-btn-float {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s;
    z-index: 10;
}

.share-btn-float:hover {
    transform: scale(1.1);
}

.share-btn-float:active {
    transform: scale(0.95);
}

/* Share Modal */
.share-modal {
    max-width: 350px;
}

.share-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.share-btn {
    padding: 12px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.share-btn:hover {
    border-color: var(--primary-color);
    background: #f8f9fa;
}

.share-btn span {
    font-size: 20px;
}

/* Reel Card Styles */
.reel-card .news-image-container {
    height: 60%;
}

.reel-video-container {
    position: relative;
    width: 100%;
    height: 60%;
    background: #000;
}

.reel-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-controls {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 5;
}

.video-play-pause,
.video-mute-unmute {
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    backdrop-filter: blur(10px);
    transition: background 0.3s;
}

.video-play-pause:hover,
.video-mute-unmute:hover {
    background: rgba(0, 0, 0, 0.8);
}

.reel-duration {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

/* Ad Card Styles */
.ad-card {
    border: 2px solid #f0f0f0;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
}

.ad-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
}

.ad-media-container {
    width: 100%;
    height: 50%;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.ad-image,
.ad-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ad-content {
    padding: 20px;
}

.ad-title {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 15px;
}

/* Toast Messages */
.toast-message {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s;
    max-width: 90%;
    text-align: center;
}

.toast-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    background: #27ae60;
}

.toast-error {
    background: #e74c3c;
}

.toast-info {
    background: #3498db;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: #e74c3c;
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
}

/* Dark Mode Updates */
body.dark-mode .modal-content {
    background: #2d2d2d;
    color: #e0e0e0;
}

body.dark-mode .modal-content h2 {
    color: #ffffff;
}

/* Horizontal Scroll Helpers */
.category-list,
#categoryNav {
    cursor: grab;
    /* Show grab cursor */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

.category-list::-webkit-scrollbar,
#categoryNav::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.category-list.active,
#categoryNav.active {
    cursor: grabbing;
    cursor: -webkit-grabbing;
}

body.dark-mode .auth-form input {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .like-btn {
    border-color: #555;
    background: #2d2d2d;
}

body.dark-mode .like-btn:hover {
    background: #3a3a3a;
}

body.dark-mode .share-btn {
    background: #3a3a3a;
    border-color: #555;
    color: #e0e0e0;
}

body.dark-mode .user-dropdown {
    color: #e0e0e0;
}