/* DEVICES CSS */

/* --- PAGE LAYOUT (Match Finance/Dashboard) --- */
main {
  display: grid;
  grid-template-columns: 20.8rem 1fr;
  min-height: 100vh;
}

.main-content {
  padding: 3.2rem;
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
}

/* --- HEADER SECTION --- */
.devices-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.6rem 2.4rem;
  background: rgba(18, 18, 24, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-title {
  font-family: "Orbitron", sans-serif;
  font-size: 2.4rem;
  color: #fff;
  letter-spacing: 1px;
}

.btn-new-device {
  background: linear-gradient(135deg, #ffd900 0%, #ff8c00 100%);
  border: none;
  border-radius: 8px;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  text-decoration: none;
}

.btn-new-device:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.4);
}

.btn-new-device ion-icon {
  font-size: 2rem;
  color: #000;
}

.btn-new-device span {
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: #000;
  text-transform: uppercase;
}

/* --- DEVICE LIST --- */
.device-list {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

/* COMMON PANEL STYLES */
.device-panel {
  display: grid;
  grid-template-columns: 20% 60% 20%;
  background: rgba(35, 35, 45, 0.6);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
  min-height: 14rem;
  align-items: center;
}

.device-panel:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.05);
}

/* Left Section: Visual */
.panel-left {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.6rem;
}

.nft-thumb-box {
  width: 10rem;
  height: 10rem;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}

.nft-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Glow effects based on class */
.glow-purple {
  box-shadow: 0 0 20px rgba(166, 77, 255, 0.4);
}
.glow-blue {
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
}
.glow-green {
  box-shadow: 0 0 20px rgba(64, 192, 87, 0.4);
}

/* Empty State Icon */
.empty-placeholder {
  width: 8rem;
  height: 8rem;
  border: 2px dashed #444;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
  gap: 0.4rem;
  animation: pulse-gray 3s infinite;
}

.empty-placeholder ion-icon {
  font-size: 3.2rem;
}

.empty-text {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

@keyframes pulse-gray {
  0% {
    border-color: #444;
    box-shadow: 0 0 0 rgba(100, 100, 100, 0);
  }
  50% {
    border-color: #666;
    box-shadow: 0 0 10px rgba(100, 100, 100, 0.2);
  }
  100% {
    border-color: #444;
    box-shadow: 0 0 0 rgba(100, 100, 100, 0);
  }
}

/* Middle Section: Details */
.panel-center {
  padding: 2.4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.2rem;
  height: 100%;
}

.device-title {
  font-family: "Orbitron", sans-serif;
  font-size: 1.8rem;
  color: #fff;
  font-weight: 500;
}

.device-meta {
  display: flex;
  gap: 2.4rem;
  color: #bbb;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.4rem;
  align-items: center;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.meta-item ion-icon {
  color: #4dabf7;
  font-size: 1.6rem;
}

.device-desc {
  font-family: "Roboto", sans-serif;
  font-size: 1.3rem;
  color: #888;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 90%;
}

/* Right Section: Actions */
.panel-right {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.2rem;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.6rem;
}

.action-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ddd;
  padding: 0.8rem 1.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: "Rajdhani", sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 16rem;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
  font-size: 1.3rem;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.action-btn.btn-remove:hover {
  background: rgba(250, 82, 82, 0.15);
  color: #fa5252;
  border-color: #fa5252;
}

/* Empty State Actions */
.action-btn.btn-select {
  border-color: #40c057;
  color: #40c057;
}

.action-btn.btn-select:hover {
  background: #40c057;
  color: #000;
}

.action-btn.btn-buy {
  border-color: #ffd900;
  color: #ffd900;
}

.action-btn.btn-buy:hover {
  background: #ffd900;
  color: #000;
}

/* --- FOOTER / SHOW MORE --- */
.show-more-container {
  margin-top: 1rem;
}

.btn-show-more {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.6rem;
  text-align: center;
  color: #888;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.btn-show-more:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
}

/* --- MODAL --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: #121218;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: 80rem;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  /* Top accent */
  border-top: 2px solid #00f2ff;
}

.modal-header {
  padding: 2.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: "Orbitron", sans-serif;
  font-size: 2rem;
  color: #fff;
}

.btn-close {
  background: none;
  border: none;
  color: #666;
  font-size: 2.4rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close:hover {
  color: #fff;
}

.modal-body {
  padding: 2.4rem;
  overflow-y: auto;
}

/* NFT Grid */
.nft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1.6rem;
}

.nft-card-select {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  border: 1px solid transparent;
}

.nft-card-select:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
}

.nft-card-img {
  width: 100%;
  height: 14rem;
  object-fit: cover;
}

.nft-card-info {
  padding: 1.2rem;
}

.nft-card-name {
  font-size: 1.3rem;
  color: #ddd;
  margin-bottom: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tags */
.status-tag {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.tag-free {
  background: rgba(64, 192, 87, 0.9);
  color: #fff;
}

.tag-used {
  background: rgba(255, 140, 0, 0.9);
  color: #fff;
}

/* --- MEDIA QUERIES --- */
@media (max-width: 84em) {
  #page-devices {
    zoom: 90%;
  }
}

@media (max-width: 75em) {
  #page-devices {
    zoom: 80%;
  }
}

@media (max-width: 59em) {
  #page-devices {
    zoom: 70%;
  }
}

@media (max-width: 44em) {
  #page-devices {
    zoom: 1; /* Reset for explicit font sizing */
  }

  .device-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 0;
    padding: 1.6rem;
  }

  .panel-left,
  .panel-center,
  .panel-right {
    border: none;
    padding: 1.6rem 0;
  }

  .panel-left {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .panel-center {
    align-items: center;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .device-meta {
    flex-wrap: wrap;
    justify-content: center;
  }

  .panel-right {
    flex-direction: row;
    justify-content: center;
    gap: 1.6rem;
    border-bottom: none;
  }

  .action-btn {
    width: auto;
    flex: 1;
  }

  /* Font reductions (1 step down) */
  .header-title {
    font-size: 2rem;
  }
  .btn-new-device span {
    font-size: 1.4rem;
  }
  .device-title {
    font-size: 1.6rem;
  }
  .device-meta,
  .meta-item ion-icon {
    font-size: 1.2rem;
  }
  .device-desc {
    font-size: 1.2rem;
  }
  .action-btn {
    font-size: 1.2rem;
    padding: 0.8rem 1.2rem;
  }
  .btn-show-more {
    font-size: 1.2rem;
  }
  .empty-text {
    font-size: 1rem;
  }
}

@media (max-width: 34em) {
  .panel-right {
    gap: 0.8rem;
  }

  /* Font reductions (2 steps down) */
  .header-title {
    font-size: 1.8rem;
  }
  .btn-new-device span {
    font-size: 1.2rem;
  }
  .device-title {
    font-size: 1.4rem;
  }
  .device-meta,
  .meta-item ion-icon {
    font-size: 1rem;
  }
  .device-desc {
    font-size: 1rem;
  }
  .action-btn {
    font-size: 1rem;
    padding: 0.6rem 0.8rem;
  }
  .btn-show-more {
    font-size: 1rem;
  }
}

/* =========================================================
   DEVICES - INTERACTIONS (JS/devices.js)
   ========================================================= */

/* Panel that just changed (assigned / swapped / emptied) */
.device-panel.is-updated {
  animation: panelUpdated 1.6s ease-out;
}
@keyframes panelUpdated {
  0% {
    border-color: rgba(0, 242, 255, 0.8);
    box-shadow: 0 0 25px rgba(0, 242, 255, 0.35);
  }
  100% {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  }
}
.device-panel.is-updated .nft-thumb {
  animation: thumbIn 0.6s ease-out;
}
@keyframes thumbIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Picker cards: used vs free */
.nft-card-select.is-used {
  cursor: not-allowed;
}
.nft-card-select.is-used .nft-card-img {
  opacity: 0.5;
}
.nft-card-select.is-used:hover {
  transform: none;
  border-color: transparent;
}
.nft-card-select.is-current {
  border-color: rgba(255, 140, 0, 0.6);
}
.nft-card-select.is-free:focus-visible {
  outline: 2px solid #40c057;
  outline-offset: 2px;
}
.nft-card-where {
  font-family: "Rajdhani", sans-serif;
  font-size: 1.1rem;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nft-card-select.is-free .nft-card-where {
  color: #40c057;
}
.nft-card-select.tag-changed .status-tag {
  animation: tagSwap 0.7s ease-out;
}
@keyframes tagSwap {
  0% {
    transform: scale(1.5);
  }
  60% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}
.nft-card-select.shake {
  animation: cardShake 0.4s ease-in-out;
}
@keyframes cardShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* Remove confirmation popup */
.device-confirm {
  z-index: 1001;
}
.confirm-content {
  width: 44rem;
  border-top-color: #fa5252;
}
.confirm-text {
  font-family: "Rajdhani", sans-serif;
  font-size: 1.6rem;
  line-height: 1.5;
  color: #ccc;
  margin-bottom: 2.4rem;
}
.confirm-actions {
  display: flex;
  gap: 1.2rem;
  justify-content: flex-end;
}
.confirm-actions .action-btn {
  width: auto;
  min-width: 12rem;
  padding: 1rem 1.6rem;
}
.action-btn.btn-remove-solid {
  background: rgba(250, 82, 82, 0.15);
  border-color: #fa5252;
  color: #fa5252;
}
.action-btn.btn-remove-solid:hover {
  background: #fa5252;
  color: #fff;
}

/* Toast */
.device-toast {
  position: fixed;
  left: 50%;
  bottom: 3.2rem;
  transform: translate(-50%, 2rem);
  padding: 1.2rem 2rem;
  background: rgba(18, 18, 24, 0.95);
  border: 1px solid rgba(0, 242, 255, 0.4);
  border-radius: 10px;
  color: #ddd;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.5rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s,
    transform 0.3s;
  z-index: 1100;
  max-width: 90vw;
  text-align: center;
}
.device-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 34em) {
  .confirm-actions {
    flex-direction: column-reverse;
  }
  .confirm-actions .action-btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .device-panel.is-updated,
  .device-panel.is-updated .nft-thumb,
  .nft-card-select.tag-changed .status-tag,
  .nft-card-select.shake {
    animation: none;
  }
}

/* =========================================================
   RESET DEMO DATA DIALOG (JS/reset.js, open with #reset)
   ========================================================= */
.reset-dialog .confirm-text {
  margin-bottom: 1.2rem;
}
.reset-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 2rem;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.5rem;
  color: #bbb;
}
.reset-list li {
  position: relative;
  padding-left: 1.8rem;
}
.reset-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65rem;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #fa5252;
}
.reset-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2.4rem;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.5rem;
  color: #888;
  cursor: pointer;
}
.reset-option input {
  width: 1.8rem;
  height: 1.8rem;
  accent-color: #fa5252;
  cursor: pointer;
}

/* =========================================================
   EDIT DEVICE + MATCHING-ONLY PICKER (JS/devices.js)
   ========================================================= */
.panel-center {
  position: relative;
}
.device-edit-btn {
  position: absolute;
  top: 1.6rem;
  right: 1.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 1rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #999;
  cursor: pointer;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.device-edit-btn ion-icon {
  font-size: 1.4rem;
}
.device-edit-btn:hover {
  color: #fff;
  border-color: #4dabf7;
  background: rgba(77, 171, 247, 0.15);
}
.panel-center .device-title {
  padding-right: 8rem;
}

.edit-content {
  width: 72rem;
  border-top-color: #4dabf7;
}
.edit-layout {
  display: grid;
  grid-template-columns: 22rem minmax(0, 1fr);
  gap: 2.4rem;
}
.edit-artwork {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.6rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: "Rajdhani", sans-serif;
  align-self: start;
}
.edit-artwork-label {
  font-size: 1.1rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.edit-artwork-img {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  margin: 0.4rem 0;
}
.edit-artwork-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.edit-artwork-empty {
  aspect-ratio: 1 / 1;
  margin: 0.4rem 0;
  border: 2px dashed #444;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 1.2rem;
}
.edit-artwork-empty ion-icon {
  font-size: 3.6rem;
}
.edit-artwork-name {
  font-family: "Orbitron", sans-serif;
  font-size: 1.5rem;
  color: #fff;
}
.edit-artwork-meta {
  font-size: 1.3rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.edit-artwork-desc {
  font-family: "Roboto", sans-serif;
  font-size: 1.2rem;
  line-height: 1.5;
  color: #888;
}
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}
.edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.edit-field label {
  font-family: "Rajdhani", sans-serif;
  font-size: 1.3rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.edit-static {
  font-family: "Rajdhani", sans-serif;
  font-size: 1.6rem;
  color: #ddd;
}
.edit-field input,
.edit-field textarea {
  width: 100%;
  padding: 1.2rem 1.4rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: "Roboto", sans-serif;
  font-size: 1.5rem;
  outline: none;
  resize: vertical;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.edit-field input:focus,
.edit-field textarea:focus {
  border-color: #4dabf7;
  box-shadow: 0 0 10px rgba(77, 171, 247, 0.3);
}
.edit-form .confirm-actions {
  margin-top: 0.8rem;
}
.action-btn.btn-save {
  background: rgba(64, 192, 87, 0.12);
}

/* Picker without matching NFTs */
.nft-grid-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding: 4rem 1.6rem;
  text-align: center;
  color: #888;
  font-family: "Rajdhani", sans-serif;
  font-size: 1.6rem;
}
.nft-grid-empty ion-icon {
  font-size: 4.8rem;
  color: #555;
}

@media (max-width: 44em) {
  .edit-layout {
    grid-template-columns: 1fr;
  }
  .edit-artwork {
    display: grid;
    grid-template-columns: 9rem 1fr;
    column-gap: 1.2rem;
    align-items: center;
  }
  .edit-artwork-label,
  .edit-artwork-desc {
    grid-column: 1 / -1;
  }
  .edit-artwork-img,
  .edit-artwork-empty {
    grid-row: span 2;
  }
  .device-edit-btn {
    position: static;
    align-self: center;
  }
  .panel-center .device-title {
    padding-right: 0;
  }
}
