/*
 * Doconut Annotation Bar — embedded annotation toolbar styles.
 * Served from the Doconut assembly at /doconut-res/css/annotationBar.css.
 *
 * Self-contained: includes the generic panel/form helpers the ribbon uses
 * (.float-panel*, .panel-close, .fp-*, .ann-confirm-*) so a host page only needs
 * to add this one stylesheet. Class names match the markup the component injects.
 */

/* ── Clear / delete confirm dialog ───────────────────────────────────────── */
.ann-confirm-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(33,37,41,.35);
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.ann-confirm-backdrop.open { display: flex; }
.ann-confirm-dialog {
    width: min(360px, calc(100vw - 32px));
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0,0,0,.22);
}
.ann-confirm-body { padding: 16px; }
.ann-confirm-title {
    margin: 0 0 8px 0;
    color: #343a40;
    font-size: 1rem;
    font-weight: 700;
}
.ann-confirm-message {
    margin: 0;
    color: #6c757d;
    font-size: .85rem;
    line-height: 1.45;
}
.ann-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #dee2e6;
}
.ann-confirm-actions .fp-btn {
    flex: 0 0 auto;
    min-width: 88px;
}

/* ── Floating panel chrome (shared header / close button) ────────────────── */
.float-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    background: #f1f3f5;
    border-bottom: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    color: #343a40;
    cursor: move;
    gap: 6px;
}
.float-panel-header span { flex: 1; }
.panel-close {
    width: 24px; height: 24px;
    border: none; background: transparent;
    border-radius: 4px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #6c757d; padding: 0;
}
.panel-close:hover { background: #dee2e6; color: #212529; }
.float-panel-body { padding: 12px; }

/* ── Annotation toolbar (ribbon) ─────────────────────────────────────────── */
#annotationToolbar {
    position: static;
    z-index: 900;
    width: 100%;
    max-height: 42vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #dee2e6;
    border-radius: 0;
    box-shadow: none;
    font-size: 0.8rem;
}
#annotationToolbar .float-panel-header {
    cursor: default;
    padding: 4px 8px;
    border-radius: 0;
}
#annotationToolbar {
    overflow: visible;
}
#annotationToolbar .float-panel-header span {
    flex: 0 0 auto;
    white-space: nowrap;
}
#annotationToolbar .ann-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
#annotationToolbar .ann-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: min(100%, 560px);
    scrollbar-width: thin;
}
#annotationToolbar .ann-header-actions::-webkit-scrollbar {
    height: 4px;
}
#annotationToolbar .ann-header-actions::-webkit-scrollbar-thumb {
    background: #c9ced6;
    border-radius: 999px;
}
#annotationToolbar .ann-icon-btn {
    height: 28px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    color: #495057;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 9px;
    flex: 0 0 auto;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
}
#annotationToolbar .ann-icon-btn:hover:not(:disabled),
#annotationToolbar .ann-icon-btn.active {
    background: #e9ecef;
    color: #212529;
}
#annotationToolbar .ann-icon-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}
/* Dev-only example button (Load samples) — dashed/muted so it reads as a demo control. */
#annotationToolbar .ann-dev-btn {
    border-style: dashed;
    border-color: #adb5bd;
    color: #6c757d;
    background: repeating-linear-gradient(45deg, #fff, #fff 6px, #f8f9fa 6px, #f8f9fa 12px);
}
#annotationToolbar .ann-dev-btn:hover {
    background: #e9ecef;
    color: #212529;
}
#annotationToolbar .ann-icon-btn.primary {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}
#annotationToolbar .ann-icon-btn.primary:hover:not(:disabled) {
    background: #0b5ed7;
}
#annotationToolbar .ann-icon-btn.success {
    background: #198754;
    border-color: #198754;
    color: #fff;
}
#annotationToolbar .ann-icon-btn.success:hover:not(:disabled) {
    background: #157347;
}
#annotationToolbar .ann-icon-btn.danger {
    color: #dc3545;
}
#annotationToolbar .ann-icon-btn.danger:hover:not(:disabled) {
    background: #f8d7da;
    border-color: #f1aeb5;
    color: #b02a37;
}
#annotationToolbar .ann-export-wrap {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
}
#annotationToolbar .ann-export-popover {
    position: fixed;
    top: auto;
    left: auto;
    right: auto;
    z-index: 10001;
    display: none;
    width: 210px;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(33, 37, 41, 0.16);
    font-weight: 400;
}
#annotationToolbar .ann-export-popover.open {
    display: block;
}
#annotationToolbar .ann-export-popover .fp-row {
    margin-top: 8px;
}
#annotationToolbar .ann-page-label {
    margin-left: auto;
}
#annotationToolbar .float-panel-body {
    padding: 6px 8px;
}
.ann-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#annotationToolbar .ann-panel-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    overflow: auto;
}
.ann-panel-footer {
    flex: 0 0 auto;
    padding: 10px 12px;
    border-top: 1px solid #dee2e6;
    background: #fff;
}
#annotationToolbar .ann-primary-actions {
    order: 1;
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
    justify-content: flex-start;
    width: 100%;
}

/* Panel controls */
.fp-row { display: flex; gap: 6px; margin-top: 8px; }
.fp-row:first-child { margin-top: 0; }
#annotationToolbar .fp-row {
    flex: 0 0 auto;
    margin-top: 0;
}
#annotationToolbar .ann-primary-actions .fp-btn {
    flex: 0 0 auto;
}
.fp-btn {
    flex: 1; padding: 5px 8px;
    border: 1px solid #ced4da; border-radius: 4px;
    background: #fff; cursor: pointer;
    font-size: 0.80rem; white-space: nowrap;
    transition: background 0.12s; min-width: 0;
}
.fp-btn:hover:not(:disabled) { background: #e9ecef; }
.fp-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.fp-btn.primary { background: #0d6efd; color: #fff; border-color: #0d6efd; }
.fp-btn.primary:hover:not(:disabled) { background: #0b5ed7; }
.fp-btn.success { background: #198754; color: #fff; border-color: #198754; }
.fp-btn.success:hover:not(:disabled) { background: #157347; }
.fp-btn.danger  { background: #dc3545; color: #fff; border-color: #dc3545; }
.fp-btn.danger:hover:not(:disabled)  { background: #bb2d3b; }

.fp-input {
    width: 100%; padding: 5px 8px;
    border: 1px solid #ced4da; border-radius: 4px;
    font-size: 0.82rem; outline: none;
}
.fp-input:focus { border-color: #86b7fe; box-shadow: 0 0 0 2px rgba(13,110,253,.15); }
.fp-label {
    display: flex; align-items: center; gap: 6px;
    margin-top: 7px; cursor: pointer; color: #495057; font-size: 0.81rem;
}
.fp-label input[type=checkbox] { margin: 0; cursor: pointer; }
.fp-divider { border: none; border-top: 1px solid #dee2e6; margin: 10px 0; }
#annotationToolbar .fp-divider { display: none; }

/* Annotation status */
.ann-status { display: flex; align-items: center; gap: 8px; padding: 4px 0 10px 0; }
#annotationToolbar .ann-status {
    display: none;
}
.status-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #adb5bd; flex-shrink: 0;
}
.status-dot.annotating { background: #198754; }
.ann-status-text { font-size: 0.82rem; color: #6c757d; }
.ann-status-text.annotating { color: #198754; font-weight: 600; }

/* Annotation tool grid */
.ann-tool-label {
    font-size: 0.72rem; color: #6c757d; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    margin: 10px 0 5px 0;
}
.ann-tool-label:first-child { margin-top: 0; }
#annotationToolbar .ann-tool-label {
    display: none;
}
#annotationToolbar #annToolSection {
    display: flex;
    flex-direction: column;
    order: 2;
    align-items: stretch;
    gap: 6px;
    width: 100%;
}
#annotationToolbar #annToolSection > div {
    flex: 0 0 auto;
    margin-top: 0 !important;
}
.ann-tool-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}
#annotationToolbar .ann-tool-grid {
    grid-template-columns: repeat(10, minmax(48px, 1fr));
    width: 100%;
}
.ann-tool-btn {
    padding: 5px 2px;
    border: 1px solid #dee2e6; border-radius: 4px;
    background: #fff; cursor: pointer;
    font-size: 0.78rem; text-align: center;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap; overflow: hidden;
}
.ann-tool-btn:hover { background: #e9ecef; }
.ann-tool-btn.active { background: #cfe2ff; border-color: #0d6efd; color: #0d6efd; font-weight: 600; }

/* Annotation style controls */
.ann-style-grid {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto 1fr;
    gap: 4px 6px;
    align-items: center;
}
.ann-style-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.ann-field {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 6px;
    align-items: center;
    min-width: 0;
}
.ann-style-lbl { font-size: 0.73rem; color: #6c757d; white-space: nowrap; }
.ann-color-pick {
    height: 28px; padding: 2px 2px; width: 100%;
    border: 1px solid #ced4da; border-radius: 4px; cursor: pointer;
}
#annotationToolbar .ann-color-pick {
    height: 24px;
    min-width: 38px;
}
.ann-num-pick {
    width: 100%; padding: 3px 4px;
    border: 1px solid #ced4da; border-radius: 4px;
    font-size: 0.78rem; text-align: center;
}

/* Presets */
.ann-preset-dot {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 2px; margin-right: 4px;
    vertical-align: middle; flex-shrink: 0;
}

/* Page indicator in annotation editor */
.ann-page-label {
    font-size: 0.76rem;
    color: #6c757d;
    font-weight: 600;
    white-space: nowrap;
}

#annotationToolbar .float-panel-header {
    gap: 8px;
    min-height: 34px;
}
#annotationToolbar .ann-header-actions {
    margin-left: 0;
}
#annotationToolbar .ann-panel-body {
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    overflow-y: visible;
    padding: 6px 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: #adb5bd transparent;
}
#annotationToolbar .ann-panel-body::-webkit-scrollbar,
#annotationToolbar #annOptionsGrid::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}
#annotationToolbar .ann-panel-body::-webkit-scrollbar-track,
#annotationToolbar #annOptionsGrid::-webkit-scrollbar-track {
    background: transparent;
}
#annotationToolbar .ann-panel-body::-webkit-scrollbar-thumb,
#annotationToolbar #annOptionsGrid::-webkit-scrollbar-thumb {
    background: rgba(108, 117, 125, 0.45);
    border-radius: 999px;
}
#annotationToolbar #annToolSection.ann-ribbon {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    width: 100%;
    min-width: min-content;
}
#annotationToolbar .ann-ribbon-group {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 0 0 auto;
    min-width: 0;
    padding: 0 10px;
    border-right: 1px solid #dee2e6;
}
#annotationToolbar .ann-ribbon-group:first-child {
    padding-left: 0;
}
#annotationToolbar .ann-ribbon-group:last-child {
    border-right: 0;
    padding-right: 0;
}
#annotationToolbar .ann-ribbon-label {
    color: #6c757d;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
}
#annotationToolbar .ann-tool-grid {
    grid-template-columns: repeat(6, minmax(46px, 1fr));
    width: auto;
}
#annotationToolbar .ann-tool-stack {
    display: grid;
    gap: 4px;
}
#annotationToolbar .ann-tool-row {
    display: grid;
    gap: 4px;
}
#annotationToolbar .ann-tool-row-shapes {
    grid-template-columns: repeat(6, minmax(46px, 1fr));
}
#annotationToolbar .ann-tool-row-notes {
    grid-template-columns: repeat(4, minmax(46px, 1fr));
}
#annotationToolbar .ann-ribbon-style .ann-style-grid {
    grid-template-columns: auto 46px auto 52px auto 58px;
    min-width: 300px;
}
#annotationToolbar .ann-ribbon-options {
    flex: 1 1 auto;
    min-width: 420px;
    max-width: none;
    overflow: hidden;
}
#annotationToolbar #annOptionsGrid {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    min-height: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 3px;
    scrollbar-width: thin;
    scrollbar-color: #adb5bd transparent;
}
#annotationToolbar #annOptionsGrid > div {
    flex: 0 0 auto;
    min-width: max-content;
    margin-top: 0 !important;
}
#annotationToolbar #annNoteInput,
#annotationToolbar #annStampInput {
    flex-basis: 220px;
    min-width: 220px;
}
#annotationToolbar #annImageInput {
    flex-basis: 360px;
    min-width: 320px;
    position: relative;
}
#annotationToolbar #annImageInput .fp-row {
    flex-wrap: nowrap;
}
#annotationToolbar #annImagePicker {
    position: fixed;
    z-index: 1200;
    display: none;
    width: min(360px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(220px, calc(100vh - 96px));
    margin: 0;
    overflow: auto;
    box-shadow: 0 8px 24px rgba(33, 37, 41, 0.16);
}
#annotationToolbar #annImagePicker.open {
    display: block;
}
#annotationToolbar #annOptionsGrid .ann-style-grid {
    align-items: center;
    gap: 4px 8px;
    grid-template-columns: max-content max-content !important;
}
#annotationToolbar #annNoteStyleRows .ann-style-grid {
    grid-template-columns: max-content 46px max-content 18px max-content 84px max-content 18px !important;
}
#annotationToolbar #annExportLockRows .ann-style-grid {
    grid-template-columns: max-content 18px max-content 18px !important;
}
#annotationToolbar #annOptionsGrid input[type=checkbox] {
    width: 14px;
    height: 14px;
    justify-self: center;
    margin: 0;
}
#annotationToolbar #annTextColorRow,
#annotationToolbar #annPenColorRow,
#annotationToolbar #annFontSizeRow {
    min-width: 132px;
}
#annotationToolbar #annNoteStyleRows {
    min-width: 350px;
}
#annotationToolbar #annExportLockRows {
    min-width: 150px;
}
#annotationToolbar #annShapeStyleRows {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
}
#annotationToolbar #annShapeStyleRows .ann-shape-style-field {
    display: grid;
    grid-template-columns: max-content max-content;
    align-items: center;
    gap: 4px 6px;
    min-width: 132px;
}
#annotationToolbar #annShapeStyleRows input[type=checkbox],
#annotationToolbar #annFreehandBackColorRow input[type=checkbox],
#annotationToolbar #annShapeOptionsRows input[type=checkbox] {
    width: 14px;
    height: 14px;
    justify-self: center;
    margin: 0;
}
#annotationToolbar .ann-color-pick:disabled {
    cursor: not-allowed;
    opacity: .45;
}
#annotationToolbar #annShapeOptionsRows {
    min-width: 700px;
}
#annotationToolbar #annShapeOptionsRows .ann-shape-options-stack {
    display: grid;
    gap: 4px;
}
#annotationToolbar #annShapeOptionsRows .ann-shape-options-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
}
#annotationToolbar #annShapeOptionsRows .ann-field {
    flex: 0 0 auto;
    grid-template-columns: max-content max-content;
    min-width: 112px;
    margin: 0;
}
#annotationToolbar #annShapeOptionsRows .ann-shape-title-field {
    min-width: 205px;
}
#annotationToolbar #annShapeOptionsRows #annShapeTitle {
    min-width: 150px;
    text-align: left;
}
#annotationToolbar #annShapeOptionsRows .ann-color-pick {
    width: 42px;
}
#annotationToolbar #annShapeOptionsRows .ann-num-pick {
    min-width: 54px;
}
#annotationToolbar #annFreehandStyleExtraRows {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
}
#annotationToolbar #annFreehandStyleExtraRows #annPenColorRow,
#annotationToolbar #annFreehandStyleExtraRows #annFreehandBackColorRow {
    display: grid;
    grid-template-columns: max-content max-content;
    align-items: center;
    gap: 4px 6px;
    margin-top: 0 !important;
    min-width: 132px;
}
#annotationToolbar #annFreehandStyleExtraRows #annFreehandBackColorRow {
    grid-template-columns: max-content max-content max-content max-content;
    min-width: 250px;
}
#annotationToolbar #annFreehandStyleRows {
    min-width: 620px;
}
#annotationToolbar #annFreehandStyleRows .ann-freehand-options-stack {
    display: grid;
    gap: 4px;
}
#annotationToolbar #annFreehandStyleRows .ann-freehand-options-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
}
#annotationToolbar #annFreehandStyleRows .ann-field {
    flex: 0 0 auto;
    grid-template-columns: max-content max-content;
    min-width: 112px;
    margin: 0;
}
#annotationToolbar #annFreehandStyleRows .ann-freehand-color-slot {
    display: grid;
    grid-template-columns: max-content max-content;
    align-items: center;
    gap: 4px 6px;
}
#annotationToolbar #annFreehandBorderColorSlot {
    min-width: 128px;
}
#annotationToolbar #annFreehandStateSlot #annExportLockRows {
    margin-top: 0 !important;
}
#annotationToolbar #annFreehandStyleRows .ann-freehand-title-field {
    min-width: 205px;
}
#annotationToolbar #annFreehandStyleRows #annFreehandTitle {
    min-width: 150px;
    text-align: left;
}
#annotationToolbar #annFreehandStyleRows .ann-color-pick {
    width: 42px;
}
#annotationToolbar #annFreehandStyleRows .ann-num-pick {
    min-width: 54px;
}

@media (max-width: 480px), (max-height: 560px) {
    #annotationToolbar {
        max-height: 55vh;
    }
    .ann-style-grid {
        grid-template-columns: auto minmax(0, 1fr);
    }
    .ann-style-grid.compact {
        grid-template-columns: 1fr;
    }
    .ann-tool-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .fp-row {
        flex-wrap: wrap;
    }
    .ann-panel-footer .fp-row {
        flex-wrap: nowrap;
    }
    #annotationToolbar .ann-panel-body {
        align-items: stretch;
    }
    #annotationToolbar .ann-tool-grid {
        grid-template-columns: repeat(6, minmax(48px, 1fr));
    }
    #annotationToolbar .ann-tool-row-shapes {
        grid-template-columns: repeat(6, minmax(48px, 1fr));
    }
    #annotationToolbar .ann-tool-row-notes {
        grid-template-columns: repeat(4, minmax(48px, 1fr));
    }
    #annotationToolbar .ann-ribbon-options {
        min-width: 360px;
        max-width: none;
    }
    #annotationToolbar #annOptionsGrid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
    }
}
