/* =============================================
   NEXT-GEN QR GENERATOR - CSS (Linear/Vercel Vibe)
   ============================================= */

:root {
    --bg-base: #000000;
    --bg-panel: #0a0a0a;
    --bg-card: #111111;
    --bg-hover: #1f1f1f;
    --bg-input: #111;

    --text-main: #ededed;
    --text-muted: #888888;

    --border-color: #222222;
    --border-focus: #444444;

    --accent: #ededed;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;

    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;

    --shadow-glow: 0 0 40px -10px rgba(59, 130, 246, 0.4);
    --shadow-dropdown: 0 10px 30px -10px rgba(0, 0, 0, 0.8);

    --font: 'Outfit', -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 3rem;
    overflow-x: hidden;
    position: relative;
}

/* Background Effects */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-blue);
    top: -200px;
    right: -100px;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: #8b5cf6;
    bottom: -100px;
    left: -200px;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.app-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 0 3rem;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.app-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.app-main {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 968px) {
    .app-main {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        grid-row: 1;
    }

    /* move preview to top on mobile */
    .desktop-only {
        display: none !important;
    }
}

/* --- LEFT PANEL: CARDS --- */
.tools-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color 0.3s;
}

.card:hover {
    border-color: var(--border-focus);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    margin-bottom: 1.25rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Inputs */
.modern-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    transition: 0.2s;
}

.modern-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.modern-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    appearance: none;
}

.modern-select:focus {
    outline: none;
    border-color: var(--text-muted);
}

/* Dropzones */
.drop-zone {
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.01);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 2rem 1rem;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
}

.drop-content .drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
}

.drop-content p {
    font-size: 0.95rem;
    font-weight: 500;
}

.drop-content span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.drop-zone.mini {
    padding: 1rem;
}

.drop-zone.mini .drop-icon {
    font-size: 1.5rem;
    margin-bottom: 0px;
    margin-right: 0.5rem;
    display: inline;
}

.drop-zone.mini p {
    display: inline;
    font-size: 0.9rem;
}

/* Status */
.status-msg {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    text-align: center;
}

.status-success {
    color: #22c55e;
}

.status-error {
    color: #ef4444;
}

/* Logo Area */
.logo-area {
    position: relative;
}

.preview-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-base);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

#logo-preview {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 2px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: 0.2s;
}

.btn-icon:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Accordion */
.accordion {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.acc-item {
    border-bottom: 1px solid var(--border-color);
}

.acc-item:last-child {
    border-bottom: none;
}

.acc-header {
    width: 100%;
    text-align: left;
    background: var(--bg-panel);
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 1rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.acc-header:hover {
    background: var(--bg-hover);
}

.acc-header::after {
    content: '▼';
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: transform 0.3s;
}

.acc-item.open .acc-header::after {
    transform: rotate(180deg);
}

.acc-body {
    display: none;
    padding: 1.25rem;
    background: var(--bg-base);
    border-top: 1px solid var(--border-color);
}

.acc-item.open .acc-body {
    display: block;
    animation: fadeInBlock 0.3s ease;
}

@keyframes fadeInBlock {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Grid & Pickers */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.color-picker-wrap label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.color-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
}

.color-control input[type="color"] {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    padding: 0;
    appearance: none;
    background: none;
    cursor: pointer;
}

.color-control input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-control input[type="color"]::-webkit-color-swatch {
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-control span {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-main);
}

/* Range */
.margin-slider-wrap label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.modern-range {
    width: 100%;
    appearance: none;
    background: var(--border-color);
    height: 4px;
    border-radius: 2px;
}

.modern-range::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-main);
    cursor: pointer;
}

/* Chips */
.shape-group {
    margin-bottom: 1rem;
}

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

.shape-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.chip-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s;
}

.chip:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

.chip.active {
    background: var(--text-main);
    color: var(--bg-base);
    border-color: var(--text-main);
    font-weight: 600;
}

/* --- RIGHT PANEL: PREVIEW --- */
.sticky-preview {
    position: sticky;
    top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.btn-hero {
    width: 100%;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
    transition: all 0.2s ease;
}

.btn-hero:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-hero:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.qr-display-card {
    background: #ffffff;
    /* QR background usually needs to be stark white for best scanning */
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: 0 0 0 1px var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px;
}

.placeholder-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #a1a1aa;
}

.placeholder-state .pulse-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    animation: pulse 2s infinite;
    opacity: 0.5;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
        transform: scale(0.95);
    }

    50% {
        opacity: 0.8;
        transform: scale(1);
    }

    100% {
        opacity: 0.5;
        transform: scale(0.95);
    }
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-dowload {
    width: 100%;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.8rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: 0.2s;
}

.btn-dowload:hover {
    background: var(--bg-hover);
    border-color: var(--border-focus);
}

.btn-dowload.alt {
    background: transparent;
}

/* Toggle Switch */
.date-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
}

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

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

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

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.3s;
}

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

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

/* Date Options */
.date-options {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
    animation: fadeIn 0.3s ease;
}

/* QR Full Wrapper (for capturing QR + date label together) */
.qr-full-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    /* width: 100%; removed to prevent capturing extra white space on the sides */
}

/* QR canvas wrapper - needs relative for overlay to anchor */
.qr-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.qr-label-overlay {
    position: relative;
    z-index: 10;
    width: max-content; /* Guarantee parent expands to fit text without cropping */
    max-width: 450px; /* Sensible limit so it doesn't stretch to infinity */
    background: transparent;
    padding: 0.35rem 0;
    font-size: 1rem;
    font-weight: 700;
    color: #444;
    letter-spacing: 0.02em;
    text-align: center;
    pointer-events: none;
    word-break: break-word;
    line-height: 1.3;
}

/* Date Label below QR */
.qr-date-label {
    text-align: center;
    margin-top: 0.3rem;
    padding: 0.25rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

.qr-date-label .date-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111;
}

.hidden {
    display: none !important;
}

/* ═══════════════════════════════════════════════
   STAMP MODAL - PDF QR Drag & Drop
   ═══════════════════════════════════════════════ */

/* "Tempel QR ke PDF" button in actions */
.btn-dowload.stamp-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.btn-dowload.stamp-btn:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

/* Fullscreen Modal */
.stamp-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    animation: stampFadeIn 0.3s ease;
}

@keyframes stampFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header Bar */
.stamp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: rgba(17, 17, 17, 0.95);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.stamp-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stamp-header-left h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}

.stamp-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stamp-close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #ef4444;
}

.stamp-header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

/* Page Navigation */
.stamp-page-nav {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255,255,255,0.04);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.stamp-nav-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stamp-nav-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-main);
}
.stamp-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#stamp-page-info {
    font-size: 0.8rem;
    color: var(--text-main);
    font-weight: 500;
    min-width: 50px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Save Button */
.stamp-save-btn {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(34, 197, 94, 0.25);
    white-space: nowrap;
}
.stamp-save-btn:hover {
    background: linear-gradient(135deg, #16a34a, #15803d);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}
.stamp-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Modal Body */
.stamp-modal-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem;
}

/* PDF Wrapper — contains canvas + draggable QR */
#pdf-wrapper {
    position: relative;
    display: inline-block;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    overflow: hidden;
    line-height: 0; /* prevent extra space below canvas */
}

#pdf-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Draggable QR Code */
.drag-qr {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 100px;
    height: 100px;
    cursor: move;
    z-index: 10;
    outline: 2px dashed rgba(59, 130, 246, 0.7);
    background: rgba(59, 130, 246, 0.05);
    transition: outline-color 0.2s, box-shadow 0.2s;
    touch-action: none; /* required for interact.js */
    user-select: none;
}

.drag-qr:hover {
    outline-color: rgba(59, 130, 246, 1);
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.3);
}

.drag-qr.is-dragging {
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    opacity: 0.9;
}

.drag-qr img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
}

/* Resize Handle */
.drag-qr-resize-handle {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #3b82f6;
    border-radius: 2px 0 4px 0;
    cursor: se-resize;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.drag-qr-resize-handle::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
}
.drag-qr-resize-handle:hover {
    opacity: 1;
}

/* Status Bar */
.stamp-status {
    padding: 0.75rem 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    animation: fadeIn 0.3s ease;
}
.stamp-status.success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}
.stamp-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}
.stamp-status.info {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

/* Responsive */
@media (max-width: 640px) {
    .stamp-modal-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }
    .stamp-header-left, .stamp-header-right {
        width: 100%;
        justify-content: space-between;
    }
    .stamp-modal-body {
        padding: 1rem;
    }
    .stamp-save-btn {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
}