/* style.css - Final Version */

/* 1. GLOBALNI RESET (Popravlja sirinu Exit dugmeta) */
* { box-sizing: border-box; }

body {
    margin: 0; background-color: #121212; color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100vh; overflow: hidden; 
    user-select: none; -webkit-user-select: none; /* Zabrana selektiranja teksta */
}

/* --- IGRICA --- */
#game-container {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; width: 100%; transition: opacity 0.4s;
}
h1 { font-weight: 300; letter-spacing: 4px; color: #fff; margin-bottom: 20px;}

.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.cell {
    width: 80px; height: 80px; background-color: #1e1e1e; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem; cursor: pointer; color: #fff;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent;
}
.cell:active { background-color: #333; }
.cell.winner { background-color: #2e7d32; color: white; }

.status { margin-top: 25px; color: #888; min-height: 25px; }
.reset-btn {
    margin-top: 20px; padding: 10px 30px; background: transparent;
    border: 1px solid #555; color: #ccc; border-radius: 20px; cursor: pointer;
}

/* --- VAULT (GALERIJA) --- */
#vault-container {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; background: #000;
    flex-direction: column; z-index: 999;
}

/* Storage Bar */
.storage-info {
    background: #111; padding: 10px 15px; font-size: 11px; color: #888; border-bottom: 1px solid #222;
}
.progress-track { width: 100%; height: 4px; background: #333; margin-top: 5px; border-radius: 2px; }
.progress-fill { height: 100%; background: #00d2ff; width: 0%; transition: width 0.5s; }

/* Headeri (Switchable) */
.header-wrapper { height: 60px; background: #111; position: relative; overflow: hidden; border-bottom: 1px solid #222; }

.header-content {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 15px; height: 100%; width: 100%; position: absolute; left: 0; top: 0;
    transition: transform 0.3s ease-in-out;
}
#header-normal { transform: translateY(0); }
#header-selection { transform: translateY(-100%); background: #1a233a; }
.selection-active #header-normal { transform: translateY(100%); }
.selection-active #header-selection { transform: translateY(0); }

/* Dugmad */
.btn { background: #222; border: 1px solid #444; color: white; padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-primary { background: #007bff; border-color: #007bff; }
.btn-danger { background: #dc3545; border-color: #dc3545; }

/* File Input Hack */
.upload-wrap { position: relative; overflow: hidden; display: inline-block; }
.upload-wrap input { position: absolute; left: 0; top: 0; font-size: 100px; opacity: 0; cursor: pointer; height: 100%; width: 100%; }

/* Grid Galerija */
.gallery-scroll { flex: 1; overflow-y: auto; padding: 2px; -webkit-overflow-scrolling: touch; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding-bottom: 50px; }

.gallery-item { 
    position: relative; padding-top: 100%; background: #111; overflow: hidden;
    -webkit-touch-callout: none; /* Blokira iOS meni */
    -webkit-user-select: none;
}
.gallery-item img, .gallery-item video { 
    position: absolute; top:0; left:0; width:100%; height:100%; object-fit: cover; 
    pointer-events: none; 
}
.gallery-item.selected img, .gallery-item.selected video { opacity: 0.5; }

/* --- BADGES & ICONS --- */

/* Tip Fajla (MP4, JPG) - Gornji Desni */
.type-badge {
    position: absolute; top: 5px; right: 5px;
    background: rgba(0, 0, 0, 0.6); color: white;
    font-size: 10px; font-weight: bold; padding: 2px 5px;
    border-radius: 4px; pointer-events: none; z-index: 5;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Play Dugme (Sredina) */
.play-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    background: rgba(0, 0, 0, 0.4); border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    pointer-events: none; z-index: 4; backdrop-filter: blur(1px);
}
.play-icon::after {
    content: ''; display: block; width: 0; height: 0;
    border-left: 12px solid white; border-top: 7px solid transparent; border-bottom: 7px solid transparent;
    margin-left: 4px;
}

/* Kvačica za selekciju - Gornji Lijevi */
.check-circle {
    position: absolute; top: 5px; left: 5px; /* Lijevo da ne smeta badgeu */
    width: 22px; height: 22px;
    border: 2px solid white; border-radius: 50%; background: rgba(0,0,0,0.3);
    display: none; align-items: center; justify-content: center; z-index: 6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.check-circle::after { content:''; width: 12px; height: 12px; background: #007bff; border-radius: 50%; display: none; }

.selection-active .check-circle { display: flex; } /* Prikazi krugove u selection modu */
.gallery-item.selected .check-circle { background: white; border-color: #007bff; }
.gallery-item.selected .check-circle::after { display: block; }

/* --- UPLOAD MODAL --- */
.upload-modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 3000; flex-direction: column; padding: 20px;
}
.upload-modal-header { font-size: 18px; color: white; margin-bottom: 20px; font-weight: bold; }
.upload-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.file-progress-item { background: #1e1e1e; padding: 10px; border-radius: 8px; border: 1px solid #333; }
.file-info { display: flex; justify-content: space-between; color: #ccc; font-size: 12px; margin-bottom: 5px; }
.progress-bg { width: 100%; height: 6px; background: #333; border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0%; background: #00d2ff; transition: width 0.2s linear; }
.status-text { font-size: 10px; color: #888; margin-top: 3px; text-align: right; }
.close-upload-btn { margin-top: 15px; padding: 12px; background: #333; color: white; border: none; border-radius: 6px; width: 100%; cursor: pointer; display: none; }

/* --- DELETE LOADER --- */
.loader-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 4000;
    flex-direction: column; justify-content: center; align-items: center; color: white;
}
.spinner {
    width: 40px; height: 40px; border: 4px solid #333; border-top: 4px solid #ff4444;
    border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- FULLSCREEN VIEWER --- */
.fs-overlay { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: #000; z-index: 2000; align-items: center; justify-content: center; 
}
.close-fs { 
    position: absolute; top: 20px; right: 20px; color: white; font-size: 30px; 
    cursor: pointer; padding: 10px; z-index: 2010; 
    background: rgba(0,0,0,0.5); border-radius: 50%; width: 50px; height: 50px; 
    display:flex; align-items:center; justify-content:center;
}

/* FIX ZA VELIKE VIDEO FAJLOVE I SLIKE */
.fs-content {
    max-width: 100%;
    max-height: 100vh; /* Ne prelazi visinu ekrana */
    width: auto;
    height: auto;
    object-fit: contain; /* Osigurava da se sve vidi unutar ekrana */
    display: block;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 2005;
}