/* RESET */
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; }

.editor-app {
    display: flex; height: 100vh; width: 100%; overflow: hidden;
}

/* SIDEBAR */
.toolbar {
    width: 300px; background: #1e1e1e; border-right: 1px solid #333;
    display: flex; flex-direction: column; padding: 15px; color: #eee;
    z-index: 10; overflow-y: auto; flex-shrink: 0;
}
.toolbar::-webkit-scrollbar { width: 6px; }
.toolbar::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

.brand { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.brand i { color: #3b82f6; }

.tool-group { background: #2a2a2a; padding: 12px; border-radius: 6px; margin-bottom: 15px; border: 1px solid #333; }
.tool-label { display: block; font-size: 11px; text-transform: uppercase; color: #888; font-weight: 700; margin-bottom: 10px; }

/* CONTROLS */
.btn-tool { width: 100%; padding: 10px; border: none; border-radius: 4px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 5px; }
.btn-upload { background: #3b82f6; color: white; }
.btn-re-crop { background: #333; color: #ccc; }

.slider-control { margin-bottom: 12px; }
.slider-control label { display: flex; justify-content: space-between; font-size: 11px; color: #bbb; margin-bottom: 3px; }
input[type="range"] { width: 100%; accent-color: #3b82f6; cursor: pointer; height: 4px; display: block; margin-top: 5px; }

.input-select { width: 100%; padding: 8px; background: #111; border: 1px solid #444; color: #fff; border-radius: 4px; margin-bottom: 10px; }
.control-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 5px; }
.input-num { width: 60px; background: #111; border: 1px solid #444; color: white; text-align: center; padding: 4px; border-radius: 4px; }
.toggle-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 10px; cursor: pointer; }
.btn-small-text { background: none; border: none; color: #666; font-size: 10px; width: 100%; text-align: right; cursor: pointer; text-decoration: underline; }

/* MAIN AREA */
.main-area { flex: 1; display: flex; flex-direction: column; background: #121212; }

/* TOP ACTION BAR */
.top-action-bar {
    height: 60px; background: #1e1e1e; border-bottom: 1px solid #333;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
}
.history-buttons { display: flex; align-items: center; gap: 5px; }
.btn-icon {
    background: transparent; border: 1px solid transparent; color: #ccc;
    width: 36px; height: 36px; border-radius: 4px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.btn-icon:hover:not(:disabled) { background: #333; color: white; }
.btn-icon:disabled { opacity: 0.3; cursor: default; }
.divider-v { width: 1px; height: 20px; background: #444; margin: 0 10px; }
.status-text { color: #666; font-size: 13px; font-weight: 600; }

.top-buttons { display: flex; gap: 10px; }
.btn-top {
    padding: 8px 20px; border: none; border-radius: 4px; font-size: 13px; font-weight: bold;
    cursor: pointer; display: flex; align-items: center; gap: 8px; transition: 0.2s;
}
.btn-download { background: #3b82f6; color: white; } .btn-download:hover { background: #2563eb; }
.btn-print { background: #fff; color: #333; } .btn-print:hover { background: #e0e0e0; }
.btn-top:disabled { opacity: 0.5; cursor: not-allowed; background: #333; color: #666; }

/* VIEWPORT */
.viewport {
    flex: 1; overflow: auto; padding: 40px;
    display: flex; align-items: flex-start; justify-content: center;
}
.canvas-wrapper {
    box-shadow: 0 0 50px rgba(0,0,0,0.5); border: 1px solid #333;
    display: inline-block; width: auto;
}
#main_canvas { display: block; max-width: 90%; height: auto; margin: 0 auto; background: white; }
.empty-state { text-align: center; color: #444; margin-top: 100px; }
.empty-state i { font-size: 50px; margin-bottom: 15px; }

/* MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-content { background: #1e1e1e; width: 95%; max-width: 600px; height: 80vh; border-radius: 8px; display: flex; flex-direction: column; border: 1px solid #333; }
.modal-header { padding: 15px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; color: white; }
.cropper-body { flex: 1; background: #000; overflow: hidden; position: relative; }
#raw_image { max-width: 100%; }
.modal-footer-controls { padding: 15px; border-top: 1px solid #333; display: flex; gap: 15px; align-items: center; }
.rotate-control { flex: 1; display: flex; gap: 10px; align-items: center; color: #888; }
.btn-modal-action { padding: 10px 20px; background: #3b82f6; color: white; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; }

@media (max-width: 768px) {
    .editor-app { flex-direction: column; height: auto; min-height: 100vh; overflow-y: auto; }
    .toolbar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid #333; }
    .main-area { min-height: 500px; }
    .top-action-bar { padding: 0 10px; }
    .status-text { display: none; }
}