/* BASE & RESET */
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Roboto', sans-serif; }

.af-editor {
    display: flex;
    min-height: 100vh; /* Allow growing */
    width: 100%;
    overflow-x: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 300px; background: #1e293b; color: #fff;
    display: flex; flex-direction: column; border-right: 1px solid #334155;
    flex-shrink: 0;
}

.logo-area {
    padding: 20px; font-size: 18px; font-weight: 700; color: #38bdf8;
    background: #0f172a; border-bottom: 1px solid #334155;
    display: flex; align-items: center; gap: 10px;
}

/* PANELS */
.panel { padding: 15px; border-bottom: 1px solid #334155; }
.panel-head {
    font-size: 13px; font-weight: 700; color: #94a3b8; text-transform: uppercase;
    margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center;
}

/* INPUTS */
.inp-group { margin-bottom: 10px; }
.inp-group label { display: block; font-size: 12px; margin-bottom: 5px; color: #cbd5e1; }

input[type="text"], input[type="date"], input[type="number"], select {
    width: 100%; background: #0f172a; border: 1px solid #475569;
    color: #fff; padding: 10px; border-radius: 4px; font-size: 14px; outline: none;
}
input:focus { border-color: #38bdf8; }
/* Fix for date icon color */
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

.row-flex { display: flex; gap: 10px; margin-bottom: 10px; }
.col-half { flex: 1; }
.kb-input-wrap { position: relative; }
.kb-input-wrap span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #64748b; font-size: 12px; font-weight: bold; }

/* BUTTONS */
.btn-primary { width: 100%; background: #38bdf8; color: #0f172a; border: none; padding: 10px; border-radius: 4px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s; }
.btn-primary:hover { background: #0ea5e9; }
.btn-secondary { width: 100%; background: #334155; color: #fff; border: none; padding: 8px; border-radius: 4px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* TOGGLE */
.switch { position: relative; display: inline-block; width: 34px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #475569; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #38bdf8; }
input:checked + .slider:before { transform: translateX(16px); }

/* MAIN CONTENT (Right Side) */
.main-content {
    flex: 1; display: flex; flex-direction: column; background: #0b1120;
}

/* TOP HEADER */
.top-header {
    height: 60px; background: #1e293b; border-bottom: 1px solid #334155;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
}
.status-txt { color: #64748b; font-size: 13px; font-weight: 600; }

.btn-download {
    background: #10b981; color: #fff; border: none; padding: 10px 20px;
    border-radius: 6px; font-size: 14px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
}
.btn-download:disabled { background: #334155; opacity: 0.5; cursor: not-allowed; }
.btn-download:hover:not(:disabled) { background: #059669; }

/* PREVIEW BOX */
.preview-box {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 20px; overflow: auto; /* Scroll if image is huge */
}

#preview_img {
    max-width: 90%; max-height: 80vh;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    border: 1px solid #334155; display: block;
}

#empty_msg { text-align: center; color: #334155; }
#empty_msg i { font-size: 60px; margin-bottom: 20px; display: block; }
#empty_msg p { font-size: 18px; }

/* MODAL */
.modal-wrap { 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-box { width: 90%; max-width: 600px; height: 80vh; background: #1e293b; border-radius: 8px; display: flex; flex-direction: column; }
.m-head { padding: 15px; border-bottom: 1px solid #334155; color: white; display: flex; justify-content: space-between; font-weight: bold;}
.m-body { flex: 1; background: #000; overflow: hidden; position: relative; }
.m-foot { padding: 15px; border-top: 1px solid #334155; text-align: right; }
#raw_img { max-width: 100%; }

/* MOBILE RESPONSIVE */
@media (max-width: 768px) {
    .af-editor { flex-direction: column; height: auto; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid #334155; }
    .main-content { min-height: 500px; }
    .top-header { padding: 0 10px; }
}