/* Trackings USA Dashboard
   Static site for GitHub Pages.
   Creador: Brayan Raudales Tu Papi
*/

:root{
  --bg:#0b0e14;
  --panel:#0f1420;
  --panel2:#121a2a;
  --text:#e9eef7;
  --muted:#a8b3c7;
  --border:rgba(255,255,255,.10);
  --shadow: 0 18px 55px rgba(0,0,0,.55);
  --radius: 18px;
  --radius2: 14px;
  --accent:#6ee7ff;
  --good:#76f7a6;
  --warn:#ffd27a;
  --bad:#ff7a7a;
}

*{box-sizing:border-box}
html,body{
  overscroll-behavior: none;
}

body.noScroll{
  overflow:hidden;
}

body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 650px at 12% 10%, rgba(110,231,255,.14), rgba(0,0,0,0)),
              radial-gradient(1000px 650px at 88% 0%, rgba(118,247,166,.10), rgba(0,0,0,0)),
              var(--bg);
  color:var(--text);
}

a{color:inherit}

.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px;
  background:rgba(11,14,20,.68);
  backdrop-filter: blur(12px);
  border-bottom:1px solid var(--border);
}

.brand{display:flex; gap:12px; align-items:center}
.logo{font-size:24px}
.brandTitle{font-weight:800; letter-spacing:.2px}
.brandSubtitle{font-size:12px; color:var(--muted)}

.topbarActions{display:flex; gap:10px; align-items:center; flex-wrap:wrap}

.container{max-width:1150px; margin:0 auto; padding:18px 14px 50px}

.toolbar{
  margin-top:10px;
  display:flex; gap:12px; justify-content:space-between; align-items:flex-start;
  padding:14px;
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(18,26,42,.85), rgba(15,20,32,.75));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.toolbarLeft{display:flex; gap:12px; align-items:center; flex-wrap:wrap; flex:1}
.toolbarRight{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.syncStatus{font-size:12px; color:var(--muted); padding:6px 10px; border:1px solid var(--border); border-radius:999px; background:rgba(0,0,0,.16)}

.input, .select{
  width:100%;
  padding:10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.22);
  color: var(--text);
  outline:none;
}
.input:focus, .select:focus{border-color: rgba(110,231,255,.55); box-shadow: 0 0 0 3px rgba(110,231,255,.12)}
.select{min-width:220px}

.btn{
  border:1px solid var(--border);
  border-radius: 12px;
  padding:10px 12px;
  cursor:pointer;
  background: rgba(0,0,0,.18);
  color:var(--text);
  font-weight:700;
}
.btn:hover{filter:brightness(1.05)}
.btnPrimary{
  border-color: rgba(110,231,255,.40);
  background: rgba(110,231,255,.14);
}
.btnDanger{
  border-color: rgba(255,122,122,.45);
  background: rgba(255,122,122,.14);
}
.btnGhost{background: rgba(0,0,0,.10)}
.iconBtn{
  border:1px solid var(--border);
  border-radius: 12px;
  padding:8px 10px;
  cursor:pointer;
  background: rgba(0,0,0,.12);
  color:var(--text);
}
.iconBtn:hover{filter:brightness(1.05)}

.tagFilters{display:flex; gap:8px; flex-wrap:wrap}

.chip{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(0,0,0,.16);
  color: var(--muted);
  font-size: 13px;
  user-select:none;
}
.chip input{accent-color: var(--accent)}

.stats{
  margin:14px 0 10px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
}
.statCard{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(15,20,32,.72);
  padding:12px;
}
.statLabel{color:var(--muted); font-size:12px}
.statValue{font-size:18px; font-weight:800; margin-top:6px}

.list{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top:10px;
}
.card{
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(18,26,42,.78), rgba(15,20,32,.68));
  padding:14px;
  box-shadow: 0 10px 40px rgba(0,0,0,.40);
  display:flex;
  gap:12px;
  align-items:flex-start;
  justify-content:space-between;
}
.cardMedia{
  display:flex;
  gap:12px;
  align-items:flex-start;
}
.miniThumb{
  width:62px;
  height:62px;
  border-radius: 14px;
  overflow:hidden;
  border:1px solid var(--border);
  background: rgba(0,0,0,.18);
  position:relative;
  flex: 0 0 auto;
  cursor:pointer;
}
.miniThumb img{width:100%; height:100%; object-fit:cover; display:block}
.miniThumb .miniCount{
  position:absolute; right:6px; bottom:6px;
  font-size:11px;
  padding:3px 7px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.55);
  color:#fff;
}
.cardLeft{flex:1; min-width:0}
.cardTitle{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.hTitle{font-weight:900; letter-spacing:.2px}
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:12px;
  color:var(--muted);
  background: rgba(0,0,0,.14);
}
.badge.good{border-color: rgba(118,247,166,.35); color: rgba(118,247,166,.95); background: rgba(118,247,166,.10)}
.badge.warn{border-color: rgba(255,210,122,.40); color: rgba(255,210,122,.95); background: rgba(255,210,122,.10)}
.badge.bad{border-color: rgba(255,122,122,.42); color: rgba(255,122,122,.95); background: rgba(255,122,122,.10)}
.badge.info{border-color: rgba(110,231,255,.35); color: rgba(110,231,255,.92); background: rgba(110,231,255,.10)}

.cardMeta{
  margin-top:8px;
  display:flex;
  flex-wrap:wrap;
  gap:8px 12px;
  color:var(--muted);
  font-size:13px;
}
.mono{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace}
.cardActions{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}

.footer{
  margin-top:18px;
  border-top:1px solid var(--border);
  padding-top:16px;
  color:var(--muted);
  font-size:12px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}

.muted{color:var(--muted)}
.small{font-size:12px}
.row{display:flex; gap:12px; margin-top:12px; align-items:center; justify-content:flex-end; flex-wrap:wrap}
.label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px}
.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}
.tagPickers{display:flex; flex-wrap:wrap; gap:8px}
.details{
  margin-top:12px;
  border:1px solid var(--border);
  border-radius: var(--radius2);
  padding:10px 12px;
  background: rgba(0,0,0,.14);
}
.callout{
  border:1px solid rgba(110,231,255,.25);
  background: rgba(110,231,255,.08);
  border-radius: var(--radius2);
  padding:10px 12px;
  margin-bottom:12px;
  color: var(--text);
}
.hint{margin-top:10px}
.error{
  margin-top:10px;
  border:1px solid rgba(255,122,122,.45);
  background: rgba(255,122,122,.10);
  padding:10px 12px;
  border-radius: var(--radius2);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 24vh;
  overflow:auto;
}

/* Modals */
.modalBackdrop{
  position:fixed; inset:0;
  background: rgba(0,0,0,.62);
  overscroll-behavior: contain;
  display:none;
  align-items:center;
  justify-content:center;
  padding:14px;
  z-index:50;
}
.modalBackdrop.show{display:flex}
.modal{
  width:min(860px, 100%);
  border:1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(15,20,32,.94);
  box-shadow: var(--shadow);
  overflow:hidden;
  max-height: calc(100vh - 28px);
  display:flex;
  flex-direction:column;
}
.modalLarge{width:min(1060px, 100%)}
.loginModal{width:min(620px,100%)}
.modalHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 14px;
  border-bottom:1px solid var(--border);
  background: rgba(0,0,0,.18);
  gap:10px;
  flex-wrap:wrap;
  position: sticky;
  top:0;
  z-index:2;
}
.modalTitle{font-weight:900; letter-spacing:.2px; min-width:0}
.modalBody{padding:14px; overflow:auto; -webkit-overflow-scrolling: touch;  overscroll-behavior: contain;
}

.metaBox{
  width: 260px;
  border:1px solid var(--border);
  border-radius: var(--radius2);
  padding:10px 12px;
  background: rgba(0,0,0,.14);
}
.imageGrid{
  margin-top:10px;
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:8px;
}
.thumb{
  border:1px solid var(--border);
  border-radius: 12px;
  overflow:hidden;
  background: rgba(0,0,0,.18);
  position:relative;
}
.thumb img{width:100%; height:100px; object-fit:cover; display:block}
.thumb .thumbBar{
  position:absolute; left:0; right:0; bottom:0;
  padding:6px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.75));
  display:flex; justify-content:space-between; gap:6px;
  font-size:11px;
  color:#fff;
}
.thumb .xBtn{
  border:none; cursor:pointer;
  background: rgba(255,255,255,.18);
  color:#fff;
  border-radius: 10px;
  padding:2px 8px;
}

/* Tag colors (custom) */
.tagBadge{
  border-color: var(--tagBorder, var(--border));
  background: var(--tagBg, rgba(110,231,255,.10));
}
.chip{
  border-color: var(--chipBorder, var(--border));
}
.chip[data-tagchip="1"]{
  border-color: var(--chipBorder, var(--border));
}

/* Tags manager in settings */
.sectionBox{
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  background: rgba(0,0,0,.12);
}
.sectionTitle{
  font-weight: 900;
  margin-bottom: 6px;
}
.tagsManager{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top: 10px;
}
.tagRow{
  display:grid;
  grid-template-columns: 78px 1fr 78px 90px;
  gap:8px;
  align-items:center;
}
.tagRow .btnTiny{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
}
.colorInput{
  height: 42px;
  padding: 0 6px;
}
@media (max-width: 640px){
  .tagRow{
    grid-template-columns: 1fr 1fr;
  }
  .tagRow .btnTiny{
    grid-column: 1 / -1;
  }
}

/* Gallery */
.galleryMain{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  position:relative;
}
.galleryImg{
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.18);
}
.navBtn{
  border:1px solid var(--border);
  border-radius: 999px;
  width:44px;
  height:44px;
  padding:0;
  cursor:pointer;
  background: rgba(0,0,0,.22);
  color:var(--text);
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  position:absolute;
  top:50%;
  transform: translateY(-50%);
  z-index:3;
  backdrop-filter: blur(10px);
}
.navBtn:hover{filter:brightness(1.05)}
#btnGalleryPrev{left:10px}
#btnGalleryNext{right:10px}
.galleryBar{
  margin-top:10px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.galleryThumbs{
  margin-top:10px;
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding-bottom:6px;
}
.gThumb{
  width:70px;
  height:56px;
  border-radius: 12px;
  overflow:hidden;
  border:1px solid var(--border);
  background: rgba(0,0,0,.18);
  flex: 0 0 auto;
  cursor:pointer;
  opacity:.82;
}
.gThumb.active{opacity:1; border-color: rgba(110,231,255,.55)}
.gThumb img{width:100%; height:100%; object-fit:cover; display:block}

@media (max-width: 820px){
  .stats{grid-template-columns: 1fr}
  .grid2{grid-template-columns: 1fr}
  .select{min-width: 180px}
  .card{flex-direction:column}
  .cardActions{justify-content:flex-start}
  .imageGrid{grid-template-columns: repeat(2,1fr)}
  .metaBox{width:100%}
}

@media (max-width: 620px){
  .topbar{flex-direction:column; align-items:flex-start; gap:10px}
  .topbarActions{width:100%; justify-content:flex-start}
  .btn{padding:9px 10px; font-size:13px}
  .iconBtn{padding:8px 9px}
  .toolbar{flex-direction:column; align-items:stretch}
  .toolbarLeft{width:100%; flex-direction:column; align-items:stretch}
  .toolbarRight{width:100%}
  .tagFilters{width:100%}
  .chip{justify-content:flex-start}
  .syncStatus{width:100%; text-align:center}
  .select{min-width: unset; width:100%}
  .cardActions .btn{flex:1; min-width:140px}
  .galleryMain{gap:8px}
  .navBtn{width:48px; height:48px}
  .galleryImg{max-height: 58vh}
}

/* Image helpers */
.fileActions{display:flex; gap:10px; flex-wrap:wrap; margin-top:8px}
.hiddenFile{display:none}
.dropZone{
  margin-top:10px;
  border:1px dashed rgba(255,255,255,.22);
  border-radius: var(--radius2);
  padding:10px 12px;
  color: var(--muted);
  background: rgba(0,0,0,.12);
}
.dropZone:focus{outline:none; border-color: rgba(110,231,255,.55); box-shadow: 0 0 0 3px rgba(110,231,255,.12)}


html, body { overscroll-behavior: none; }
.modalBackdrop { touch-action: none; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.modal, .modalBody { touch-action: pan-y; }
.galleryThumbs { touch-action: pan-x; }
#settingsError { display:none; }
#settingsError.show { display:block; }


.wheelBox{
  margin-top:12px;
  border:1px solid var(--border);
  border-radius: var(--radius2);
  padding:12px;
  background: rgba(0,0,0,.18);
}
.wheelBox #colorWheel{
  display:flex;
  align-items:center;
  justify-content:center;
}
