* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: #f5f7fb;
  color: #172033;
}

/* HEADER */

.topbar {
  height: 76px;
  background: #ffffff;
  border-bottom: 1px solid #e7eaf0;
  padding: 0 6%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #1e40af;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand span,
.user span {
  display: block;
  color: #8490a4;
  font-size: 12px;
  margin-top: 2px;
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e8edff;
  color: #1e40af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* CONTENT */

.container {
  width: min(1100px, 90%);
  margin: 38px auto 80px;
}

.hero {
  background:
    linear-gradient(
      135deg,
      #172554,
      #1e40af
    );
  color: white;
  border-radius: 20px;
  padding: 38px 42px;
  margin-bottom: 22px;
}

.hero h2 {
  margin: 5px 0 8px;
  font-size: 30px;
}

.hero p {
  max-width: 650px;
  margin-bottom: 0;
  color: #dbe5ff;
  line-height: 1.6;
}

.hero .eyebrow {
  color: #a9bfff;
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
}

/* STATS */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: white;
  border: 1px solid #e6eaf1;
  border-radius: 14px;
  padding: 20px;
}

.stat-card span {
  display: block;
  color: #7d889a;
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 22px;
}

.stat-card .online {
  color: #168653;
  font-size: 16px;
}

/* PANELS */

.panel {
  background: white;
  border: 1px solid #e6eaf1;
  border-radius: 16px;
  padding: 26px;
  margin-bottom: 22px;
}

.panel h3 {
  margin: 0 0 5px;
  font-size: 18px;
}

.panel p {
  margin: 0;
  color: #8490a4;
  font-size: 13px;
}

/* UPLOAD */

.upload-form {
  margin-top: 22px;
}

.file-area {
  border: 2px dashed #ccd4e3;
  border-radius: 14px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  display: block;
  transition: 0.2s;
}

.file-area:hover {
  border-color: #3158c9;
  background: #f8faff;
}

.file-area input {
  display: none;
}

.upload-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: #edf1ff;
  color: #1e40af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
}

.file-area strong {
  display: block;
  margin-bottom: 5px;
}

.file-area span {
  color: #8a95a7;
  font-size: 12px;
}

.selected-file {
  font-size: 13px;
  color: #5e6878;
  margin: 13px 0;
}

.primary-button {
  border: 0;
  background: #1e40af;
  color: white;
  border-radius: 9px;
  padding: 11px 18px;
  font-weight: 600;
  cursor: pointer;
}

.primary-button:hover {
  background: #193792;
}

.upload-status {
  margin-top: 15px !important;
}

/* LIBRARY */

.library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.library-actions {
  display: flex;
  gap: 8px;
}

.library-actions input {
  width: 220px;
  padding: 10px 12px;
  border: 1px solid #d9deea;
  border-radius: 9px;
  outline: none;
}

.library-actions input:focus {
  border-color: #3158c9;
}

.backup-button {
  background: white;
  border: 1px solid #d9deea;
  padding: 9px 15px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
}

.table-header,
.video-row {
  display: grid;
  grid-template-columns:
    minmax(0, 3fr)
    1fr
    1.3fr
    100px;
  gap: 15px;
  align-items: center;
}

.table-header, .video-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 3fr) 90px 120px 220px;
  gap: 15px;
  align-items: center;
}

.video-row {
  padding: 15px;
  border-bottom: 1px solid #edf0f5;
  font-size: 13px;
}

.video-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-button {
  color: #1e40af;
  text-decoration: none;
  font-weight: 600;
}

footer {
  text-align: center;
  padding: 25px;
  color: #9aa3b2;
  font-size: 12px;
}

/* MOBILE */

@media (max-width: 700px) {
  .user {
    display: none;
  }

  .container {
    width: 94%;
    margin-top: 20px;
  }

  .hero {
    padding: 28px 24px;
  }

  .hero h2 {
    font-size: 24px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .library-header {
    align-items: stretch;
    flex-direction: column;
    gap: 15px;
  }

  .library-actions input {
    width: 100%;
  }

  .table-header {
    display: none;
  }

  .video-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.delete-button {
  border: 0;
  background: transparent;
  color: #c43d3d;
  cursor: pointer;
  font-weight: 600;
  padding: 0;
}

.delete-button:hover {
  text-decoration: underline;
}

/* LOGIN */

.login-body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(
      135deg,
      #172554,
      #1e40af
    );
}

.login-card {
  width: 390px;
  max-width: 90%;
  background: white;
  padding: 38px;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: #1e40af;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-card > p {
  color: #8490a4;
  margin: 7px 0 28px;
}

.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 15px 0 7px;
}

.login-card input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #d9deea;
  border-radius: 9px;
  outline: none;
}

.login-card input:focus {
  border-color: #3158c9;
}

.login-button {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  border: 0;
  border-radius: 9px;
  background: #1e40af;
  color: white;
  font-weight: 600;
  cursor: pointer;
}

#loginStatus {
  margin-top: 15px;
  font-size: 13px;
}

.logout-button {
  margin-left: 10px;
  padding: 8px 13px;
  border: 1px solid #d9deea;
  border-radius: 8px;
  background: white;
  color: #526075;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.logout-button:hover {
  background: #f5f7fb;
  color: #1e40af;
}
.video-code {
  font-weight: 700;
  color: #1e40af;
  font-size: 13px;
}

.copy-button {
  border: 0;
  background: #edf1ff;
  color: #1e40af;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.copy-button:hover {
  background: #dfe7ff;
}

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.folder-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.folder-card {
  min-width: 0;
  border: 1px solid #e1e6ef;
  background: #f8f9fc;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.folder-card:hover {
  border-color: #3158c9;
  background: #f3f6ff;
}

.folder-icon {
  font-size: 22px;
}

.folder-name {
  font-size: 13px;
  font-weight: 600;
  color: #172033;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-folder {
  grid-column: 1 / -1;
  padding: 20px;
  border: 1px dashed #d9deea;
  border-radius: 10px;
  text-align: center;
  color: #8490a4;
  font-size: 13px;
}

@media (max-width: 700px) {
  .folder-header {
    align-items: stretch;
    flex-direction: column;
  }

  .folder-list {
    grid-template-columns: 1fr 1fr;
  }
}

.move-button {
  border: 0;
  background: #f3f4f6;
  color: #526075;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.move-button:hover {
  background: #e7eaf0;
  color: #1e40af;
}

.active-folder {
  border-color: #1e40af;
  background: #edf1ff;
}

.active-folder .folder-name {
  color: #1e40af;
}

.folder-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.folder-count {
  font-size: 11px;
  font-weight: 400;
  color: #8a95a7;
}

.folder-rename {
  margin-left: auto;
  padding: 5px 7px;
  border-radius: 6px;
  color: #8490a4;
  font-size: 14px;
}

.folder-rename:hover {
  background: #e8edff;
  color: #1e40af;
}

.folder-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 3px;
}

.folder-rename,
.folder-delete {
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
}

.folder-delete {
  color: #a45b5b;
  font-size: 18px;
}

.folder-delete:hover {
  background: #fff0f0;
  color: #c43d3d;
}

#backupModal.show {
  display: flex !important;
}

#backupModal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 99999 !important;
  background: rgba(15, 23, 42, 0.65) !important;

  align-items: center !important;
  justify-content: center !important;
}

#backupModal .backup-modal-card {
  display: block !important;
  position: relative !important;

  width: 90% !important;
  max-width: 560px !important;
  max-height: 85vh !important;

  overflow-y: auto !important;

  background: #ffffff !important;
  padding: 24px !important;
  border-radius: 16px !important;

  opacity: 1 !important;
  visibility: visible !important;

  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25) !important;
}

/* =========================================
   BACKUP MODAL - FINAL
========================================= */

.backup-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(15, 23, 42, 0.68);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#backupModal.show {
  display: flex;
}

#backupModal .backup-modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.backup-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.backup-modal-header h3 {
  margin: 0 0 6px;
  font-size: 20px;
  color: #172033;
}

.backup-modal-header p {
  margin: 0;
  font-size: 14px;
  color: #64748b;
}

.backup-modal-close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.backup-modal-close:hover {
  background: #e2e8f0;
}


/* MODE BACKUP */

.backup-options {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.backup-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  background: #ffffff;
}

.backup-option:hover {
  border-color: #b8c5e6;
  background: #f8faff;
}

.backup-option input[type="radio"] {
  margin-top: 3px;
  flex-shrink: 0;
}

.backup-option span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.backup-option strong {
  font-size: 14px;
  color: #172033;
}

.backup-option small {
  font-size: 12px;
  line-height: 1.5;
  color: #64748b;
}


/* EXTRA CONTENT */

.backup-extra {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.backup-extra h4 {
  margin: 0 0 12px;
  font-size: 14px;
  color: #172033;
}


/* VIDEO CHECKBOX */

.backup-video-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.backup-video-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  color: #334155;
}

.backup-video-list label:hover {
  background: #f1f5f9;
}

.backup-video-list input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}


/* DATE */

.backup-date-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.backup-date-fields label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.backup-date-fields input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  color: #172033;
}


/* ACTION BUTTONS */

.backup-modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.backup-cancel-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #334155;
  font-weight: 600;
  cursor: pointer;
}

.backup-cancel-button:hover {
  background: #f8fafc;
}

#downloadBackupButton {
  min-height: 42px;
  padding-left: 20px;
  padding-right: 20px;
}


/* MOBILE */

@media (max-width: 600px) {
  #backupModal .backup-modal-card {
    padding: 20px;
    border-radius: 16px;
  }

  .backup-date-fields {
    grid-template-columns: 1fr;
  }

  .backup-modal-actions {
    flex-direction: column-reverse;
  }

  .backup-modal-actions button {
    width: 100%;
  }
}