/* common.css or base styles can be imported here */
@import url('common.css');

/* --- General Body and Typography --- */
body {
    font-family: 'Roboto', sans-serif;
    background-color: #f8f9fa;
    color: #212529;
    line-height: 1.6;
    /* Prevent search box jumping during search due to too short list of found songs */
    margin: 0 auto 50em auto;
    padding: 1em; /* Adjusted for mobile */
}

h1 {
    color: #343a40;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 0.5em;
    margin-top: 2em;
    font-weight: 500;
}

a {
    color: #0056b3;
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: #007bff;
    text-decoration: underline;
}

/* --- Songbooks Section --- */
.songbook-container h1 {
    border-bottom: none; /* We will style it differently for mobile */
}

#songbooks {
    list-style: none;
    padding: 0;
}

#songbooks li {
    font-weight: bold;
    margin-top: 1em;
    margin-bottom: 0.5em;
}

#songbooks div {
    margin-bottom: 1em;
}

#songbooks a {
    display: inline-block;
    background-color: #6c757d;
    color: #ffffff;
    padding: 0.4em 0.9em;
    border-radius: 15px;
    font-size: 0.85em;
    margin-right: 0.5em;
    margin-bottom: 0.5em;
    text-transform: uppercase;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#songbooks a:hover {
    background-color: #5a6268;
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-2px);
}

#songbooks a.epub { background-color: #28a745; }
#songbooks a.epub:hover { background-color: #218838; }
#songbooks a.pdf { background-color: #dc3545; }
#songbooks a.pdf:hover { background-color: #c82333; }

/* --- Main Song List --- */
#songs {
    list-style-type: none;
    padding: 0;
    margin-top: 1em;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#songs li {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    padding: 0.8em 1em;
    transition: background-color 0.2s ease;
    cursor: pointer;

    flex-wrap: wrap;      /* Allow items to wrap to the next line */
    gap: 0.5em 0.3em;       /* Add space: 0.5em vertically, 1em horizontally */
}

#songs li:last-child { border-bottom: none; }
#songs li:hover { background-color: #eef2f5; }

/* Main song link wrapper */
#songs li a.song-link {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5em;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

#songs li a.song-link:hover {
    text-decoration: none;
}

#songs li a.song-link .title {
    font-size: 1.1em;
    color: #333;
    font-weight: 400;
}

#songs li a.song-link .alias {
    font-size: 0.9em;
    color: #6c757d;
    font-style: italic;
}

#songs li .alias::before {
    content: '(';
}

#songs li .alias::after {
    content: ')';
}

#songs li a.song-link .artist {
    margin-left: auto; /* This takes up all available space, pushing the element to the end */
    padding-left: 1em; /* Ensures some space between the alias and artist on smaller screens */
    font-size: 0.95em;
    color: #6c757d;
}


#songs li a.song-link:hover .title {
    color: #0056b3;
}

/* --- Edit Icon Button --- */
.editicon {
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 0.05em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.editicon:hover { opacity: 1; }

.editicon .material-symbols-outlined {
    font-size: 20px;
    color: #6c757d;
    transition: color 0.2s ease;
}

.editicon:hover .material-symbols-outlined { color: #007bff; }

/* --- PDF Link Styles --- */
.pdflink {
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 0.05em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    text-decoration: none;
}

.pdflink:hover { 
    opacity: 1;
    text-decoration: none;
}

.pdflink .material-symbols-outlined {
    font-size: 18px;
    color: #6c757d;
    transition: color 0.2s ease;
    margin-right: 2px;
}

.pdflink:hover .material-symbols-outlined { color: #dc3545; }

.pdflink .pdf-label {
    font-size: 0.7em;
    font-weight: 500;
    color: #6c757d;
    transition: color 0.2s ease;
    text-transform: uppercase;
}

.pdflink:hover .pdf-label { color: #dc3545; }

/* --- Kindle Link Paragraph --- */
p {
    margin-top: 1.5em;
    font-style: italic;
    color: #6c757d;
    text-align: center;
}

/* --- Search Box --- */
.search-container {
    background-color: #ffffff;
    padding: 1em 1.5em;
    margin-top: 2em;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    top:5px;
    position: sticky; /* Keeps the search box at the top when scrolling */
    z-index: 1000; /* Ensures it stays above other content */
}

.search-label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 500;
    color: #343a40;
}

#songSearch {
    width: 100%;
    padding: 0.75em;
    font-size: 1em;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
}

/* ==========================================================================
   Mobile Responsive Styles (Screen width <= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    body {
        padding: 0.5em;
        -webkit-text-size-adjust: 100%; /* Prevent font scaling on iOS */
    }

    div.top-navigation {
        align-items: flex-start;
        gap: 0.8em;
    }

    h1 {
        font-size: 1.2em;
        margin-top: 1.2em;
    }

    /* --- Collapsible Songbook --- */
    #songbook-toggle {
        cursor: pointer;
        user-select: none; /* Prevents text selection on tap */
        border-bottom: 2px solid #dee2e6;
        margin-bottom: 0;
        position: relative;
    }

    /* Arrow icon for the toggle */
    #songbook-toggle::after {
        content: '▼';
        font-size: 0.8em;
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        transition: transform 0.3s ease;
    }

    #songbooks-container.expanded #songbook-toggle::after {
        transform: translateY(-50%) rotate(180deg);
    }

    /* Hide songbooks by default on mobile */
    #songbooks-container #songbooks-list-container {
        display: none;
        padding: 1em;
        background-color: #fff;
        border-radius: 0 0 8px 8px;
        box-shadow: inset 0 3px 5px rgba(0,0,0,0.05);
    }

    /* Show when expanded */
    #songbooks-container.expanded #songbooks-list-container {
        display: block;
    }

    p {
        padding: 0 1em;
    }
}

/* ==========================================================================
   Desktop Styles (Screen width > 768px)
   ========================================================================== */
@media (min-width: 769px) {
    body {
        max-width: 960px;
        padding: 2em;
    }

    div.top-navigation {
        padding: 1em 2em;
        gap: 1.5em;
        flex-wrap: nowrap;
    }

    .songbook-container h1 {
         border-bottom: 2px solid #dee2e6;
    }

    #songbook-toggle {
        cursor: default;
    }

    #songbook-toggle::after {
        content: ''; /* Remove arrow on desktop */
    }
}