body { font-family: 'Segoe UI', sans-serif; background: #f7f8fa; }
#pdfw-dashboard { padding: 10px; }
#pdfw-topbar { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 10px 20px; border-radius: 8px; margin-bottom: 10px; }

/* Layout */
#pdfw-main { display: flex; gap: 10px; height: 80vh; }
#pdfw-folders, #pdfw-files, #pdfw-viewer { background: #fff; border-radius: 8px; padding: 10px; }
#pdfw-folders, #pdfw-files { display: flex; flex-direction: column; }
#pdfw-folders { flex: 0 0 180px; }
#pdfw-files { flex: 0 0 240px; }
#pdfw-viewer { flex: 1; text-align: center; position: relative; overflow: auto; }
#pdfw-viewer { -webkit-overflow-scrolling: touch; }

/* Panels */
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.panel-header h3 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-header .pane-actions { display: flex; gap: 6px; }
.panel-header .toggle { width: 28px; height: 28px; border-radius: 6px; border: 1px solid #d0d7de; background: #f6f8fa; cursor: pointer; line-height: 26px; text-align: center; }
.panel-header .toggle:hover { background: #eef2f6; }
.panel-tools { margin-bottom: 8px; }
.panel-tools input[type="text"] { width: 100%; padding: 6px 8px; border: 1px solid #d0d7de; border-radius: 6px; font-size: 13px; }

/* Lists */
.list-wrap { flex: 1; overflow-y: auto; border: 1px solid #eef2f6; border-radius: 6px; }
.list-wrap { -webkit-overflow-scrolling: touch; }
.collapsed .panel-tools, .collapsed .list-wrap { display: none; }
.collapsed { flex: 0 0 44px !important; padding: 10px 10px; }
.collapsed .panel-header { margin-bottom: 0; }
.list { list-style: none; padding: 0; margin: 0; }
.list-item { display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: pointer; font-size: 12px; }
.list-item .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .actions { display: inline-flex; gap: 6px; margin-left: 8px; }
.btn-ico { border: 1px solid #d0d7de; background: #f6f8fa; border-radius: 4px; padding: 2px 6px; font-size: 12px; cursor: pointer; }
.btn-ico:hover { background: #eef2f6; }
.list-item:hover { background: #f2f7ff; }
.list-item.selected { background: #e6f0ff; }
.list-item.empty { color: #667085; cursor: default; }

/* Buttons */
.btn { cursor: pointer; border: 1px solid #d0d7de; background: #f6f8fa; color: #24292f; border-radius: 6px; padding: 6px 10px; font-size: 13px; }
.btn:hover { background: #eef2f6; }
.btn.small { padding: 4px 8px; font-size: 12px; }

/* Editor */
#pdfw-editor { position: relative; display: flex; flex-direction: column; align-items: center; }
#pdfw-editor .pdf-canvas-wrap { position: relative; display: inline-block; border: 1px solid #ddd; }
#pdfw-editor .pdf-page { position: relative; display: inline-block; border: 1px solid #ddd; margin-bottom: 12px; }
#pdfw-editor canvas { max-width: 100%; height: auto; display: block; }
#pdfw-editor .pdf-page canvas:first-child { position: relative; z-index: 1; pointer-events: none; }
#pdfw-editor .pdf-page canvas:last-child { position: absolute; top: 0; left: 0; z-index: 2; pointer-events: auto; }
#pdfw-editor .pdfw-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,0.9); border: 1px solid #d0d7de; padding: 8px 12px; border-radius: 6px; font-size: 13px; z-index: 4; }
#pdfw-viewer .viewer-header { display:flex; align-items:center; justify-content: space-between; margin-bottom: 6px; }
#pdfw-viewer .viewer-actions .btn.small { width: 28px; height: 28px; padding: 0; display:inline-flex; align-items:center; justify-content:center; }
#pdfw-editor .pdfw-error { width: 100%; max-width: 800px; margin: 8px auto; padding: 8px 12px; background: #fff3cd; border: 1px solid #ffe69c; color: #7a5e00; border-radius: 6px; }
#pdfw-tools.tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; background: rgba(255,255,255,0.9); border: 1px solid #d0d7de; border-radius: 8px; padding: 6px; z-index: 5; backdrop-filter: blur(4px); }
#pdfw-tools .tool-btn { min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid #d0d7de; border-radius: 6px; background: #fff; cursor: pointer; font-size: 14px; line-height: 34px; }
#pdfw-tools .tool-btn:hover { background: #f6f8fa; }
#pdfw-tools .tool-btn.active { background: #e6f0ff; border-color: #9ac1ff; }
#pdfw-tools .tool-btn.primary { background: #2da44e; color: #fff; border-color: #2da44e; }
#pdfw-tools .tool-btn.primary:hover { background: #2c974b; }
#pdfw-tools .spacer { width: 8px; }
#pdfw-tools button { margin: 5px; padding: 6px 10px; border: 1px solid #ccc; background: #eee; border-radius: 5px; cursor: pointer; }
#pdfw-tools button:hover { background: #ddd; }

/* Misc */
button { cursor: pointer; }
.pdfw-login-wrapper { max-width: 300px; margin: 100px auto; text-align: center; background: #fff; padding: 20px; border-radius: 8px; }
.pdfw-login-wrapper input { width: 100%; padding: 10px; margin-bottom: 10px; }

/* Mobile toolbar (sticks to bottom) */
@media (max-width: 768px) {
  #pdfw-main { flex-direction: column; height: auto; }
  #pdfw-folders, #pdfw-files { flex: 0 0 auto; }
  #pdfw-folders .list-wrap, #pdfw-files .list-wrap { max-height: 38vh; }
  #pdfw-tools.tools { position: fixed; left: 50%; transform: translateX(-50%); right: auto; top: auto; bottom: 12px; width: calc(100% - 24px); justify-content: space-between; padding: 6px 8px; }
  #pdfw-viewer { padding-bottom: 88px; padding-left: 8px; padding-right: 8px; }
  #pdfw-tools .tool-btn { flex: 1; min-width: 0; height: 40px; font-size: 16px; }
  #pdfw-tools .spacer { display: none; }
  /* keep headers visible while scrolling lists */
  #pdfw-folders .panel-header, #pdfw-files .panel-header { position: sticky; top: 0; background: #fff; z-index: 2; padding-bottom: 6px; }
  /* slightly tighter page spacing and borders on small screens */
  #pdfw-editor .pdf-page { margin-bottom: 8px; border-width: 1px; }
}

/* Tablet toolbar (stick to bottom like mobile) */
@media (min-width: 769px) and (max-width: 1024px) {
  #pdfw-main { flex-direction: column; height: auto; }
  #pdfw-folders, #pdfw-files { flex: 0 0 auto; }
  #pdfw-tools.tools { position: fixed; left: 50%; transform: translateX(-50%); right: auto; top: auto; bottom: 16px; width: min(920px, calc(100% - 48px)); justify-content: space-between; padding: 8px 10px; }
  #pdfw-viewer { padding-bottom: 96px; padding-left: 12px; padding-right: 12px; }
  #pdfw-tools .tool-btn { flex: 1; min-width: 0; height: 44px; font-size: 17px; }
  #pdfw-tools .spacer { display: none; }
}

/* Desktop: keep tools visible while scrolling */
@media (min-width: 1025px) {
  #pdfw-tools.tools { position: fixed; top: 16px; right: 16px; left: auto; bottom: auto; transform: none; width: auto; padding: 6px; }
}

/* Full view mode: hide side panels */
#pdfw-main.full #pdfw-folders,
#pdfw-main.full #pdfw-files { display: none; }
