:root {
  --accent: #fe2c55;
  --nav-height: 60px;
  --action-size: 28px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* Toast de Feedback */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 255, 255, 0.95);
  color: #1c1c1e;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

/* Reset Básico */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Garante que o atributo hidden sempre funcione,
   mesmo em elementos com display definido no CSS */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  background-color: #000;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* Container do App (Ocupa a tela inteira do celular) */
.app {
  width: 100%;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  background-color: #000;
  display: flex;
  flex-direction: column;
}

/* Header Superior */
.top-header {
  position: absolute;
  top: var(--safe-top);
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 15px;
  z-index: 10;
  font-weight: 600;
  font-size: 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
}

.top-header span {
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  padding: 4px 8px;
}

.top-header span.active {
  color: #fff;
  border-bottom: 2px solid #fff;
  padding-bottom: 2px;
}

/* Feed com Scroll Snap */
.video-feed {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: none; /* Firefox */
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.video-feed::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

/* Container de Cada Vídeo */
.video-card {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  position: relative;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background-color: #111;
}

.video-player {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  background-color: #000;
}

/* Overlay de Informações (Autor, Descrição, Música) */
.video-info {
  position: absolute;
  bottom: calc(80px + var(--safe-bottom));
  left: calc(15px + var(--safe-left));
  right: calc(80px + var(--safe-right));
  z-index: 5;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.video-info .username {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
}

.video-info .description {
  font-size: 14px;
  margin-bottom: 10px;
  line-height: 1.3;
  word-break: break-word;
}

.video-info .music {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-info .music span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Barra Lateral de Ações (Curtir, Comentar, etc.) */
.action-bar {
  position: absolute;
  right: calc(12px + var(--safe-right));
  bottom: calc(100px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 5;
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
  cursor: pointer;
  min-width: 48px;
}

.action-item i {
  font-size: var(--action-size);
  margin-bottom: 4px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.action-item i.liked {
  color: var(--accent);
}

.action-item:active i {
  transform: scale(1.3);
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
  margin-bottom: 10px;
}

/* Barra de Navegação Inferior */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background-color: #000;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 10;
}

.nav-item {
  position: relative;
  background: none;
  border: none;
  color: #8a8b91;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: #fff;
}

.nav-item i {
  font-size: 18px;
}

.create-btn {
  background: linear-gradient(90deg, #00f2fe, var(--accent));
  padding: 3px;
  border-radius: 8px;
  color: #000;
  width: 42px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.create-btn i {
  background: #fff;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Tela de Perfil */
.profile-view {
  position: absolute;
  inset: 0;
  background-color: #000;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: calc(32px + var(--safe-top)) 24px calc(80px + var(--safe-bottom));
}

.profile-view[hidden] {
  display: none;
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
  text-align: center;
}

.profile-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  object-fit: cover;
  background-color: #1c1c1e;
  margin-bottom: 16px;
}

.profile-header h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.profile-header p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.profile-card {
  width: 100%;
  max-width: 320px;
  background-color: #161618;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.profile-card-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
  margin-bottom: 20px;
}

.btn-login {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background-color: #fff;
  color: #1c1c1e;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.btn-login i {
  font-size: 18px;
}

.btn-login:active {
  opacity: 0.85;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background-color: #2a2a2e;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.btn-logout i {
  font-size: 16px;
}

.btn-logout:active {
  opacity: 0.85;
}

.login-error {
  margin-top: 16px;
  font-size: 12px;
  color: #ff5a5f;
  line-height: 1.4;
}

/* Tela de Notificações */
.notifications-view {
  position: absolute;
  inset: 0;
  background-color: #000;
  z-index: 5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.page-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.notifications-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px calc(80px + var(--safe-bottom));
}

.notification-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.notification-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-content p {
  font-size: 14px;
  line-height: 1.4;
}

.notification-content strong {
  color: #fff;
}

.notification-time {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.notification-item.unread .notification-content p {
  color: #fff;
}

.notification-item.unread .notification-content strong {
  color: var(--accent);
}

.notifications-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

.notifications-empty i {
  font-size: 44px;
  color: rgba(255, 255, 255, 0.3);
}

/* Badge de notificações na barra de navegação */
.nav-badge {
  position: absolute;
  top: 2px;
  right: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background-color: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Tela de Criação/Postagem */
.create-view {
  position: absolute;
  inset: 0;
  background-color: #000;
  z-index: 5;
  display: flex;
  flex-direction: column;
}

.create-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(16px + var(--safe-top)) 16px 16px;
}

.create-back {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.create-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

.publish-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.publish-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.create-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.upload-box {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 55vh;
  background-color: #161618;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.upload-box:active {
  border-color: var(--accent);
}

.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

.upload-prompt i {
  font-size: 40px;
  color: rgba(255, 255, 255, 0.4);
}

.video-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
}

.post-input {
  width: 100%;
  background-color: #161618;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  padding: 14px 16px;
  outline: none;
}

.post-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.post-input:focus {
  border-color: var(--accent);
}

.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-progress p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: #2a2a2e;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00f2fe, var(--accent));
  border-radius: 4px;
  transition: width 0.2s ease;
}

.progress-fill.indeterminate {
  width: 40%;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0% {
    margin-left: -40%;
  }
  100% {
    margin-left: 100%;
  }
}

/* Aviso de Acesso para Desktop */
.desktop-warning {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background-color: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 24px;
}

.desktop-warning[hidden] {
  display: none;
}

.warning-card {
  max-width: 380px;
  text-align: center;
  color: #fff;
}

.warning-card i {
  font-size: 64px;
  color: var(--accent);
  margin-bottom: 20px;
}

.warning-card h1 {
  font-size: 24px;
  margin-bottom: 12px;
}

.warning-card p {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
  margin-bottom: 8px;
}

.warning-card .warning-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

/* Ajustes para telas pequenas (iPhone SE, etc.) */
@media (max-width: 360px) {
  .top-header {
    font-size: 14px;
    gap: 16px;
  }

  .video-info .username {
    font-size: 14px;
  }

  .video-info .description {
    font-size: 13px;
  }

  .video-info .music {
    font-size: 12px;
  }

  .action-item i {
    font-size: 24px;
  }

  .profile-avatar {
    width: 44px;
    height: 44px;
  }

  .nav-item {
    font-size: 9px;
  }

  .nav-item i {
    font-size: 17px;
  }
}

/* Ajustes para telas em landscape (celular deitado) */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --nav-height: 48px;
  }

  .video-info {
    bottom: calc(70px + var(--safe-bottom));
  }

  .action-bar {
    bottom: calc(80px + var(--safe-bottom));
  }

  .action-bar {
    gap: 14px;
  }

  .profile-avatar {
    width: 40px;
    height: 40px;
  }

  .action-item i {
    font-size: 22px;
  }
}
