/* ===============================
   BASE LAYOUT
================================ */
body {
    font-family: Arial;
    max-width: 750px;
    margin: 30px auto;
    padding: 20px;
    background: #f4f4f4;
}

.app-box {
    background: white;
    padding: 20px;
    border-radius: 14px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.section {
    display: none;
}

h1 {
    text-align: center;
    font-size: 1.5em;
    margin-bottom: 20px;
}

/* ===============================
   TOP BUTTONS
================================ */
.back-btn-top {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #555;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
}

.menu-btn {
    width: 60%;
    display: block;
    padding: 12px;
    margin: 10px auto;
    background: #4CAF50;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1em;
    cursor: pointer;
}

/* ===============================
   CATEGORY PANEL
================================ */

.category-panel {
    border: 1px solid #ccc;
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    cursor: pointer; /* indicates clickable */
}


.category-panel.collapsed {
    max-height: 36px;
}

.category-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0f0f0;
    padding: 6px 10px;
    cursor: pointer;
}

.btn-toggle {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.category-panel.collapsed .btn-toggle {
    transform: rotate(-90deg);
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 360px;
    overflow-y: auto;
}

/* ===============================
   CATEGORY ITEMS
================================ */.category-form-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    width: 100%;
    margin-bottom: 12px;
}

.category-form-header .header-btn {
    width: auto !important;
    flex: none !important;
    align-self: center;
}

.category-form-title {
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    color: #444;
    pointer-events: none;
    justify-self: center;
}

.category-form-title {
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#categoryList li {
    background: white;
    padding: 6px 10px;
    margin: 6px 0;
    border-radius: 8px;
    border-left: 6px solid #4CAF50;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    font-size: 0.85em;
    transition: background 0.2s ease;
}

#categoryList li.active {
    background: #e3f2fd;
    border-left-color: #2196F3;
}

#categoryList li.editing {
    background: #ffe0b2;
    border-left-color: #ff9800;
}

.category-name {
    font-weight: bold;
}

.category-desc {
    font-size: 0.8em;
    color: #555;
    margin-top: 2px;
}
* Inline category edit highlight */
#categoryList li.inline-editing {
    background: #fff3cd;
    /* soft yellow */
    border-left: 6px solid #ff9800;
}

#categoryList li.inline-editing input,
#categoryList li.inline-editing textarea {
    background: #fff8e1;
    border: 1px solid #ffb74d;
}

#categoryList li.inline-editing input:focus,
#categoryList li.inline-editing textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.25);
}

#categoryList li.active {
    background: #e3f2fd;
    /* blue highlight for selected */
    border-left: 6px solid #2196F3;
}

#categoryList li .category-name {
    font-weight: bold;
    width: 100%;
}

#categoryList li .category-desc {
    font-size: 0.8em;
    color: #555;
    width: 100%;
    margin-top: 2px;
}

/* ---------- INLINE EDIT COMPACT ---------- */
#categoryList li.inline-editing {
    position: relative;
    padding-top: 28px;
}

/* Action icons */
.inline-edit-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 6px;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
    line-height: 1;
    opacity: 0.7;
}

.icon-btn:hover {
    opacity: 1;
}

.icon-btn[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Inputs */
.inline-name,
.inline-desc {
    width: 100%;
    font-size: 0.85em;
}

.inline-desc {
    margin-top: 4px;
    resize: vertical;
}

/* Validation */
.inline-error {
    font-size: 0.75em;
    color: #d32f2f;
    margin-top: 3px;
}

.inline-name.invalid {
    border: 1px solid #d32f2f;
    background: #fff6f6;
}

.edit-btn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    align-self: flex-end;
    margin-top: 3px;
}

.precepts-admin .btn {
    padding: 8px 12px;
    border: none;
    margin: 5px 0;
    border-radius: 6px;
    cursor: pointer;
}

.btn-add {
    background: #2196F3;
    color: white;
}

.precepts-admin .btn-delete {
    background: #d32f2f;
    color: white;
}
.precepts-admin .btn-verse-delete {
    padding: 2px 6px;
    font-size: 0.85em;
    line-height: 1;
}

.btn-edit {
    background: #ff9800;
    color: white;
}

.btn-back {
    background: #666;
    color: white;
}

#versePanel,
#editCategoryPanel {
    width: 100%;
    /* Ensure full width */
    display: none;
    padding: 12px;
    /* Consistent padding */
    box-sizing: border-box;
    /* Prevent overflow */
}

#editCategoryPanel input,
#editCategoryPanel textarea {
    width: 100%;
    /* Ensure input and textarea are full width */
    padding: 10px;
    /* Ensure proper padding inside the fields */
    margin-top: 8px;
    /* Add margin for spacing between elements */
    margin-bottom: 8px;
    /* Space after the input fields */
    border-radius: 8px;
    border: 1px solid #bbb;
    /* Border for inputs */
    box-sizing: border-box;
    /* Prevent overflow */
}

#editCategoryPanel textarea {
    resize: vertical;
    /* Allow vertical resizing */
    height: 100px;
    /* Set a default height for the textarea */
}

#nameWarning {
    font-size: 0.8em;
    margin-top: 4px;
    color: #d32f2f;
}

#addCategoryBtn {
    width: 100%;
    /* Make the button match the form width */
    padding: 10px;
    margin-top: 10px;
    border-radius: 8px;
    background-color: #2196F3;
    color: white;
    font-size: 1em;
    border: none;
    cursor: pointer;
}


#editCategoryPanel h3 {
    text-align: center;
    font-size: 1em;
    margin-bottom: 8px;
}

#editCategoryPanel .btn {
    font-size: 0.85em;
    padding: 5px 8px;
    margin-top: 6px;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    font-size: 18px;
    user-select: none;
    display: none;
}

/* ===============================
   VERSE PANEL
================================ */
#versePanel {
    display: none;
    padding: 12px;
}

#versePanelTitle {
    font-size: 0.85em;
    margin: 4px 0 8px 0;
    line-height: 1.3;
}#versePanelTitle::before {
    content: "Tip: Use the search to lookup any verse, or select from book, chapter and verse dropdown";
    display: block;
    font-size: 0.8em;
    font-style: italic;
    color: #666;
    margin-bottom: 6px;
}


/* ===============================
   DROPDOWNS
================================ */
.dropdowns-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.input-clear-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
}

.input-clear-wrapper input,
.input-clear-wrapper textarea {
    width: 100%;
    box-sizing: border-box;
}

input,
textarea,
select {
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #bbb;
    font-size: 0.9em;
}

/* ===============================
   COMMENT BOX (AUTO-EXPAND)
================================ */
textarea#verseComment {
    min-height: 56px;
    height: auto;
    resize: none;
    overflow: hidden;
    transition: height 0.2s ease;
    font-size: 0.85em;
    padding: 10px;
}

/* ===============================
   SEARCH INPUT
================================ */
#verseSearchInput {
    width: 100%;
    padding: 8px 28px 8px 8px;
    border-radius: 6px;
    border: 1px solid #bbb;
    box-sizing: border-box;
}

/* ===============================
   SEARCH RESULTS (SNAPS TO CONTENT)
================================ */
#chapterVersesContainer {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 6px;
    background: #f0f0f0;
    margin-top: 8px;
    transition: max-height 0.25s ease, padding 0.2s ease;
}
/* Chapter Verses Container hint */
#chapterVersesContainer::before {
    content: "Tip: Click on verse result to add to the precepts. Write a comment to include it with precepts, before clicking";
    display: block;
    font-size: 0.75em;
    color: #666;
    margin-bottom: 6px;
    font-style: italic;
    pointer-events: none; /* doesn't interfere with interaction */
}

#chapterVersesContainer:empty {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border: none;
}

/* Verse items */
.chapter-verse-item {
    background: #fbfbfb;
    border-left: 4px solid #4CAF50;
    padding: 8px;
    margin: 6px 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
}#verseSearchInput {
    width: 100%;
    padding: 8px 28px 8px 8px;
    /* space for clear button */
    border-radius: 6px;
    border: 1px solid #bbb;
    box-sizing: border-box;
}

#clearSearchBtn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    font-size: 18px;
    user-select: none;
    display: none;
}

#clearSearchBtn:hover {
    color: #d32f2f;
}

.chapter-verse-item:hover {
    background: #eef6ff;
}

/* ===============================
   CATEGORY VERSES
================================ */
#categoryVersesContainer {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
    background: #f9fff9;
    border: 2px solid #4CAF50;
}
#categoryVersesContainer::before {
    content: "Tip: Drag verses to change their order";
    display: block;
    font-size: 0.75em;
    color: #666;
    margin-bottom: 6px;
    font-style: italic;
    pointer-events: none; /* important: doesn't interfere with dragging */
}

.category-verse-item {
    background: #fff;
    border-left: 4px solid #2196F3;
    padding: 8px;
    margin: 6px 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}.category-verse-item.newly-added {
    background: #e3f2fd;
    transition: background 1.5s;
}

.category-verse-item.dragging {
    opacity: 0.5;
}


.drag-handle {
    cursor: grab;
    user-select: none;
    margin-left: auto;
    opacity: 0.6;
}

/* ===============================
   COMMENT BUBBLE
================================ */
.comment-bubble {
    display: inline-block;
    background: #fff7d6;
    color: #8a5b00;
    padding: 3px 8px;
    margin-left: 6px;
    border-radius: 10px;
    border: 1px solid #e6c568;
    font-size: 0.82em;
}

/* ===============================
   MOBILE
================================ */
@media (max-width: 600px) {
    .dropdowns-row {
        flex-direction: column;
    }

    .chapter-verse-item,
    .category-verse-item {
        font-size: 0.95em;
        padding: 10px;
    }
}
