/* ===== CSS VARIABLES ===== */
:root {
  --ink         : #1a1a1a;
  --ink-light   : #4a4a4a;
  --ink-faint   : #8a8a8a;
  --paper       : var(--color-bg-app);
  --paper-warm  : var(--color-bg-section);
  --ui-bg       : var(--color-bg-app);
  --ui-border   : var(--color-border-panel);
  --accent      : var(--color-accent);
  --accent-light: var(--color-accent-hover);
  --rule        : var(--color-border-panel);
  --rule-dark   : var(--color-border-input);
  --shadow      : 0 2px 20px rgba(0,0,0,0.08),
                  0 1px 4px rgba(0,0,0,0.04);
  --ui-font     : var(--font-ui);
  --header-height: 60px;
  --radius-sm   : var(--radius-md);
  --radius-md   : var(--radius-lg);
}

[data-theme="dark"] {
  --ink       : #deddda;
  --ink-light : #9a9996;
  --ink-faint : #77767b;
  --paper     : #1a1a1a;
  --paper-warm: #2d2d2d;
  --ui-bg     : #1a1a1a;
  --ui-border : #3d3d3d;
  --accent    : #e07b39;
  --rule      : #3d3d3d;
  --rule-dark : #4d4d4d;
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--ui-font);
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER APLIKASI ===== */
.app-header {
    background: rgba(18, 16, 14, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--paper);
    padding: 0 28px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--accent);
    box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 4px 32px rgba(0,0,0,0.3);
}

.app-title {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.app-title-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1;
}

.app-name {
    font-family: var(--ui-font);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.app-subtitle {
    font-family: var(--ui-font);
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

.selector-grid {
    display: contents;
}

.btn-toggle-panel {
  background: rgba(0,0,0,0.25);
  color: var(--color-text-app-header);
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  margin: 0;
  transition: background 0.2s ease;
  line-height: 1;
}

.btn-toggle-panel:hover {
  background: rgba(0,0,0,0.4);
}

/* ===== BUTTONS ===== */
.btn {
    font-family: var(--ui-font);
    font-size: 0.8rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.18s ease;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-print {
    background: var(--accent);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 2px 12px rgba(46,123,196,0.4);
}

.btn-print:hover {
    background: var(--accent-light);
    box-shadow: 0 4px 20px rgba(46,123,196,0.6);
    transform: translateY(-2px);
}

.btn-dashboard {
    background: var(--accent);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 2px 8px rgba(46,123,196,0.3);
    white-space: nowrap;
}

.btn-dashboard:hover {
    background: var(--accent-light);
    box-shadow: 0 4px 16px rgba(46,123,196,0.5);
    transform: translateY(-1px);
}

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

/* ===== MAIN LAYOUT ===== */
.app-body {
    flex: 1;
    display: grid;
    grid-template-columns: 30% 70%;
    gap: 0;
    overflow: hidden;
    height: calc(100vh - var(--header-height));
    transition: grid-template-columns 0.3s ease;
}

.app-body.expanded {
    grid-template-columns: 0 100%;
}

/* ===== PANEL KIRI ===== */
.panel-left {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--rule-dark);
    background: var(--ui-bg);
    overflow-y: auto;
    height: calc(100vh - 60px);
    transition: width 0.3s ease, padding 0.3s ease;
}

.panel-left.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
    border-right: none;
}

/* ===== PANEL KANAN ===== */
.panel-right {
    display: flex;
    flex-direction: column;
    background: #e8eaed;
    overflow-y: auto;
    height: calc(100vh - 60px);
}

/* Panel content untuk preview dengan styling khusus */
.panel-right .panel-content {
    background: #e8eaed;
    overflow-y: auto;
    padding: 20px;
}

/* ===== PANEL LABEL ===== */
.panel-label {
    padding: 12px 20px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-faint);
    border-bottom: 1px solid var(--rule);
    background: var(--paper-warm);
    font-family: 'JetBrains Mono', monospace;
    border-left: 3px solid var(--accent);
    position: relative;
}

/* ===== PANEL CONTENT ===== */
.panel-content {
    flex: 1;
    padding: 0;
    display: block;
}


.section-title {
    font-family: var(--ui-font);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
}

/* ===== FORM GROUPS ===== */
.form-group {
    margin-bottom: var(--form-group-gap);
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-family: var(--ui-font);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 3px;
    letter-spacing: 0.01em;
}

/* ===== INPUT STYLES ===== */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-sm);
    font-family: var(--ui-font);
    font-size: 0.78rem;
    color: var(--ink);
    background: var(--color-bg-panel);
    transition: all 0.18s ease;
    outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(46, 123, 196, 0.1);
}

input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
    color: var(--ink-faint);
    font-style: italic;
}

select {
    cursor: pointer;
}

textarea {
    resize: vertical;
    min-height: 90px;
    line-height: 1.4;
}

/* Textarea untuk paste JSON TP */
#paste-json-tp {
    min-height: 200px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
}

/* ===== INPUT WITH BUTTON ===== */
.input-with-button {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-with-button input[type="text"] {
    flex: 1;
}

/* ===== BUTTON VARIANTS ===== */
.btn-add {
    background: var(--ink-light);
    color: white;
    border: none;
    padding: 10px 16px;
    white-space: nowrap;
    font-size: 0.8rem;
}

.btn-add:hover {
    background: var(--ink);
    transform: translateY(-1px);
}

.btn-generate {
    width: 100%;
    background: var(--accent);
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 12px rgba(46,123,196,0.4);
    margin-top: 8px;
}

.btn-generate:hover {
    background: var(--accent-light);
    box-shadow: 0 4px 20px rgba(46,123,196,0.6);
    transform: translateY(-2px);
}

/* ── Generate Prompt Status (Tab 2) ── */
.generate-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.generate-row .btn-generate {
    width: auto;
    margin-top: 0;
}

.prompt-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid var(--rule);
    background: var(--paper-warm);
    color: var(--ink-faint);
    font-size: 0.78rem;
    line-height: 1;
    min-height: 30px;
    min-width: 160px;
    box-sizing: border-box;
}

.prompt-status:empty {
    display: none;
}

.prompt-status.is-loading {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.prompt-status.is-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.prompt-status.is-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

/* ===== FORM DIVIDER ===== */
.form-divider {
    height: 1px;
    background: var(--rule);
    margin: 8px 0;
    opacity: 0.6;
}

/* ===== INSTRUCTION TEXT ===== */
.instruction-text {
    font-size: 0.75rem;
    color: var(--ink-faint);
    font-style: italic;
    margin-bottom: 8px;
    line-height: 1.4;
}

/* ===== READONLY TEXTAREA ===== */
textarea[readonly] {
    background: var(--paper-warm);
    color: var(--ink-light);
    cursor: not-allowed;
    resize: none;
}

textarea[readonly]:focus {
    border-color: var(--rule);
    box-shadow: none;
}

textarea[readonly]::placeholder {
    color: var(--ink-faint);
    opacity: 0.7;
}

/* ===== BUTTON VARIANTS ===== */
.btn-copy {
    width: 100%;
    background: var(--ink-light);
    color: white;
    border: 1px solid var(--ink-light);
    padding: 10px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 8px;
}

.btn-copy:hover {
    background: var(--ink);
    border-color: var(--ink);
    transform: translateY(-1px);
}

/* ── DUAL PROMPT MODE (Polish UI) ── */
.prompt-mode-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    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; /* override margin-top global .btn-copy */
    font-size: 0.8rem;
    padding: 10px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    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: #ffffff;
}

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

.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: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

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

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

.prompt-card-desc {
    font-size: 0.82rem;
    color: #475569;
    margin: 0;
    line-height: 1.45;
}

.btn-render {
    width: 100%;
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 12px rgba(40, 167, 69, 0.3);
    margin-top: 8px;
}

.btn-render:hover {
    background: #218838;
    box-shadow: 0 4px 20px rgba(40, 167, 69, 0.4);
    transform: translateY(-2px);
}

/* ===== RINGKASAN DATA ===== */
#ringkasan-data {
    background: var(--paper-warm);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-size: 0.85rem;
    line-height: 1.6;
}

#ringkasan-data h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#ringkasan-data h4::before {
    content: '✓';
    color: #28a745;
    font-weight: bold;
}

#ringkasan-data p {
    margin-bottom: 4px;
}

#ringkasan-data ul {
    margin: 8px 0;
    padding-left: 20px;
}

#ringkasan-data li {
    margin-bottom: 2px;
}

/* ===== RESPONSIVE FORM ===== */
@media (max-width: 768px) {
    .form-container {
        padding: 16px;
    }
    
    .form-section {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }
    
    .input-with-button {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .input-with-button input[type="text"] {
        width: 100%;
    }
    
    .btn-add {
        width: 100%;
        padding: 10px;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-body {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
    
    .panel-left {
        border-right: none;
        border-bottom: 1px solid var(--rule-dark);
    }
    
    .app-header {
        padding: 0 16px;
    }
    
    .app-name {
        font-size: 1.2rem;
    }
    
    .app-subtitle {
        font-size: 0.6rem;
    }
}

/* ===== THEME SELECTOR STYLING ===== */
.theme-selector-wrapper {
   display: flex;
   align-items: center;
   gap: 6px;
   padding: 6px 12px;
   background: rgba(255,255,255,0.1);
   border-radius: 6px;
   border: 1px solid rgba(255,255,255,0.15);
   margin-right: 12px;
}

.theme-label {
   font-size: 0.9rem;
   color: var(--color-text-app-header);
   cursor: pointer;
   transition: opacity 0.2s ease;
}

.theme-label:hover {
   opacity: 0.7;
}

.theme-select {
   background: rgba(255,255,255,0.15);
   color: var(--color-text-app-header);
   border: 1px solid rgba(255,255,255,0.2);
   border-radius: 4px;
   padding: 4px 8px;
   font-size: 0.75rem;
   font-weight: 500;
   cursor: pointer;
   outline: none;
   transition: all 0.2s ease;
}

.theme-select:hover {
   background: rgba(255,255,255,0.2);
   border-color: rgba(255,255,255,0.3);
}

.theme-select:focus {
   border-color: rgba(255,255,255,0.5);
   box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
}

.theme-select option {
   background: var(--color-bg-app-header);
   color: var(--color-text-app-header);
}

.action-buttons {
   display: flex;
   gap: 8px;
}

/* ═══════════════════════════════════════════
   HEADER RESPONSIVE - COMPREHENSIVE
   ═══════════════════════════════════════════ */

/* Tablet (≤768px) */
@media (max-width: 768px) {
    .app-header {
        padding: 0 16px;
        height: 56px;
    }

    .app-title {
        gap: 8px;
    }

    .app-name {
        font-size: 1.2rem;
        max-width: 200px;
    }

    .app-subtitle {
        display: none;
    }

    .btn-toggle-panel {
        padding: 4px 8px;
        font-size: 0.9rem;
    }

    .header-left {
        gap: 8px;
    }

    .theme-selector-wrapper {
        padding: 4px 8px;
        margin-right: 8px;
    }

    .theme-label {
        font-size: 0.8rem;
    }

    .theme-select {
        font-size: 0.7rem;
        padding: 3px 6px;
    }

    .btn-dashboard {
        padding: 6px;
        min-width: 34px;
    }

    .btn-dashboard span {
        display: none;
    }

    .btn-print,
    .btn-simpan-cloud {
        padding: 6px;
        min-width: 34px;
        justify-content: center;
    }

    .btn-print span,
    .btn-simpan-cloud span {
        display: none;
    }

    .header-actions {
        gap: 8px;
    }

    .action-buttons {
        gap: 6px;
    }
}

/* Mobile besar (≤480px) */
@media (max-width: 480px) {
    .app-header {
        padding: 0 12px;
        height: auto;
        min-height: 52px;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
    }

    .app-title {
        gap: 6px;
        min-width: 0;
    }

    .app-name {
        font-size: 1rem;
        max-width: 150px;
    }

    .app-subtitle {
        display: none;
    }

    .btn-toggle-panel {
        padding: 4px 6px;
        font-size: 0.85rem;
    }

    /* Theme selectors - compact */
    .theme-selector-wrapper {
        padding: 3px 6px;
        margin-right: 0;
        gap: 4px;
    }

    .theme-label {
        font-size: 14px;
    }

    .theme-select {
        font-size: 10px;
        padding: 2px 4px;
        max-width: 80px;
    }

    /* Dashboard button - icon only */
    .btn-dashboard {
        padding: 6px;
        min-width: 36px;
    }

    .btn-dashboard span {
        display: none;
    }

    /* Action buttons - full width row */
    .action-buttons {
        width: 100%;
        gap: 4px;
        flex-shrink: 0;
        display: flex;
    }

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

    .selector-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
    }

    .header-actions {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        width: 100%;
        gap: 6px;
    }

    .btn-print,
    .btn-simpan-cloud {
        flex: 1;
        padding: 6px 4px;
        min-width: 0;
        justify-content: center;
        width: 100%;
    }

    .btn-print span,
    .btn-simpan-cloud span {
        display: none;
    }
}

/* Mobile kecil (≤375px) */
@media (max-width: 375px) {
    .app-header {
        padding: 0 8px;
        gap: 6px;
    }

    .app-title {
        gap: 4px;
    }

    .app-name {
        font-size: 0.9rem;
        max-width: 120px;
    }

    .btn-toggle-panel {
        padding: 3px 5px;
        font-size: 0.8rem;
    }

    .header-left {
        gap: 4px;
    }

    .theme-selector-wrapper {
        padding: 2px 4px;
    }

    .theme-select {
        font-size: 9px;
        padding: 2px 3px;
        max-width: 70px;
    }

    .btn-dashboard {
        padding: 5px;
        min-width: 32px;
    }

    .btn-print,
    .btn-simpan-cloud {
        padding: 5px 3px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
  @page {
    size: 330mm 215mm;
    margin: 0mm;
  }

  /* Reset semua tinggi dari layout normal */
  html {
    height: auto !important;
    min-height: 0 !important;
  }

  body {
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
    flex-direction: unset !important;
  }

  /* Reset semua flex container */
  .app-layout,
  .app-container,
  .main-container,
  .panel-right,
  #preview-container,
  #document-preview {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    flex: unset !important;
    display: block !important;
    overflow: visible !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-direction: unset !important;
  }

  /* Sembunyikan semua elemen UI */
  .app-header,
  .panel-left,
  .panel-divider,
  #preview-container > *:not(#document-preview),
  .preview-placeholder,
  .panel-label,
  ::-webkit-scrollbar {
    display: none !important;
  }

  /* Layout print */
  .app-layout,
  .panel-right {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: white !important;
  }

  .panel-right {
    background: white !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
  }

  #preview-container {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
  }

  #document-preview {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
  }

  /* Dokumen F4 Legal Landscape */
  .page {
    width: 330mm !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: white !important;
    border: none !important;
    outline: none !important;
  }

  /* Pastikan tidak ada elemen lain 
     yang menambah tinggi halaman */
  #document-preview,
  #preview-container {
    min-height: 0 !important;
    height: auto !important;
  }

  /* Footer dokumen tidak boleh jadi 
     halaman terpisah */
  .doc-footer {
    page-break-before: avoid !important;
    page-break-after: avoid !important;
  }

  /* Semua section tidak memulai 
     halaman baru kecuali diperlukan */
  .section-title {
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
  }

  table.main,
  table.fase,
  table.ppp {
    page-break-before: avoid !important;
  }

  /* Hanya hindari baris tabel 
     terpotong di tengah */
  table { 
    page-break-inside: auto !important; 
  }
  
  tr { 
    page-break-inside: avoid !important; 
    page-break-after: auto !important; 
  }

  thead {
    display: table-header-group !important;
  }

  /* Hapus halaman kosong */
  html, body {
    height: auto !important;
    overflow: visible !important;
  }
}

/* ── Paste Manual Collapsible ── */
.btn-paste-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 2px;
    transition: color 0.2s ease;
}

.btn-paste-toggle:hover {
    color: var(--accent-light);
}

.paste-manual-panel {
    display: none;
    margin-top: 8px;
    padding: 10px;
    border: 1px dashed var(--ui-border);
    border-radius: var(--radius-sm);
    background: var(--paper-warm);
}

.paste-manual-panel.open {
    display: block;
    animation: fadeSlideIn 0.2s ease;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Fitur Simpan ke Cloud ── */
.btn-simpan-cloud {
    background: var(--color-accent, #e07b39);
    color: #fff;
    border: 1px solid #d46b30;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.8rem;
    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 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--color-border-panel);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--color-bg-panel);
    transition: border-color 0.2s;
}

.dokumen-item:hover {
    border-color: var(--color-accent);
}

.dokumen-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.dokumen-nama {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dokumen-meta {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-bottom: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

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

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

.btn-buka-dokumen:hover {
    background: var(--color-accent);
    color: #fff;
}

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

.btn-hapus-dokumen:hover {
    background: var(--color-btn-danger);
    color: #fff;
}

.dokumen-kosong {
    font-size: 12px;
    color: var(--color-text-secondary);
    text-align: center;
    padding: 16px 0;
    font-style: italic;
}


/* ══════════════════════════════════════════
   STEPPER NAVIGATOR - ATP
   ══════════════════════════════════════════ */
.stepper-nav {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--color-bg-panel);
  border-bottom: 2px solid var(--ui-border);
  padding: 8px 12px;
  flex-shrink: 0;
  margin-bottom: 12px;
  overflow-x: hidden;
}

.step-connector {
  flex: 1;
  height: 2px;
  background: var(--ui-border);
  min-width: 6px;
  max-width: 20px;
  transition: background 0.3s ease;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  border: none;
  background: none;
}

.step-item:hover {
  background: var(--color-bg-hover);
}

.step-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ui-border);
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.3s ease;
  border: 2px solid var(--ui-border);
}

/* step-label disembunyikan — tidak informatif di ruang sempit */
.step-label {
  display: none;
}

/* step-info hanya tampil di step active */
.step-info {
  display: none;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

.step-item.active .step-info {
  display: flex;
}

.step-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-faint);
  white-space: nowrap;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-item.active .step-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
}

.step-item.active .step-label,
.step-item.active .step-title {
  color: var(--accent);
}

.step-item.done .step-circle {
  background: var(--color-btn-success);
  border-color: var(--color-btn-success);
  color: white;
}

.step-item.done .step-label,
.step-item.done .step-title {
  color: var(--color-btn-success);
}

.step-item.done + .step-connector {
  background: var(--color-btn-success);
}

@media (max-width: 1024px) {
  .stepper-nav {
    padding: 6px 8px;
  }
  .step-circle {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }
  .step-connector {
    min-width: 4px;
  }
}

/* ══════════════════════════════════════════
   STEP GUIDE BANNER - ATP
   ══════════════════════════════════════════ */
.step-guide-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--form-banner-gap);
  padding: 12px 16px;
  margin-bottom: var(--form-group-gap);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
}

.step-guide-banner.step-guide-final {
  background: color-mix(in srgb, var(--color-btn-success) 8%, transparent);
  border-left-color: var(--color-btn-success);
}

.step-guide-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-guide-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.4;
}

.step-guide-text strong {
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 700;
}

.step-guide-text span {
  font-size: 0.78rem;
  color: var(--ink-light);
}

/* Dark mode */
[data-theme="dark"] .step-guide-banner {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

[data-theme="dark"] .step-guide-banner.step-guide-final {
  background: color-mix(in srgb, var(--color-btn-success) 12%, transparent);
}

/* ══════════════════════════════════════════
   PREVIEW EMPTY STATE WITH ROADMAP - ATP
   ══════════════════════════════════════════ */
.preview-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  text-align: center;
}

.preview-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.preview-empty-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.preview-empty-desc {
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-bottom: 20px;
}

.preview-empty-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 500px;
}

.preview-empty-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-bg-panel);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  text-align: left;
}

.preview-empty-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.preview-empty-step span {
  font-size: 0.8rem;
  color: var(--ink-light);
  line-height: 1.4;
}

.preview-empty-step strong {
  color: var(--ink);
}

@media (max-width: 768px) {
  .preview-empty-state {
    padding: 16px;
  }
  .preview-empty-steps {
    max-width: 100%;
  }
  .preview-empty-step {
    padding: 8px 10px;
  }
  .preview-empty-step-num {
    width: 24px;
    height: 24px;
    min-width: 24px;
    font-size: 11px;
  }
}

/* ══════════════════════════════════════════
   TAB NAVIGATION — ATP (LEGACY - REMOVE SOON)
   ══════════════════════════════════════════ */

/* ── PANEL CONTENT FLEX ── */
.panel-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.form-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--form-container-padding);
}

/* ── NAVIGASI TAB ── */
.module-nav {
  display: flex;
  gap: 0;
  background: var(--color-bg-panel);
  border-bottom: 2px solid var(--ui-border);
  margin: 0 calc(-1 * 20px);
  padding: 0 20px;
  flex-shrink: 0;
  margin-bottom: 16px;
}

.module-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex: 1;
  text-align: center;
  font-family: var(--ui-font);
  letter-spacing: 0.02em;
}

.module-tab:hover {
  color: var(--ink);
  background: var(--color-bg-hover, rgba(0,0,0,0.04));
}

.module-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: none;
}

/* ── PANEL KONTEN TAB ── */
.module-panel {
  display: none;
  flex: 1;
}

.module-panel.active {
  display: flex;
  flex-direction: column;
}

/* ── FORM SECTION ── */
.form-section {
  margin-bottom: var(--form-section-gap);
  padding: 10px 12px;
  background: var(--paper-warm);
  border-radius: 8px;
  border-bottom: none;
}

.form-section:last-child {
  margin-bottom: 0;
}

.section-title {
  margin-bottom: 0;
}

/* ── SECTION HEADER COLLAPSIBLE ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.section-header:hover .section-title {
  color: var(--accent);
}


/* ── BADGE OPSIONAL ── */
.badge-opsional {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--ink-faint);
  background: var(--paper-warm);
  border: 1px dashed var(--ui-border);
  border-radius: 4px;
  padding: 1px 7px;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 6px;
  text-transform: lowercase;
}

/* ── FIELD REQUIRED ── */
.field-required {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
}

/* ── MUAT ELEMEN CONTROLS ── */
.muat-elemen-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.muat-elemen-controls select {
  flex: 1;
  height: 38px;
}

.btn-muat {
  background: var(--accent);
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  height: 38px;
}

.btn-muat:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.hint-text {
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 4px;
  display: block;
  font-style: italic;
}

/* ── CTA LANJUT TAB ── */
.tab1-cta-lanjut {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--color-bg-panel);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  border-top: 3px solid var(--accent);
}

.tab1-cta-info {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-bottom: 8px;
  line-height: 1.4;
}

.btn-lanjut-tab2 {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.btn-lanjut-tab2:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  transform: translateY(-1px);
}

.btn-lanjut-tab2:active {
  transform: translateY(0);
}

/* ── TOGGLE SWITCH TTD ── */
.ttd-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-bg-panel);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
}

.ttd-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ttd-toggle-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.ttd-toggle-desc {
  font-size: 0.7rem;
  color: var(--ink-faint);
  line-height: 1.3;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--ui-border);
  border-radius: 24px;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ── FORM ROW ── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.form-row .form-group {
  margin-bottom: 0;
}

/* ── ACCORDION PANDUAN ── */
.panduan-accordion {
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  overflow: hidden;
}

.panduan-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--paper-warm);
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--ui-font);
  text-align: left;
  transition: background 0.15s ease;
  gap: 8px;
}

.panduan-toggle:hover {
  background: var(--color-bg-hover, var(--ui-border));
}

.panduan-chevron {
  font-size: 0.65rem;
  color: var(--ink-faint);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.panduan-toggle[aria-expanded="true"] .panduan-chevron {
  transform: rotate(180deg);
}

.panduan-body {
  padding: 10px 12px;
  background: var(--color-bg-panel);
  border-top: 1px solid var(--ui-border);
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panduan-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.panduan-list li {
  font-size: 0.78rem;
  color: var(--ink-light);
  line-height: 1.5;
}

.panduan-list li strong {
  color: var(--ink);
}

/* ── TEXTAREA RENDER (JSON) ── */
.textarea-render {
  min-height: 200px !important;
  resize: vertical;
  font-family: 'JetBrains Mono', 'Courier New', monospace !important;
  font-size: 0.78rem !important;
  line-height: 1.5;
}

/* ── TOMBOL RENDER FULL-WIDTH ── */
.btn-render-dokumen {
  width: 100%;
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 10px;
}

/* ── EMPTY STATE DOKUMEN TERSIMPAN ── */
.dokumen-kosong {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 24px 16px;
  text-align: center;
}

.dokumen-kosong-icon {
  font-size: 1.8rem;
  opacity: 0.4;
  margin-bottom: 4px;
}

.dokumen-kosong-hint {
  font-size: 0.7rem;
  color: var(--ink-faint);
  font-style: italic;
  line-height: 1.4;
  max-width: 200px;
}

/* ── DARK MODE ── */
[data-theme="dark"] .module-nav {
  background: var(--color-bg-panel);
  border-bottom-color: var(--ui-border);
}

[data-theme="dark"] .module-tab:hover {
  background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .toggle-slider {
  background: #555;
}

[data-theme="dark"] .ttd-toggle-card {
  background: var(--paper-warm);
}

[data-theme="dark"] .panduan-toggle:hover {
  background: var(--paper-warm);
}

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .module-nav {
    margin: 0 calc(-1 * 16px);
    padding: 0 8px;
  }
  .module-tab {
    padding: 8px 6px;
    font-size: 10px;
  }
}

@media (max-width: 768px) {
  .module-tab {
    padding: 6px 4px;
    font-size: 9px;
  }
  .ttd-toggle-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .toggle-switch {
    align-self: flex-end;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .muat-elemen-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-muat {
    width: 100%;
    height: auto;
  }
}

/* ══════════════════════════════════════════
   POLISH UX — TAB CONTENT ENHANCEMENTS
   ══════════════════════════════════════════ */

/* ── DIVIDER GRUP ANTAR LANGKAH ── */
.tab-grup-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.tab-grup-divider--top {
  margin-top: 0;
}

.tab-grup-divider::before,
.tab-grup-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ui-border);
}

/* ── SECTION OPSIONAL (border putus-putus) ── */
.form-section-opsional {
  border: 1px dashed var(--ui-border) !important;
  background: transparent !important;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.form-section-opsional:hover {
  opacity: 1;
}

/* ── TIP CARD INFO ── */
.atp-tip-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--color-bg-panel);
  border: 1px solid var(--ui-border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.78rem;
  color: var(--ink-light);
  line-height: 1.5;
}

.atp-tip-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.atp-tip-card strong {
  color: var(--ink);
}

/* ── RINGKASAN DATA — override inline style ── */
#ringkasan-data table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

#ringkasan-data table td {
  padding: 4px 6px;
  vertical-align: top;
  line-height: 1.5;
}

#ringkasan-data table td:first-child {
  font-weight: 600;
  color: var(--ink);
  width: 130px;
  white-space: nowrap;
}

/* ── DARK MODE ── */
[data-theme="dark"] .tab-grup-divider {
  color: var(--ink-faint);
}

[data-theme="dark"] .tab-grup-divider::before,
[data-theme="dark"] .tab-grup-divider::after {
  background: var(--ui-border);
}

[data-theme="dark"] .atp-tip-card {
  background: var(--paper-warm);
  border-color: var(--ui-border);
  border-left-color: var(--accent);
}
