/* ============================================================
   PPT Master - SVG Editor  |  Dark theme, three-panel layout
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #e0e0e0;
    background: #1a1a2e;
    overflow: hidden;
}

/* ---------- App shell ---------- */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ======================== LEFT PANEL ======================== */
#panel-left {
    width: 200px;
    min-width: 200px;
    background: #16162a;
    border-right: 1px solid #2a2a4a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#panel-left .panel-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 15px;
    border-bottom: 1px solid #2a2a4a;
    flex-shrink: 0;
}

#slide-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.slide-list-empty {
    padding: 12px 16px;
    color: #5a5a7a;
    font-size: 13px;
    line-height: 1.5;
}

/* Scrollbar */
#slide-list::-webkit-scrollbar {
    width: 6px;
}
#slide-list::-webkit-scrollbar-track {
    background: transparent;
}
#slide-list::-webkit-scrollbar-thumb {
    background: #3a3a5a;
    border-radius: 3px;
}

/* Slide item */
.slide-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
    user-select: none;
}

.slide-item:hover {
    background: #1f1f38;
}

.slide-item.active {
    background: #1e3a5f;
    border-left-color: #4a9eff;
}

.slide-item.slide-error {
    border-left-color: #ef4444;
}

.slide-item.slide-error .slide-name {
    color: #fca5a5;
}

.slide-item.slide-error .slide-name::before {
    content: "⚠ ";
    color: #ef4444;
}

.slide-item .slide-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
}

.slide-item .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #f5c542;
    color: #1a1a2e;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

/* ======================== CENTER PANEL ======================== */
#panel-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    background: #12121f;
    overflow: hidden;
}

#slide-nav {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid #2a2a4a;
    background: #16162a;
    user-select: none;
}

.nav-btn {
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: #c0c0d8;
    background: transparent;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-btn:hover:not(:disabled) {
    color: #ffffff;
    background: #2a2a4a;
    border-color: #5a5a7a;
}

.nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#nav-label {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 220px;
    max-width: 480px;
    padding: 0 6px;
    font-size: 13px;
    color: #c0c0d8;
    justify-content: center;
}

#nav-counter {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #f5c542;
    white-space: nowrap;
}

#nav-name {
    color: #8a8aaa;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#svg-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 24px;
    position: relative;
}

#svg-placeholder {
    color: #5a5a7a;
    font-size: 16px;
    user-select: none;
}

#svg-content {
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    max-height: 100%;
    overflow: visible;
    position: relative;
}

#svg-content svg {
    display: block;
    /* Both dimensions auto so the box hugs the slide at any aspect ratio: with
       only height:auto, portrait formats (e.g. 1242x1660) keep their attribute
       width while max-height shrinks the height, leaving large white bands
       inside the white card. width:auto lets the element scale proportionally. */
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 72px);
}

/* ---------- SVG element interaction states ---------- */
.svg-selectable {
    cursor: pointer;
    transition: outline 0.12s ease;
}

.svg-selectable:hover {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

.svg-selected {
    outline: 2px solid #4a9eff !important;
    outline-offset: 2px;
    cursor: move;
}

/* While a drag is in progress, keep the move cursor everywhere so it does not
   flicker to the hovered element's cursor as the pointer crosses other shapes. */
body.svg-dragging,
body.svg-dragging * {
    cursor: move !important;
}

.svg-annotated {
    outline: 2px solid #f59e0b !important;
    outline-offset: 2px;
}

/* ======================== RIGHT PANEL ======================== */
#panel-right {
    width: 280px;
    min-width: 280px;
    background: #16162a;
    border-left: 1px solid #2a2a4a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#panel-right .panel-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 15px;
    border-bottom: 1px solid #2a2a4a;
    flex-shrink: 0;
}

/* --- Selection info --- */
#selection-info {
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a4a;
    flex-shrink: 0;
}

.section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #7a7a9a;
    margin-bottom: 8px;
    font-weight: 600;
}

#selected-element {
    font-size: 13px;
    word-break: break-all;
}

#selected-element.empty {
    color: #5a5a7a;
    font-style: italic;
}

#selected-element .el-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #2a2a4a;
    border-radius: 4px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
    color: #7ab4ff;
    margin-right: 6px;
}

#selected-element .el-id {
    font-size: 12px;
    color: #a0a0c0;
}

/* --- Pending status --- */
.pending-status {
    margin: 0 16px 10px;
    padding: 8px 10px;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
}

.pending-status.empty {
    color: #7a7a9a;
    background: #18182a;
}

.pending-status.active {
    color: #f8d46b;
    background: rgba(245, 197, 66, 0.08);
    border-color: rgba(245, 197, 66, 0.45);
}

.pending-pages {
    margin-top: 3px;
    color: #b8a866;
    word-break: break-word;
}

/* --- Annotation input --- */
#annotation-input {
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a4a;
    flex-shrink: 0;
}

#annotation-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.annotation-quick-chip {
    padding: 4px 8px;
    font-size: 11.5px;
    color: #c0c0d8;
    background: #1e1e36;
    border: 1px solid #3a3a5a;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.annotation-quick-chip:hover {
    color: #ffffff;
    background: #2a2a4a;
    border-color: #4a9eff;
}

#annotation-text {
    width: 100%;
    min-height: 80px;
    max-height: 160px;
    resize: vertical;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    color: #e0e0e0;
    background: #1e1e36;
    border: 1px solid #3a3a5a;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s;
}

#annotation-text:focus {
    border-color: #4a9eff;
}

#annotation-text::placeholder {
    color: #5a5a7a;
}

#btn-add-annotation {
    margin-top: 10px;
    width: 100%;
    padding: 9px 0;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: #4a9eff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

#btn-add-annotation:hover {
    background: #3a8eef;
}

#btn-add-annotation:active {
    background: #2a7edf;
}

/* --- Annotation list --- */
#annotation-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
}

#annotation-list::-webkit-scrollbar {
    width: 6px;
}
#annotation-list::-webkit-scrollbar-track {
    background: transparent;
}
#annotation-list::-webkit-scrollbar-thumb {
    background: #3a3a5a;
    border-radius: 3px;
}

#annotations {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.annotation-item {
    background: #1e1e36;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.annotation-item .ann-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.annotation-item .ann-tag {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 11px;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.annotation-item .ann-id {
    font-size: 11px;
    color: #7a7a9a;
}

.annotation-item .ann-remove {
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.annotation-item .ann-remove:hover {
    background: rgba(255, 107, 107, 0.15);
}

.annotation-item .ann-text {
    font-size: 13px;
    color: #c0c0d8;
    word-break: break-word;
    white-space: pre-wrap;
}

.annotations-empty {
    color: #5a5a7a;
    font-size: 13px;
    font-style: italic;
}

/* --- Action buttons --- */
#preview-actions {
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.lang-select {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 5;
}

.lang-select-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 34px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #c0c0d8;
    background: #1e1e3a;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lang-select-btn:hover {
    color: #ffffff;
    background: #2a2a4a;
    border-color: #5a5a7a;
}

.lang-caret { font-size: 9px; color: #8a8aa8; }

.lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    margin: 0;
    padding: 4px;
    list-style: none;
    min-width: 96px;
    background: #1e1e3a;
    border: 1px solid #3a3a5a;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.lang-menu li {
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #c0c0d8;
    cursor: pointer;
}

.lang-menu li:hover,
.lang-menu li:focus { background: #2a2a4a; color: #ffffff; }
.lang-menu li.selected { color: #ffffff; font-weight: 600; }

#btn-save {
    padding: 11px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    background: #f5c542;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

#btn-save:hover {
    background: #e5b532;
}

#btn-save:active {
    background: #d5a522;
}

#btn-exit-preview {
    padding: 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: #c0c0d8;
    background: transparent;
    border: 1px solid #3a3a5a;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

#btn-exit-preview:hover {
    color: #ffffff;
    background: #2a2a4a;
    border-color: #5a5a7a;
}

#btn-exit-preview:active {
    background: #1e1e36;
}

.btn-undo {
    padding: 10px 0;
    font-size: 13px;
    font-weight: 600;
    color: #c0c0d8;
    background: transparent;
    border: 1px solid #3a3a5a;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-undo:hover:not(:disabled) {
    color: #ffffff;
    background: #2a2a4a;
    border-color: #5a5a7a;
}

.btn-undo:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ======================== MODAL ======================== */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#modal {
    background: #1e1e36;
    border: 1px solid #3a3a5a;
    border-radius: 10px;
    padding: 28px 32px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
}

#modal-message {
    font-size: 14px;
    line-height: 1.7;
    color: #d0d0e8;
    margin-bottom: 20px;
    white-space: pre-line;
    text-align: left;
}

#modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

#modal-confirm {
    padding: 10px 32px;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    background: #f5c542;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

#modal-confirm:hover {
    background: #e5b532;
}

#modal-cancel {
    padding: 10px 32px;
    font-size: 14px;
    font-weight: 600;
    color: #a0a0c0;
    background: transparent;
    border: 1px solid #3a3a5a;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

#modal-cancel:hover {
    background: #2a2a4a;
}

/* --- Element properties --- */
#element-props {
    margin-top: 10px;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.prop-table {
    width: 100%;
    border-collapse: collapse;
}

.prop-table tr {
    border-bottom: 1px solid #2a2a4a;
}

.prop-table tr:last-child {
    border-bottom: none;
}

.prop-table td {
    padding: 4px 0;
    vertical-align: top;
}

.prop-table .prop-key {
    color: #7a7a9a;
    width: 80px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.prop-table .prop-val {
    color: #c0c0d8;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
    word-break: break-all;
}

.prop-table .prop-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    vertical-align: middle;
    margin-right: 4px;
    border: 1px solid #3a3a5a;
}

/* --- Direct-edit controls --- */
.prop-caption {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #6a8ec0;
    margin-bottom: 6px;
    font-weight: 600;
}

.prop-section {
    margin-top: 10px;
    margin-bottom: 4px;
    font-size: 10px;
    color: #8a8aaa;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}

.prop-section:first-of-type {
    margin-top: 0;
}

.prop-table .prop-ro {
    color: #8a8aaa;
}

.prop-table .prop-note {
    color: #8a8aaa;
    font-family: inherit;
    font-style: italic;
}

.prop-edit {
    font-family: inherit;
    color: #e0e0e0;
    background: #1e1e36;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    outline: none;
    font-size: 12px;
    transition: border-color 0.15s;
}

.prop-edit:focus {
    border-color: #4a9eff;
}

textarea.prop-edit-content,
textarea.prop-edit-attr-area {
    width: 100%;
    resize: vertical;
    padding: 6px 8px;
    line-height: 1.4;
}

input.prop-edit-attr {
    width: 100%;
    padding: 4px 6px;
}

input.prop-edit-number {
    width: 72px;
    padding: 4px 6px;
}

select.prop-edit-select {
    width: 100%;
    padding: 4px 6px;
}

input.prop-edit-color {
    width: 30px;
    height: 24px;
    padding: 0;
    vertical-align: middle;
    cursor: pointer;
    background: #1e1e36;
}

input.prop-edit-color-text {
    width: calc(100% - 40px);
    margin-left: 6px;
    padding: 4px 6px;
    vertical-align: middle;
}

input.prop-edit-batch,
select.prop-edit-batch {
    width: 100%;
    padding: 4px 6px;
}

input.prop-edit-batch-color + input.prop-edit-batch {
    width: calc(100% - 40px);
    margin-left: 6px;
    vertical-align: middle;
}

input.prop-edit-geo {
    width: 56px;
    padding: 4px 6px;
    margin-right: 4px;
}

input.prop-edit-multi-geo {
    width: 56px;
    padding: 4px 6px;
    margin-right: 4px;
}

.btn-select-group {
    width: 100%;
    padding: 5px 7px;
    color: #d8e6ff;
    background: #24365a;
    border: 1px solid #3e5f98;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.btn-select-group:hover {
    background: #2d4370;
}

.multi-el-list {
    margin-top: 6px;
    max-height: 100px;
    overflow-y: auto;
    font-size: 11px;
}

.multi-el-item {
    padding: 2px 0;
    color: #7a7a9a;
}

.multi-el-item .el-tag {
    font-size: 10px;
    margin-right: 4px;
}

.multi-summary {
    margin-top: 8px;
    font-size: 12px;
    color: #a0a0c0;
}

/* --- Multi-select count --- */
.multi-count {
    color: #4a9eff;
    font-weight: 600;
    font-size: 14px;
}

/* --- Rubber band selection --- */
#rubber-band-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    cursor: crosshair;
}

#rubber-band-overlay.active {
    pointer-events: auto;
}

#rubber-band {
    position: fixed;
    border: 2px dashed #4a9eff;
    background: rgba(74, 158, 255, 0.15);
    pointer-events: none;
    z-index: 11;
}

/* --- Overlap picker (right-click list of stacked elements) --- */
#overlap-picker {
    position: fixed;
    z-index: 1100;
    min-width: 180px;
    max-width: 340px;
    max-height: 60vh;
    overflow-y: auto;
    background: #1f2430;
    border: 1px solid #3a4252;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    padding: 4px;
    font-size: 12px;
}

.overlap-caption {
    padding: 4px 8px 6px;
    color: #8b94a7;
    font-size: 11px;
}

.overlap-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.overlap-item:hover {
    background: #2d3545;
}

.overlap-tag { color: #4a9eff; }
.overlap-id { color: #e6e9ef; }
.overlap-txt {
    color: #8b94a7;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Element highlighted while hovering its row in the overlap picker. */
.overlap-hover {
    outline: 2px solid #f59e0b !important;
    outline-offset: 2px;
}

/* ======================== UTILITY ======================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
