/* =============================================== */
/* == 1. CẤU HÌNH CHUNG & RESET                 == */
/* =============================================== */
:root {
  --nal-primary: #ff69b4;
  --nal-bg-gray: #f3f4f6;
  --nal-border: #e5e7eb;
  --nal-text: #1f2937;
}

@font-face {
  font-family: "Luckiest Guy";
  src: url("../fonts/LuckiestGuy-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Fredoka One";
  src: url("../fonts/FredokaOne-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Bangers";
  src: url("../fonts/Bangers-Regular.ttf") format("truetype");
}

.nal-app-wrapper,
.nal-app-wrapper * {
  box-sizing: border-box;
}

.nal-app-wrapper {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #fff;
  border: 1px solid var(--nal-border);
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
  margin: 20px auto;
  width: 100%;
  max-width: 1600px;
  height: 85vh;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =============================================== */
/* == 2. HEADER                                 == */
/* =============================================== */
.nal-header {
  padding: 15px 25px;
  border-bottom: 1px solid var(--nal-border);
  background: #fff;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nal-header h2 {
  font-size: 18px;
  margin: 0;
  color: var(--nal-text);
  font-weight: 700;
}
.nal-header p {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

/* =============================================== */
/* == 3. MAIN LAYOUT (2 CỘT)                    == */
/* =============================================== */
.nal-main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --- CỘT TRÁI (CONTROLS) --- */
.nal-controls-panel {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--nal-border);
  padding: 20px;
  overflow-y: auto;
  z-index: 10;
}

/* --- CỘT PHẢI (PREVIEW) --- */
.nal-preview-area {
  flex: 1;
  background: var(--nal-bg-gray);
  display: flex;
  flex-direction: column;
  position: relative;
  min-width: 0;
}

/* =============================================== */
/* == 4. CANVAS PREVIEW AREA                    == */
/* =============================================== */
.nal-canvas-wrapper-outer {
  flex: 1;
  background: var(--nal-bg-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  overflow: hidden;
  width: 100%;
  height: 100%;
  position: relative;
}

.nal-canvas-container {
  height: 95%;
  aspect-ratio: 210/297;
  width: auto;
  background: #ffffff;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
}

.nal-canvas-container .canvas-container {
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
}
.nal-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  display: block !important;
}

/* =============================================== */
/* == 6. CÁC STYLE NHỎ LẺ                       == */
/* =============================================== */
.nal-control-group {
  margin-bottom: 18px;
}
.nal-control-group label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 6px;
  display: block;
  letter-spacing: 0.5px;
}
.nal-textarea,
.nal-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--nal-border);
  border-radius: 8px;
  font-size: 14px;
  background: #f9fafb;
  color: #333;
  transition: border-color 0.2s, background 0.2s;
}
.nal-textarea:focus,
.nal-select:focus {
  outline: none;
  border-color: var(--nal-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 105, 180, 0.1);
}
.nal-select {
  height: 42px;
  cursor: pointer;
}

/* --- SLIDER --- */
.nal-slider {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  -webkit-appearance: none;
  margin-top: 5px;
}
.nal-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--nal-primary);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}
.nal-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

/* --- PAPER SIZE --- */
.nal-paper-size-grid {
  display: flex;
  gap: 10px;
}
.nal-pager-btn {
  flex: 1;
  padding: 12px 10px;
  border: 1px solid var(--nal-border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.nal-pager-btn span {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}
.nal-pager-btn:hover {
  border-color: var(--nal-primary);
  transform: translateY(-1px);
}
.nal-pager-btn.active {
  border-color: var(--nal-primary);
  background: #fff0f6;
}
.nal-pager-btn.active span {
  color: var(--nal-primary);
}
.nal-icon-portrait {
  width: 16px;
  height: 22px;
  border: 2px solid #9ca3af;
  display: block;
  border-radius: 2px;
}
.nal-icon-landscape {
  width: 22px;
  height: 16px;
  border: 2px solid #9ca3af;
  display: block;
  border-radius: 2px;
}
.nal-pager-btn.active .nal-icon-portrait,
.nal-pager-btn.active .nal-icon-landscape {
  border-color: var(--nal-primary);
}

/* --- UPLOAD BOX --- */
.nal-upload-box {
  border: 2px dashed var(--nal-border);
  border-radius: 8px;
  height: 60px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  transition: 0.2s;
  background: #f9fafb;
}
.nal-upload-box:hover {
  border-color: var(--nal-primary);
  background: #fff0f6;
  color: var(--nal-primary);
}
.nal-upload-label .dashicons {
  font-size: 24px;
  width: 24px;
  height: 24px;
}
.nal-file-input {
  display: none;
}

/* --- BOTTOM TOOLBAR --- */
.nal-bottom-toolbar {
  background: #fff;
  padding: 15px 25px;
  border-top: 1px solid var(--nal-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  z-index: 20;
}
.nal-social-share {
  display: flex;
  gap: 10px;
}
.nal-share-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-decoration: none;
  transition: transform 0.2s, opacity 0.2s;
  border: none;
  outline: none;
}
.nal-share-btn:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}
.nal-share-btn .dashicons {
  font-size: 20px;
  width: 20px;
  height: 20px;
  line-height: 20px;
  display: block;
}
.nal-share-btn.fb {
  background: #1877f2;
}
.nal-share-btn.tw {
  background: #000000;
}
.nal-share-btn.pt {
  background: #e60023;
  padding-top: 0px !important;
}
.nal-share-btn.link {
  background: #6b7280;
}

.nal-action-buttons {
  display: flex;
  gap: 12px;
}
.nal-action-btn {
  height: 40px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.nal-btn-online {
  background: #fff;
  border: 1px solid var(--nal-primary);
  color: var(--nal-primary);
  padding: 0 20px;
  text-transform: uppercase;
}
.nal-btn-online:hover {
  background: #fff0f6;
  transform: translateY(-1px);
}
.nal-btn-download,
.nal-btn-delete {
  background: var(--nal-primary);
  color: #fff;
  padding: 0;
  width: 40px;
  box-shadow: 0 4px 10px rgba(255, 105, 180, 0.3);
}
.nal-btn-delete {
  background: #ef4444;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}
.nal-btn-download:hover {
  background: #d63384;
  transform: translateY(-2px);
}
.nal-btn-delete:hover {
  background: #dc2626;
  transform: translateY(-2px);
}
.nal-btn-download .dashicons,
.nal-btn-delete .dashicons {
  font-size: 22px;
  width: 22px;
  height: 22px;
  line-height: 22px;
}

/* =============================================== */
/* == 7. RESPONSIVE MOBILE                      == */
/* =============================================== */
@media (max-width: 900px) {
  .nal-app-wrapper {
    height: auto;
    border-radius: 0;
    border: none;
    margin: 0;
  }
  .nal-main-container {
    flex-direction: column-reverse;
  }
  .nal-controls-panel {
    width: 100%;
    height: auto;
    border-right: none;
    border-top: 1px solid var(--nal-border);
    max-height: none;
  }
  .nal-preview-area {
    height: auto;
    padding: 0;
  }
  .nal-canvas-wrapper-outer {
    padding: 20px;
    height: 50vh;
    min-height: 300px;
  }
  .nal-canvas-container {
    width: 90%;
    height: auto;
    aspect-ratio: 210/297;
  }
  .nal-bottom-toolbar {
    flex-wrap: wrap;
    gap: 15px;
  }
  .nal-social-share,
  .nal-action-buttons {
    width: 100%;
    justify-content: center;
  }
}

/* =============================================== */
/* == 8. COMMON: SCROLL NGANG (BG & DECOR)      == */
/* =============================================== */

/* Container Scroll Ngang chung */
.nal-visual-selector,
.nal-decorations-grid {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 10px;
  padding: 2px 2px 10px 2px;
  margin-top: 5px;

  /* Scroll mượt */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Scrollbar đẹp */
.nal-visual-selector::-webkit-scrollbar,
.nal-decorations-grid::-webkit-scrollbar {
  height: 6px;
}
.nal-visual-selector::-webkit-scrollbar-track,
.nal-decorations-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}
.nal-visual-selector::-webkit-scrollbar-thumb,
.nal-decorations-grid::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}
.nal-visual-selector::-webkit-scrollbar-thumb:hover,
.nal-decorations-grid::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* Item chung */
.nal-visual-item,
.nal-decor-item {
  flex: 0 0 30%; /* Hiện 3 ảnh 1 hàng (30% * 3 = 90%) */
  width: 30%;
  aspect-ratio: 1;
  border: 2px solid var(--nal-border);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  user-select: none;
}

/* Decoration Item Specific (viền mỏng hơn chút nếu muốn, hoặc dùng chung) */
.nal-decor-item {
  border-width: 1px;
  padding: 6px;
}

.nal-visual-item img,
.nal-decor-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none; /* Tránh kéo ảnh */
}

/* Decoration thì nên dùng contain để không bị cắt hình */
.nal-decor-item img {
  object-fit: contain;
}

/* Hover & Active */
.nal-visual-item:hover,
.nal-decor-item:hover {
  border-color: #999;
  transform: translateY(-2px);
}
.nal-visual-item.active,
.nal-decor-item:active {
  border-color: var(--nal-primary);
  box-shadow: 0 0 0 2px rgba(255, 105, 180, 0.2);
}

.nal-visual-item .nal-no-bg-icon {
  font-size: 24px;
  color: #ccc;
  width: auto;
  height: auto;
}
