/* ===================== Layout ===================== */
body {
    display: flex;
    flex-direction: row;
    height: 100vh;
    margin: 0;
}

#sidebar {
    flex: 0 0 30%; /*width: 30%;*/
    padding: 10px;
    border-right: 2px solid #ccc;
    overflow-y: auto;
    height: 100%;
    background-color: #f1f1f1;
    transition: all 0.3s ease; /*transition: width 0.3s, padding 0.3s;*/
}

#sidebar.collapsed {
    flex: 0 0 0; /*width: 0;*/
    padding: 0;
    overflow: hidden; /* New: Hide overflow when collapsed */
    border: none;
}

body.sidebar-collapsed #song-content {
    width: 100%;
}

#toggle-sidebar {
    background-color: #007BFF;
    color: white;
    border: none;
    font-size: 1.5em;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 5px;
    transition: transform 0.3s ease;
}

#search {
    width: 100%;
    padding: 0.5rem;         /* was 8px */
    margin-bottom: 0.625rem; /* was 10px */
    box-sizing: border-box;
}

#song-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    max-height: 85vh;
    overflow-y: auto; /* Make the list scrollable */
}

#song-list li {
    margin: 5px 0;
}

#song-content {
    flex: 1; /*width: 70%;*/
    background-color: #dadada;
    overflow-y: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease; /*new*/
}

#song-lyrics {
    white-space: wrap;
    word-wrap: break-word;
    flex-grow: 1;
}

/* ===================== Verse containers ===================== */
.verse-container {
    display: flex;
    margin-bottom: 10px; /* Add space between verses */
    align-items: flex-start; /* Align the items at the top */
}

/* Left container for meta information (e.g., "V1") */
.verse-meta-box {
    flex: 0 0 auto; /* Do not grow or shrink, size to content */
    width: auto;    /* Let the content define the width*/
    text-align: center;
    background-color: #ffffff; /* Light gray background for contrast */
    border-style: solid;
    padding: 0.3125rem;      /* was 5px */
    margin-right: 0.9375rem; /* was 15px */
    border-radius: 0.3125rem;
    font-size: 0.9em;
    font-weight: bold;
    white-space: nowrap; /* Prevent wrapping to multiple lines */
}

/* Right container for lyrics */
.verse-lyrics-box {
    flex: 1; /* This will make the lyrics container take up the remaining space */
    padding: 0.625rem 0 0.625rem 0; /* was 10px */
    background-color: #ffffff; /* White background for lyrics */
    border-style: solid;
    border: 1px solid #ddd; /* Border around the lyrics box */
    border-radius: 0.3125rem;
    word-wrap: break-word; /* Ensure long lines break */
    white-space: pre-wrap; /* Preserve line breaks */
    padding-left: 0; /* Remove padding from the left side */
    margin: 0; /* Reset any margins */
}

/* Ensure first line of lyrics is aligned properly */
.verse-lyrics-box > *:first-child {
    margin-left: 0; /* Remove left margin from first child */
}

/* Optional: Make sure each line of lyrics has proper spacing */
.verse-line {
    margin-bottom: 5px;
}

.log {
    color: red;
    font-size: 12px;
}

#user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    font-size: 0.9em;
}

#user-info span {
    color: #333;
}

#user-info a {
    text-decoration: none;
    color: #007BFF;
    margin-left: 10px;
}

#user-info a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

.filter-dropdown {
    position: relative;
    margin-top: 10px;
}

.dropdown-button {
    width: 100%;
    padding: 6px;
    cursor: pointer;
}

.dropdown-menu {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    padding: 10px;
    margin-top: 4px;
    width: 220px;
    z-index: 10;
}

.dropdown-menu.open {
    display: block;
}

.filter-section {
    margin-bottom: 10px;
}

.filter-title {
    display: block;
    font-size: 0.8em;
    font-weight: bold;
    margin-bottom: 6px;
}

.tag {
    display: inline-block;
    border: 1px solid #ccc;
    border-radius: 14px;
    padding: 4px 10px;
    margin: 3px;
    cursor: pointer;
}

.tag input {
    display: none;
}

.tag:has(input:checked) {
    background: #2b6cb0;
    color: white;
    border-color: #2b6cb0;
}

/* ===================== Controls toolbar ===================== */
.controls-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background-color: #e5e7eb;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    font-weight: 500;
}

.btn-ctrl {
    background-color: #007BFF;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-ctrl:hover {
    background-color: #0056b3;
}

.btn-ctrl.btn-reset {
    background-color: #6c757d;
}

.btn-ctrl.btn-reset:hover {
    background-color: #545b62;
}

.transpose-badge {
    background: #ffffff;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    font-weight: bold;
    color: #1e293b;
    font-size: 0.85em;
    min-width: 60px;
    text-align: center;
}

/* ===================== ChordPro rendering ===================== */
.chord-line {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 0.4rem;
    line-height: 1.25;
}

.chord-segment {
    display: inline-flex;
    flex-direction: column;
    justify-content: flex-end;
    margin-right: 0;
}

.chord-name {
    font-weight: 700;
    font-size: 0.88em;
    color: #1d4ed8; /* Crisp Blue Chord color */
    min-height: 1.2em;
    white-space: pre;
    user-select: none;
    font-family: monospace, Consolas, "Courier New", monospace;
}

.chord-lyric {
    font-size: 1em;
    min-height: 1.2em;
    white-space: pre;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.lyric-line-plain {
    margin-bottom: 0.35rem;
    white-space: pre-wrap;
    font-size: 1em;
}

.lyric-line-empty {
    height: 0.8rem;
}

/* ===================== View mode tabs ===================== */
.view-mode-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.tab-btn {
    padding: 6px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background-color: #ffffff;
    font-size: 0.9em;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background-color: #f1f5f9;
}

.tab-btn.active {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* ===================== PDF viewer ===================== */
#pdf-container {
    width: 100%;
    margin-top: 10px;
    flex-grow: 1;
    min-height: 600px;
}

#pdf-iframe {
    width: 100%;
    height: 75vh;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ===================== PDF upload controls ===================== */
.admin-pdf-box {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

.btn-upload {
    background-color: #10b981;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
}

.btn-upload:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.status-msg {
    font-size: 0.85em;
    font-weight: 500;
}

/* ===================== Login page ===================== */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #4ea6a3;
    margin: 0;
    font-family: Arial, sans-serif;
    flex-direction: column;
}

.logo-container img {
    width: 500px;
    margin-bottom: 20px;
}

.login-container {
    background-color: white;
    padding: 30px;
    border-radius: 20px;
    width: 300px;
    text-align: center;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
}

.login-container h2 {
    margin-bottom: 20px;
    font-size: 24px;
    color: #333;
}

.login-container input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.login-container button {
    width: 100%;
    padding: 10px;
    background-color: #007f7b;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
}

.login-container button:hover {
    background-color: #4ea6a3;
}

.login-container .error-message {
    color: red;
    margin-top: 10px;
}

/* ===================== Admin page ===================== */

body.admin-page {
    flex-direction: column;
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 20px;
    height: auto;
    overflow-y: auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-header h1 {
    margin: 0;
    color: #333;
}

.admin-header a {
    color: #007BFF;
    text-decoration: none;
}

.admin-header a:hover {
    text-decoration: underline;
}

/* Cards */

.admin-card {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.admin-card h2 {
    margin-top: 0;
    color: #333;
}

/* Flash messages */

.flash-messages {
    margin-bottom: 15px;
}

.flash-success {
    background-color: #d1fae5;
    color: #065f46;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 8px;
}

.flash-danger {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 8px;
}

/* Forms */

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 360px;
}

.form-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    box-sizing: border-box;
}

.perm-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.perm-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
}

/* Tables */

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #555;
}

.admin-table tr:hover {
    background-color: #f8f9fa;
}

.admin-table input,
.admin-table select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.admin-table input[type="text"],
.admin-table input[type="password"] {
    width: 150px;
}

/* Buttons */

.btn-create {
    background-color: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-create:hover {
    background-color: #059669;
}

.btn-save {
    background-color: #007BFF;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-save:hover {
    background-color: #0056b3;
}

.btn-delete {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-delete:hover {
    background-color: #dc2626;
}

.actions-cell {
    white-space: nowrap;
}

/* ===================== Chat panel ===================== */

.chat-panel {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 320px;
    background-color: #ffffff;
    border-left: 1px solid #ddd;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.chat-panel.collapsed {
    transform: translateX(100%);
}

.chat-toggle-btn-floating {
    position: fixed;
    right: 10px;
    top: 10px;
    width: 50px;
    height: 50px;
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    z-index: 99;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle-btn-floating:hover {
    background-color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.2em;
    cursor: pointer;
    padding: 0 8px;
}

.chat-close-btn:hover {
    opacity: 0.8;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #2563eb;
    color: #ffffff;
    border-bottom: 1px solid #ddd;
}

.chat-header h3 {
    margin: 0;
    font-size: 0.95em;
}


.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    background-color: #f9fafb;
}

.chat-message {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message-user {
    background-color: #2563eb;
    color: #ffffff;
    margin-left: 20px;
    text-align: right;
}

.chat-message-assistant {
    background-color: #e5e7eb;
    color: #1f2937;
    margin-right: 20px;
}

.chat-message-error {
    background-color: #fee2e2;
    color: #991b1b;
    margin-right: 20px;
}

.chat-input-area {
    padding: 12px;
    border-top: 1px solid #ddd;
    background-color: #ffffff;
}

#chat-form {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.chat-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
}

.chat-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.chat-send-btn {
    padding: 8px 12px;
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
}

.chat-send-btn:hover {
    background-color: #1d4ed8;
}

.chat-clear-btn {
    width: 100%;
    padding: 6px;
    background-color: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
}

.chat-clear-btn:hover {
    background-color: #dc2626;
}

@media (max-width: 1024px) {
    .chat-panel {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .chat-panel {
        width: 100%;
    }
}