/**
 * Reddit-style UI/UX Styles for Munotes
 * Includes voting system, post cards, and community widgets
 */

/* ============================================
   CSS Variables - Reddit Color Palette
   ============================================ */
:root {
    --reddit-orange: #FF4500;
    --reddit-orange-hover: #FF5722;
    --reddit-blue: #7193FF;
    --reddit-blue-hover: #5A7FE0;
    --reddit-bg: #DAE0E6;
    --reddit-card-bg: #FFFFFF;
    --reddit-border: #EDEFF1;
    --reddit-text: #1C1C1C;
    --reddit-text-secondary: #7C7C7C;
    --reddit-karma-gold: #FFD700;
}

/* ============================================
   Vote Button Styles
   ============================================ */
.vote-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: linear-gradient(180deg, #f8f9fa 0%, #f1f3f5 100%);
    border-radius: 8px;
    min-width: 40px;
}

.vote-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #878A8C;
}

.vote-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.vote-btn[data-vote-btn="up"]:hover {
    color: var(--reddit-orange);
    background: rgba(255, 69, 0, 0.1);
}

.vote-btn[data-vote-btn="down"]:hover {
    color: var(--reddit-blue);
    background: rgba(113, 147, 255, 0.1);
}

.vote-btn.vote-active[data-vote-btn="up"] {
    color: var(--reddit-orange);
    background: rgba(255, 69, 0, 0.15);
}

.vote-btn.vote-active[data-vote-btn="down"] {
    color: var(--reddit-blue);
    background: rgba(113, 147, 255, 0.15);
}

.vote-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.15s ease;
}

.vote-btn:active svg {
    transform: scale(0.9);
}

/* Vote score display */
.vote-score {
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    padding: 4px 0;
    min-width: 24px;
    text-align: center;
    transition: color 0.2s ease;
}

.vote-score.positive {
    color: var(--reddit-orange);
}

.vote-score.negative {
    color: var(--reddit-blue);
}

/* Vote animation */
.vote-bounce {
    animation: voteBounce 0.3s ease;
}

@keyframes voteBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Floating vote indicator */
.vote-indicator {
    position: fixed;
    font-weight: 700;
    font-size: 16px;
    pointer-events: none;
    z-index: 9999;
    animation: floatUp 0.8s ease-out forwards;
    transform: translateX(-50%);
}

.vote-indicator-up {
    color: var(--reddit-orange);
}

.vote-indicator-down {
    color: var(--reddit-blue);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px);
    }
}

/* Loading state */
.voting-loading {
    opacity: 0.6;
    pointer-events: none;
}

.vote-in-progress .vote-btn {
    pointer-events: none;
}

/* ============================================
   Reddit-Style Post Card
   ============================================ */
.reddit-card {
    display: flex;
    background: var(--reddit-card-bg);
    border: 1px solid var(--reddit-border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.reddit-card:hover {
    border-color: #898989;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.reddit-card-vote {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 8px;
    background: #F8F9FA;
    gap: 0;
}

.reddit-card-content {
    flex: 1;
    padding: 12px 16px 12px 12px;
    min-width: 0;
}

.reddit-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--reddit-text-secondary);
    margin-bottom: 6px;
}

.reddit-card-meta a {
    color: var(--reddit-text-secondary);
    text-decoration: none;
}

.reddit-card-meta a:hover {
    text-decoration: underline;
}

.reddit-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--reddit-text);
    margin-bottom: 8px;
    line-height: 1.4;
    display: block;
    text-decoration: none;
}

.reddit-card-title:hover {
    color: var(--reddit-orange);
}

.reddit-card-flair {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Flair colors by type */
.flair-notes {
    background: #E8F5E9;
    color: #2E7D32;
}

.flair-question-papers {
    background: #E3F2FD;
    color: #1565C0;
}

.flair-syllabus {
    background: #FFF3E0;
    color: #E65100;
}

.flair-shared-by-students {
    background: #F3E5F5;
    color: #7B1FA2;
}

.flair-other {
    background: #ECEFF1;
    color: #546E7A;
}

/* Post info (college, path) */
.reddit-card-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--reddit-text-secondary);
    margin-bottom: 10px;
}

.reddit-card-info svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* Post actions */
.reddit-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.reddit-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--reddit-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.reddit-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--reddit-text);
}

.reddit-action-btn svg {
    width: 16px;
    height: 16px;
}

.reddit-action-btn.bookmarked {
    color: var(--reddit-orange);
}

/* ============================================
   Sort Tabs
   ============================================ */
.sort-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--reddit-card-bg);
    border: 1px solid var(--reddit-border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sort-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--reddit-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: all 0.15s ease;
}

.sort-tab:hover {
    background: rgba(0, 0, 0, 0.05);
}

.sort-tab.active {
    background: rgba(255, 69, 0, 0.1);
    color: var(--reddit-orange);
}

.sort-tab svg {
    width: 18px;
    height: 18px;
}

/* Time filter dropdown */
.time-filter {
    position: relative;
    margin-left: auto;
}

.time-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--reddit-text-secondary);
    background: #F6F7F8;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.time-filter-btn:hover {
    background: #EDEFF1;
}

.time-filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--reddit-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 120px;
    overflow: hidden;
    display: none;
}

.time-filter-dropdown.show {
    display: block;
}

.time-filter-option {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--reddit-text);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.time-filter-option:hover {
    background: #F6F7F8;
}

.time-filter-option.active {
    color: var(--reddit-orange);
    font-weight: 600;
}

/* ============================================
   Community Stats Widget
   ============================================ */
.community-widget {
    background: var(--reddit-card-bg);
    border: 1px solid var(--reddit-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.community-widget-header {
    background: linear-gradient(135deg, var(--reddit-orange) 0%, #FF6B3D 100%);
    color: white;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 14px;
}

.community-widget-body {
    padding: 16px;
}

.community-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.community-stat:last-child {
    border-bottom: none;
}

.community-stat-label {
    font-size: 13px;
    color: var(--reddit-text-secondary);
}

.community-stat-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--reddit-text);
}

.community-stat-highlight {
    color: var(--reddit-orange);
}

/* ============================================
   Top Contributors Widget
   ============================================ */
.contributor-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.contributor-item:last-child {
    border-bottom: none;
}

.contributor-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--reddit-text-secondary);
    background: #F6F7F8;
    border-radius: 50%;
}

.contributor-rank.gold {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: white;
}

.contributor-rank.silver {
    background: linear-gradient(135deg, #C0C0C0 0%, #A0A0A0 100%);
    color: white;
}

.contributor-rank.bronze {
    background: linear-gradient(135deg, #CD7F32 0%, #A0522D 100%);
    color: white;
}

.contributor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.contributor-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--reddit-orange) 0%, #FF6B3D 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.contributor-info {
    flex: 1;
    min-width: 0;
}

.contributor-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--reddit-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contributor-karma {
    font-size: 11px;
    color: var(--reddit-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.contributor-karma svg {
    width: 12px;
    height: 12px;
    color: var(--reddit-orange);
}

/* ============================================
   Karma Badge
   ============================================ */
.karma-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    color: #F57C00;
}

.karma-badge svg {
    width: 12px;
    height: 12px;
}

/* ============================================
   Uploader Info (Mini Profile)
   ============================================ */
.uploader-mini {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--reddit-text-secondary);
}

.uploader-mini:hover {
    color: var(--reddit-text);
}

.uploader-mini-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.uploader-mini-avatar-placeholder {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 600;
}

.uploader-mini-name {
    font-size: 12px;
    font-weight: 500;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .reddit-card {
        border-radius: 4px;
        margin-bottom: 8px;
    }

    .reddit-card-vote {
        padding: 8px 6px;
        min-width: 36px;
    }

    .vote-btn {
        width: 28px;
        height: 28px;
        min-height: 44px; /* Touch target */
    }

    .vote-btn svg {
        width: 16px;
        height: 16px;
    }

    .vote-score {
        font-size: 11px;
    }

    .reddit-card-content {
        padding: 10px 12px 10px 8px;
    }

    .reddit-card-title {
        font-size: 14px;
        line-height: 1.4;
    }

    .reddit-card-meta {
        font-size: 11px;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .reddit-card-meta > span:nth-child(2),
    .reddit-card-meta > span:nth-child(4) {
        display: none; /* Hide bullet separators on mobile */
    }

    .reddit-card-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .reddit-card-actions {
        gap: 2px;
        flex-wrap: wrap;
    }

    .reddit-action-btn {
        padding: 8px 10px;
        font-size: 11px;
        min-height: 40px; /* Touch target */
    }

    .sort-tabs {
        padding: 6px 8px;
        gap: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .sort-tabs::-webkit-scrollbar {
        display: none;
    }

    .sort-tab {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 40px; /* Touch target */
    }
    
    .sort-tab svg {
        width: 16px;
        height: 16px;
    }

    .time-filter-btn {
        padding: 8px 12px;
        min-height: 40px;
    }

    .community-widget {
        border-radius: 8px;
        margin-bottom: 12px;
    }
    
    .community-widget-header {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .community-widget-body {
        padding: 12px;
    }
    
    .community-stat {
        padding: 6px 0;
    }
    
    .community-stat-label {
        font-size: 12px;
    }
    
    .community-stat-value {
        font-size: 14px;
    }

    .contributor-item {
        padding: 8px 0;
    }
    
    .contributor-avatar,
    .contributor-avatar-placeholder {
        width: 32px;
        height: 32px;
    }
    
    .contributor-name {
        font-size: 12px;
    }
    
    .contributor-karma {
        font-size: 10px;
    }

    .uploader-mini {
        gap: 4px;
    }
    
    .uploader-mini-avatar,
    .uploader-mini-avatar-placeholder {
        width: 18px;
        height: 18px;
    }
    
    .uploader-mini-name {
        font-size: 11px;
    }

    .karma-badge {
        padding: 1px 6px;
        font-size: 10px;
    }
    
    .karma-badge svg {
        width: 10px;
        height: 10px;
    }

    .reddit-card-flair {
        padding: 2px 6px;
        font-size: 10px;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    .reddit-card-meta {
        font-size: 10px;
    }
    
    .reddit-card-title {
        font-size: 13px;
    }
    
    .sort-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .sort-tab svg {
        width: 14px;
        height: 14px;
    }
    
    .reddit-action-btn span {
        display: none; /* Hide text, show only icons on very small screens */
    }
    
    .reddit-action-btn {
        padding: 8px;
    }
}

/* ============================================
   Dark Mode Support (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    .reddit-card,
    .sort-tabs,
    .community-widget {
        /* Uncomment to enable dark mode
        background: #1A1A1B;
        border-color: #343536;
        */
    }
}

/* ============================================
   Animation Utilities
   ============================================ */
.fade-in {
    animation: fadeIn 0.3s ease;
}

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

.slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
