/* ============================================================
   APP.CSS — Styling Panel UI Aplikasi LKPD
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
  overflow: hidden;
}

/* ── LAYOUT UTAMA ── */
.app-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── HEADER ── */
.app-header {
  background: #1a1a2e;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  min-height: 52px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-toggle-panel {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  display: block;
}

.panel-hidden {
  display: none !important;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
}

.app-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.app-subtitle {
  font-size: 11px;
  color: #aaa;
  margin-top: 1px;
}

/* ── BODY ── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── PANEL KIRI ── */
.panel-input {
  width: 42%;
  height: calc(100vh - 52px);
  min-width: 300px;
  max-width: 480px;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

/* ── PANEL KANAN ── */
.panel-preview {
  flex: 1;
  height: calc(100vh - 52px);
  background: #dde1e7;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

/* ── BLOK ── */
.blok {
  background: #fff;
  border: 1px solid #e4e4e4;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.blok-header {
  background: #f1f3f5;
  padding: 8px 14px;
  font-size: 10px;
  font-weight: 700;
  color: #666;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid #e4e4e4;
}

.blok-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── FORM ELEMENTS ── */
label {
  font-size: 11px;
  font-weight: 600;
  color: #444;
  display: block;
  margin-bottom: 3px;
}

textarea,
select,
input[type="number"] {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  color: #333;
  background: #fff;
  transition: border-color 0.2s;
  display: block;
}

textarea:focus,
select:focus,
input[type="number"]:focus {
  outline: none;
  border-color: #e07b39;
  box-shadow: 0 0 0 2px rgba(224,123,57,0.12);
}

textarea.json-input {
  font-family: 'Courier New', monospace;
  font-size: 10.5px;
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* ── TOMBOL ── */
.btn {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-align: center;
  font-family: inherit;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: #e07b39;
  color: #fff;
}

.btn-primary:hover { background: #c96a2a; }

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover { background: #e0e0e0; }

.preview-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

/* ── MODAL UPLOAD GAMBAR ── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { color: #333; }

.modal-body {
  padding: 20px;
}

.upload-area {
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.3s;
}

.upload-area:hover {
  border-color: #2c5aa0;
}

.upload-placeholder .upload-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.upload-placeholder p {
  margin: 10px 0 5px 0;
  font-weight: 600;
  color: #333;
}

.upload-placeholder small {
  color: #666;
}

.preview-area {
  text-align: center;
}

.preview-image-container {
  margin-bottom: 20px;
  max-height: 300px;
  overflow: hidden;
  border-radius: 8px;
}

.preview-image-container img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.preview-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── DUAL PLACEHOLDER GAMBAR (SIDE-BY-SIDE) ── */
.placeholder-gambar-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.placeholder-gambar-container .placeholder-gambar {
  margin-bottom: 0;
  height: 140px;
}

.placeholder-gambar-container .gambar-upload {
  height: 140px;
  max-height: 140px;
}

/* ── EDIT MODE ── */
.edit-mode .placeholder-gambar {
  cursor: pointer;
  border-color: #2c5aa0;
  background: #f0f7ff;
  position: relative;
}

.edit-mode .placeholder-gambar:hover {
  box-shadow: 0 0 0 2px #2c5aa0;
}

.edit-mode .placeholder-gambar::after {
  content: "📷 Klik untuk upload gambar";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(44, 90, 160, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.edit-mode .placeholder-gambar:hover::after {
  opacity: 1;
}

.gambar-upload {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  border-radius: 4px;
  aspect-ratio: 16/9;
}

/* ── BUTTON STYLING (Standarisasi) ── */
.btn {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 0.8rem;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-dashboard {
  background: #e07b39;
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-dashboard:hover {
  background: #d06a30;
  box-shadow: 0 4px 16px rgba(224,123,57,0.5);
  transform: translateY(-1px);
}

.btn-dashboard:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(224,123,57,0.3);
}

.btn-print {
  background: #4CAF50;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-print:hover { 
    background: #45a049; 
    transform: translateY(-1px);
}

.btn-edit-image {
  background: #2196F3;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-edit-image:hover {
  background: #1976D2;
  transform: translateY(-1px);
}

.btn-fullscreen {
  background: #e07b39;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-fullscreen:hover {
  background: #d06a30;
  transform: translateY(-1px);
}

/* ── Fitur Simpan ke Cloud ── */
.btn-simpan-cloud {
    background: #e07b39;
    color: #fff;
    border: 1px solid #d46b30;
    border-radius: 6px;
    padding: 8px 16px;  /* ✅ Konsisten dengan tombol lain */
    cursor: pointer;
    font-size: 0.8rem;  /* ✅ Konsisten dengan tombol lain */
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-simpan-cloud:hover {
    background: #d46b30;
    border-color: #c55f2a;
    transform: translateY(-1px);
}

.btn-simpan-cloud:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.dokumen-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
    transition: border-color 0.2s;
}

.dokumen-item:hover { 
    border-color: #e07b39; 
}

.dokumen-nama {
    font-size: 13px;
    font-weight: 500;
    color: #1a1a2e;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dokumen-meta {
    font-size: 11px;
    color: #77767b;
    margin-bottom: 8px;
}

.dokumen-actions { 
    display: flex; 
    gap: 6px; 
}

.btn-buka-dokumen {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid #e07b39;
    background: transparent;
    color: #e07b39;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-buka-dokumen:hover {
    background: #e07b39;
    color: #fff;
}

.btn-hapus-dokumen {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #dc2626;
    background: transparent;
    color: #dc2626;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-hapus-dokumen:hover { 
    background: #dc2626; 
    color: #fff; 
}

.dokumen-kosong {
    font-size: 12px;
    color: #77767b;
    text-align: center;
    padding: 16px 0;
    font-style: italic;
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
    .btn-toggle-panel {
        display: block;
    }

    .header-left {
        gap: 6px;
        flex-shrink: 1;
        min-width: 0;
    }

    .app-title {
        font-size: 14px;
    }
}

/* ── PROMPT MODE SECTION ── */
.prompt-mode-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}

.prompt-mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: stretch;
}

.prompt-mode-buttons .btn-copy,
.prompt-mode-buttons .btn-copy-oneshot {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    margin-top: 0;
    font-size: 0.8rem;
    padding: 10px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.prompt-mode-buttons .btn-copy {
    background-color: #2563eb;
    color: white;
}

.prompt-mode-buttons .btn-copy-oneshot {
    background-color: #16a34a;
    color: white;
}

.prompt-mode-buttons .btn-copy:hover {
    background-color: #1d4ed8;
}

.prompt-mode-buttons .btn-copy-oneshot:hover {
    background-color: #15803d;
}

.prompt-mode-buttons .btn-copy.copy-sukses,
.prompt-mode-buttons .btn-copy-oneshot.copy-sukses {
    background-color: #6b7280 !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

@media (max-width: 560px) {
    .prompt-mode-buttons {
        grid-template-columns: 1fr;
    }
}

.prompt-mode-info {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-mode-info-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1e293b;
    margin: 0;
}

.prompt-mode-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
}

.prompt-card-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.prompt-card-desc {
    font-size: 0.85rem;
    color: #475569;
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.prompt-card-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prompt-card-list li {
    font-size: 0.83rem;
    color: #334155;
}

.prompt-card-list li.plus {
    color: #16a34a;
}

.prompt-card-list li.minus {
    color: #dc2626;
}

@media (max-width: 768px) {
    .app-subtitle {
        display: none;
    }

    .header-actions {
        flex-wrap: nowrap;
        gap: 6px;
        align-items: center;
    }

    .btn-dashboard, .btn-print, .btn-simpan-cloud, .btn-edit-image {
        font-size: 0.75rem;
        padding: 6px 10px;
        flex-shrink: 1;
        min-width: 0;
    }

    /* Progressive disclosure: hide text span on tablet, keep icon */
    .btn-dashboard .btn-text,
    .btn-print .btn-text,
    .btn-simpan-cloud .btn-text,
    .btn-edit-image .btn-text {
        display: none;
    }
}

@media (max-width: 480px) {
    .header-left {
        gap: 6px;
        width: 100%;
    }

    .header-actions {
        flex-wrap: wrap;
        gap: 6px;
        align-items: stretch;
    }

    .btn-dashboard, .btn-print, .btn-simpan-cloud, .btn-edit-image {
        font-size: 0.72rem;
        padding: 6px 8px;
        width: 100%;
    }

    /* Progressive disclosure: ensure icon stays visible, text hidden */
    .btn-dashboard .btn-text,
    .btn-print .btn-text,
    .btn-simpan-cloud .btn-text,
    .btn-edit-image .btn-text {
        display: none;
    }
}

/* ── RINGKASAN DATA ── */
.ringkasan-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 11px;
  color: #166534;
  line-height: 1.7;
}

.ringkasan-box.error {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}

/* ── DETAIL LKPD ── */
.lkpd-detail-box {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  color: #444;
  line-height: 1.7;
}

.lkpd-detail-box .lkpd-judul-kecil {
  font-weight: 700;
  font-size: 12px;
  color: #222;
  margin-bottom: 4px;
}

/* ── PROMPT AREA ── */
.prompt-area {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  min-height: 140px;
  background: #1a1a2e;
  color: #e8f5e9;
  border: none;
  border-radius: 6px;
  padding: 10px;
  resize: vertical;
  width: 100%;
  line-height: 1.5;
  display: block;
}

/* ── KONFIGURASI GRID ── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── PREVIEW PLACEHOLDER ── */
.preview-placeholder {
  color: #aaa;
  text-align: center;
  margin-top: 60px;
  font-size: 13px;
  line-height: 1.8;
}

.preview-placeholder .icon {
  font-size: 44px;
  display: block;
  margin-bottom: 10px;
}
