/* ============================================
   Admin Page Styles
   ============================================ */

body {
  overflow-y: auto;
  background: linear-gradient(135deg, var(--color-bg) 0%, #EDE7F6 100%);
  min-height: 100vh;
}

.admin-container {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-5);
}

/* Header */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.admin-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-black);
  color: var(--color-fun-purple);
}

.admin-header a {
  color: var(--color-text-light);
  text-decoration: none;
  font-size: var(--font-size-md);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-bg-card);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}

.admin-header a:hover {
  color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

/* Upload Section */
.upload-section {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
}

.upload-section h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.form-row {
  display: flex;
  gap: var(--space-4);
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-light);
  margin-bottom: var(--space-1);
}

.form-group input[type="text"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-family: var(--font-family);
  transition: border-color var(--transition-fast);
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--color-fun-purple);
}

.file-input-wrapper {
  position: relative;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  top: 0;
  left: 0;
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-light);
  font-size: var(--font-size-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  width: 100%;
  justify-content: center;
}

.file-input-label:hover {
  border-color: var(--color-fun-purple);
  color: var(--color-fun-purple);
  background: #F3EEFF;
}

.file-input-label.has-file {
  border-color: var(--color-success);
  color: var(--color-success);
  border-style: solid;
}

/* === Mask Editor === */
.mask-editor-section {
  display: none;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
}

.mask-editor-section.active {
  display: block;
}

.mask-editor-section h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

.mask-editor-section .hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
  margin-bottom: var(--space-4);
}

.mask-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.tool-btn {
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-family);
}

.tool-btn.active {
  border-color: var(--color-fun-purple);
  background: var(--color-fun-purple);
  color: white;
}

.tool-btn:hover:not(.active) {
  border-color: var(--color-fun-purple);
}

.brush-size-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.brush-size-control input[type="range"] {
  width: 120px;
  accent-color: var(--color-fun-purple);
}

.brush-preview {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brush-preview-dot {
  border-radius: 50%;
  background: #00FF00;
}

.mask-canvas-wrapper {
  position: relative;
  display: inline-block;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-width: 100%;
  cursor: crosshair;
  background: #f0f0f0;
  /* 체크무늬 배경 표시 */
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.mask-canvas-wrapper canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* 브러시 커서 미리보기 */
#brush-cursor {
  position: absolute;
  border: 2px solid #00FF00;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  display: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}

/* 단축키 표시 */
.tool-btn kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-family: var(--font-family);
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
  margin-left: 2px;
  opacity: 0.6;
}

.mask-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* Book List */
.book-list-section {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

.book-list-section h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.book-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.book-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  transition: all var(--transition-normal);
}

.book-list-item:hover {
  box-shadow: var(--shadow-sm);
}

.book-list-thumb {
  width: 80px;
  height: 100px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.book-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-list-info {
  flex: 1;
}

.book-list-info h3 {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-1);
}

.book-list-info .green-status {
  font-size: var(--font-size-sm);
  color: var(--color-success);
}

.book-list-actions {
  display: flex;
  gap: var(--space-2);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-family);
}

.btn-sm:hover {
  transform: translateY(-1px);
}

.btn-edit {
  background: var(--color-fun-blue);
  color: white;
}

.btn-delete {
  background: var(--color-danger);
  color: white;
}

.empty-list {
  text-align: center;
  padding: var(--space-6);
  color: var(--color-text-light);
  font-size: var(--font-size-md);
}

/* Responsive */
@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
  }

  .admin-header {
    flex-direction: column;
    gap: var(--space-3);
    text-align: center;
  }

  .mask-toolbar {
    justify-content: center;
  }

  .book-list-item {
    flex-direction: column;
    text-align: center;
  }
}
