@font-face {
    font-family: 'GreatVibes';
    src: url('../fonts/GreatVibes-Regular.ttf') format('truetype');
    font-weight: normal;
}
@font-face {
    font-family: 'OpenSans';
    src: url('../fonts/OpenSans-Regular.ttf') format('truetype');
    font-weight: 400;
}
@font-face {
    font-family: 'OpenSans';
    src: url('../fonts/OpenSans-Bold.ttf') format('truetype');
    font-weight: 700;
}
@font-face {
    font-family: 'OpenSansBoldItalic';
    src: url('../fonts/OpenSans-BoldItalic.ttf') format('truetype');
    font-weight: 700;
    font-style: italic;
}

:root {
    --primary: #1a237e;
    --primary-light: #3949ab;
    --accent: #f5a623;
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    --success: #2e7d32;
    --danger: #c62828;
    --radius: 8px;
}

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

body {
    font-family: 'OpenSans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ===== HEADER ===== */
.app-header {
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header h1 { font-size: 18px; font-weight: 700; }
.app-header .session-id { font-size: 11px; opacity: 0.7; font-family: monospace; }

/* ===== MAIN LAYOUT ===== */
.app-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    padding: 16px;
    max-width: 1440px;
    margin: 0 auto;
    align-items: start;
    min-height: calc(100vh - 56px);
}

/* ===== CANVAS AREA ===== */
.canvas-area {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 12px;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px - 32px);
    display: flex;
    flex-direction: column;
}
.canvas-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}
.canvas-wrapper canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    cursor: crosshair;
}
.canvas-placeholder {
    position: absolute;
    color: var(--text-light);
    text-align: center;
    padding: 40px;
    z-index: 1;
    pointer-events: none;
}
.canvas-placeholder.hidden { display: none; }
.canvas-placeholder svg { width: 64px; height: 64px; margin-bottom: 12px; opacity: 0.4; }

/* ===== SIDEBAR ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ===== PANEL (accordion) ===== */
.panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.panel-header {
    background: var(--primary);
    color: white;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius) var(--radius) 0 0;
}
.panel-header.collapsed {
    border-radius: var(--radius);
}
.panel-header .toggle {
    font-size: 10px;
    transition: transform 0.2s;
}
.panel-header.collapsed .toggle {
    transform: rotate(-90deg);
}

/* Panel body: visible by default */
.panel-body {
    padding: 14px;
    font-size: 13px;
    border-radius: 0 0 var(--radius) var(--radius);
}
/* Panel body: hidden when collapsed */
.panel-body.collapsed {
    display: none !important;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
    margin-bottom: 10px;
}
.form-group:last-child {
    margin-bottom: 0;
}
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Text, number, textarea, select inside form-group */
.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(57,73,171,0.15);
}
.form-group textarea {
    resize: vertical;
    min-height: 56px;
}

/* Color input */
.form-group input[type="color"] {
    display: block;
    width: 100%;
    height: 34px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
}

/* Grid layouts for side-by-side fields */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.form-row:last-child { margin-bottom: 0; }
.form-row .form-group { margin-bottom: 0; }

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.form-row-3:last-child { margin-bottom: 0; }
.form-row-3 .form-group { margin-bottom: 0; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    line-height: 1.4;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #e09500; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #1b5e20; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    margin-bottom: 10px;
}
.upload-zone:last-child { margin-bottom: 0; }
.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary-light);
    background: rgba(57,73,171,0.04);
}
.upload-zone input[type="file"] {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.upload-zone .upload-label { font-size: 12px; color: var(--text-light); }
.upload-zone .upload-icon { font-size: 24px; margin-bottom: 4px; }
.upload-zone.uploaded { border-color: var(--success); background: rgba(46,125,50,0.04); }
.upload-zone.uploaded .upload-label { color: var(--success); }

/* Small upload zone (for header logos) */
.upload-zone.upload-zone-sm {
    padding: 10px 6px;
    margin-bottom: 6px;
}
.upload-zone.upload-zone-sm .upload-label {
    font-size: 11px;
    word-break: break-all;
}

/* Form hint text */
.form-hint {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== PARTICIPANT NAV & LIST ===== */
.peserta-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}
.peserta-nav .nav-info {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
}
.peserta-list {
    max-height: 150px;
    overflow-y: auto;
    border-radius: 4px;
}
.peserta-list:not(:empty) { border: 1px solid var(--border); }
.peserta-item {
    padding: 6px 10px;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.peserta-item:last-child { border-bottom: none; }
.peserta-item:hover { background: var(--bg); }
.peserta-item.active {
    background: rgba(57,73,171,0.08);
    color: var(--primary);
    font-weight: 600;
}

/* ===== CHECKBOX ===== */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}
.checkbox-group input[type="checkbox"] { accent-color: var(--primary); }
.checkbox-group label { font-size: 12px; cursor: pointer; }

/* ===== SECTION DIVIDER ===== */
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

/* ===== PRESET ROW ===== */
.preset-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.preset-row select {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}
.preset-row select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(57,73,171,0.15);
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}
.loading-box {
    background: white;
    border-radius: var(--radius);
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box p { font-size: 14px; color: var(--text); }
.loading-box .progress-text { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* ===== PROGRESS BAR ===== */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-bar .progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

/* ===== ALERTS ===== */
.alert { padding: 10px 14px; border-radius: 4px; font-size: 12px; margin-bottom: 10px; }
.alert-success { background: #e8f5e9; color: var(--success); border: 1px solid #c8e6c9; }
.alert-error { background: #ffebee; color: var(--danger); border: 1px solid #ffcdd2; }
.alert-info { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* ===== FORMAT SELECTOR ===== */
.format-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13px;
}
.format-label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 12px;
}
.format-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.format-option input[type="radio"] { accent-color: var(--primary); }

/* ===== SUCCESS MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal-box {
    background: white;
    border-radius: 12px;
    padding: 32px 36px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    max-width: 420px;
    width: 90%;
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-icon-success {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    font-size: 28px;
    line-height: 56px;
    margin: 0 auto 16px;
}
.modal-box h3 {
    font-size: 20px;
    color: var(--text);
    margin-bottom: 8px;
}
.modal-info {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 4px;
}
.modal-error {
    font-size: 13px;
    color: var(--danger);
    margin-bottom: 4px;
}
.modal-download {
    margin-top: 16px;
    font-size: 15px;
    padding: 12px 20px;
}
.modal-close {
    margin-top: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    .canvas-area {
        position: static;
    }
    .canvas-wrapper {
        min-height: 260px;
    }
}
