/* ==========================================
   RESET TOTAL & SETTING LAYAR LEBAR
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: #0f172a;
    color: #f8fafc;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden; /* Mencegah patahan horizontal di semua monitor */
}

/* ==========================================
   HEADER (Lebar Penuh & Mepet Atas)
   ========================================== */
header {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    padding: 10px 15px;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

header h1 {
    font-size: 1.3rem;
    color: #3b82f6;
    font-weight: 700;
}

header p {
    font-size: 0.75rem;
    color: #94a3b8;
}

.subdomain-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
}

/* ==========================================
   STRUKTUR MELEBAR PENUH 100% (MEPET KANAN-KIRI)
   ========================================== */
.container {
    display: grid;
    grid-template-columns: 290px 1fr; /* Sidebar sempit namun fungsional, sisa layar milik canvas */
    gap: 10px;
    padding: 10px; /* Sempit & Mepet maksimal di semua layar */
    flex: 1;
    width: 100%;
    max-width: 100% !important; /* Memaksa mengabaikan batas maksimal */
}

/* ==========================================
   SIDEBAR KONTROL (KIRI)
   ========================================== */
.sidebar {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

/* Scrollbar tipis modern */
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background-color: #475569;
    border-radius: 2px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
}

.form-group select, 
.form-group input[type="range"],
.form-group input[type="text"] {
    background: #0f172a;
    border: 1px solid #475569;
    color: #f8fafc;
    padding: 7px;
    border-radius: 6px;
    outline: none;
    font-size: 0.82rem;
    cursor: pointer;
    width: 100%;
}

.form-group-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

/* Upload Area / Dropzone */
.upload-area {
    border: 2px dashed #475569;
    border-radius: 6px;
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.4);
    transition: border-color 0.2s;
}

.upload-area p {
    font-size: 0.75rem;
    color: #94a3b8;
}

#fileInput {
    display: none;
}

/* Thumbnail List & Items */
.thumb-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin-top: 4px;
}

.thumb-item {
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid #475569;
    position: relative;
}

.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.btn-edit-thumb {
    position: absolute;
    bottom: 1px;
    right: 1px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 3px;
    width: 16px;
    height: 16px;
    font-size: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

/* Tombol */
.btn {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    background: #3b82f6;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn:hover {
    background: #2563eb;
}

.btn-danger {
    background: #ef4444;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: #10b981;
}

.btn-success:hover {
    background: #059669;
}

/* ==========================================
   AREA PRATINJAU / PREVIEW AREA (KANAN)
   ========================================== */
.preview-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100vh - 80px);
    width: 100%;
}

/* Preview Header & Text List Badge */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    flex-wrap: wrap;
    gap: 8px;
}

.preview-header h3 {
    font-size: 0.9rem;
    color: #f8fafc;
}

.text-badge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.text-badge {
    background: #334155;
    color: #f8fafc;
    font-size: 0.7rem;
    padding: 3px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid transparent;
}

.text-badge .remove-btn {
    color: #ef4444;
    cursor: pointer;
    font-weight: bold;
}

.badge {
    background: #3b82f6;
    color: white;
    font-size: 0.68rem;
    padding: 3px 6px;
    border-radius: 4px;
}

/* Canvas Wrapper - Tanpa margin mengambang, mepet tepi bingkai */
.canvas-wrapper {
    flex: 1;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px; /* Lebih tipis agar foto tampil maksimal dan mepet */
    overflow: hidden;
    position: relative;
    width: 100%;
}

#collageCanvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    background-color: #0f172a;
    cursor: move;
}

.resolusi-info {
    text-align: center;
    font-size: 0.7rem;
    color: #64748b;
}

/* ==========================================
   MODAL EDIT POP-UP (FILTER & ZOOM)
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.8);
    display: none; /* Dikelola lewat app.js */
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-content {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
    padding-bottom: 8px;
}

.modal-header h4 {
    font-size: 0.95rem;
    color: #3b82f6;
}

.modal-close {
    font-size: 1.2rem;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
}

/* ==========================================
   RESPONSIF SMARTPHONE / TABLET
   ========================================== */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr; /* Responsif beralih ke atas-bawah */
    }
    .sidebar {
        height: auto;
        max-height: 500px;
    }
    .preview-area {
        height: auto;
    }
    .canvas-wrapper {
        min-height: 420px;
    }
}