/* assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-hover: rgba(51, 65, 85, 0.8);
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-primary: #8b5cf6;
    --accent-secondary: #06b6d4;
    --glass-border: rgba(255, 255, 255, 0.08);
    --hover-glow: 0 0 25px rgba(139, 92, 246, 0.25);
    --danger: #ef4444;
    --success: #22c55e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.15) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

main {
    flex: 1;
    padding: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.6s ease-out;
}

/* Header */
header {
    padding: 1rem 2rem;
    backdrop-filter: blur(12px);
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

/* Navigation */
nav {
    display: flex;
    gap: 0.5rem;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

nav a:hover,
nav a.active {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

nav i {
    margin-right: 6px;
}

/* Mobile Menu Toggle */
#mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Main Cards */
.meme-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    max-width: 450px;
    position: relative;
    overflow: hidden;
    /* Aspect ratio handled by img mostly, but container helps */
}

.meme-card:hover {
    transform: translateY(-5px);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: var(--hover-glow);
}

.meme-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background-color: #000;
    border-radius: 12px;
    display: block;
}

/* Tag Styles */
.meme-tags {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.tag-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px 12px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    user-select: none;
}

.tag-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-secondary);
    transform: translateY(-2px);
}

.tag-btn.clicked {
    transform: scale(0.95);
}

.tag-btn.active {
    border-color: currentColor;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* Zoom Button */
.zoom-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
    background: rgba(15, 23, 42, 0.7);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
}

.zoom-btn:hover {
    transform: scale(1.15);
    background: var(--accent-primary);
    border-color: var(--accent-secondary);
    color: white;
}

.zoom-btn i {
    font-size: 1.1rem;
}

/* Tag Specific Colors */
.tag-xd {
    color: #d8b4fe;
}

/* Purple */
.tag-it {
    color: #7dd3fc;
}

/* Light Blue */
.tag-culture {
    color: #6ee7b7;
}

/* Emerald */
.tag-pl {
    color: #fbbf24;
}

/* Amber */

.tag-xd.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: #a855f7;
}

.tag-it.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

.tag-culture.active {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
}

.tag-pl.active {
    background: rgba(251, 191, 36, 0.2);
    border-color: #fbbf24;
}

.tag-name {
    font-weight: 600;
    opacity: 0.9;
}

.tag-count {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-secondary);
}

/* Battle Layout */
.battle-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 1rem;
}

.vs-badge {
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    color: white;
    font-weight: 800;
    font-size: 1.2rem;
    padding: 0.8rem;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
    z-index: 10;
    flex-shrink: 0;
}

/* Upload & Inputs */
.upload-box {
    background: var(--card-bg);
    border: 2px dashed var(--glass-border);
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    transition: 0.3s;
    width: 100%;
    max-width: 600px;
    position: relative;
}

.upload-box.dragging {
    border-color: var(--accent-secondary);
    background: rgba(6, 182, 212, 0.1);
    transform: scale(1.02);
}

.upload-box:hover {
    border-color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.05);
}

input[type="text"],
input[type="password"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

input:focus {
    border-color: var(--accent-primary);
}

.btn {
    background: linear-gradient(to right, var(--accent-secondary), var(--accent-primary));
    color: #fff;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 99px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.btn:active {
    transform: scale(0.98);
}

.skip-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 99px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.skip-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border-color: var(--text-muted);
}

.skip-btn i {
    font-size: 0.8rem;
}

.custom-file-upload {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    font-weight: 500;
    margin-top: 1rem;
    transition: all 0.2s;
}

.custom-file-upload:hover {
    background: rgba(255, 255, 255, 0.15);
}

input[type="file"] {
    display: none;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    width: 100%;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: #000;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.progress-container {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    height: 6px;
    border-radius: 10px;
    margin-top: 1.5rem;
    overflow: hidden;
    display: none;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
    width: 0%;
    transition: width 0.3s ease;
}

/* Ranking Table */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    min-width: 600px;
    /* Force scroll on small screens */
}

.ranking-table th,
.ranking-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.ranking-table th {
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.ranking-table tr:last-child td {
    border-bottom: none;
}

.ranking-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.rank-numb {
    font-weight: 700;
    color: var(--accent-secondary);
}

.rank-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

/* Admin Grid */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin-top: 2rem;
}

.admin-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}

.admin-card img {
    width: 100%;
    aspect-ratio: 16/9;
    /* Or 1/1 depending on preference */
    object-fit: cover;
    background: #000;
}

.admin-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.5rem;
}

.delete-btn {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.6rem;
    width: 100%;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    margin-top: auto;
}

.delete-btn:hover {
    background: #dc2626;
}

/* Stats Overlay */
.stats-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 15px;
    z-index: 20;
}

.stats-overlay.show {
    opacity: 1;
}

.stats-content {
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stats-overlay.show .stats-content {
    transform: scale(1);
}

/* Footer */
footer {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.6);
}

.admin-login-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.admin-login-link:hover {
    opacity: 1;
    color: var(--accent-secondary);
}

/* Last Vote Section */
.last-vote-container {
    width: 100%;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
    animation: fadeIn 0.8s ease-out;
}

.last-vote-title {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.lv-grid {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.lv-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    gap: 1rem;
    width: 100%;
    max-width: 400px;
    transition: transform 0.2s;
}

.lv-card:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-2px);
}

.lv-card.winner {
    border-left: 3px solid var(--success);
}

.lv-card.loser {
    border-left: 3px solid var(--danger);
}

.lv-img-wrapper {
    width: 100px;
    height: 100px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    cursor: zoom-in;
}

.lv-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lv-img-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.lv-img-wrapper:hover .lv-img-overlay {
    opacity: 1;
}

.lv-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    font-size: 0.9rem;
}

.lv-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lv-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.lv-value {
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 1001;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--accent-primary);
    text-decoration: none;
    cursor: pointer;
}

.modal-footer-action {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1002;
    animation: fadeIn 0.4s ease-out 0.2s both;
}

/* Mobile Responsiveness update */
@media (max-width: 768px) {

    /* ... existing media styles ... */
    header {
        padding: 1rem;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    /* ... rest of existing media query ... */


    header h1 {
        font-size: 1.2rem;
        margin-bottom: 0;
    }

    #mobile-menu-toggle {
        display: block !important;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
    }

    #main-nav {
        display: none;
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        width: 100%;
        background: rgba(30, 41, 59, 0.95);
        border-bottom: 1px solid var(--glass-border);
        border-top: 1px solid var(--glass-border);
        flex-direction: column;
        padding: 0.5rem;
        margin-top: 1rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        border-radius: 8px;
    }

    #main-nav.active {
        display: flex;
    }

    #main-nav a {
        padding: 1rem;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.03);
        margin-bottom: 0.5rem;
        text-align: center;
        width: 100%;
    }

    #main-nav a:last-child {
        margin-bottom: 0;
    }

    /* Battle Mobile */
    .battle-container {
        flex-direction: column;
        gap: 0.5rem;
        height: auto;
        max-height: calc(100vh - 120px);
        /* Viewport minus header and footer space */
        overflow-y: auto;
        padding: 0.5rem 0;
    }

    .meme-card {
        max-width: 90vw;
        max-height: calc((100vh - 140px) / 2);
        /* Split available height between 2 cards */
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
    }

    .meme-card img {
        max-height: calc((100vh - 250px) / 2);
        /* Ensured space for tags below */
        width: auto;
        max-width: 100%;
        object-fit: contain;
    }

    .meme-tags {
        margin-top: 10px;
        gap: 6px;
        justify-content: center;
        width: 100%;
    }

    .tag-btn {
        padding: 4px 10px;
        font-size: 0.8rem;
    }

    .zoom-btn {
        bottom: auto;
        top: 10px;
        left: 10px;
        width: 34px;
        height: 34px;
    }

    .vs-badge {
        display: none;
    }

    /* Upload & Admin Mobile */
    .upload-box {
        padding: 1.5rem;
    }

    .admin-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .admin-card img {
        height: 100px;
    }

    main {
        padding: 1rem;
    }
}