* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;

    background: #f5f6f8;
    color: #222;

    font-family: Arial, Helvetica, sans-serif;
}


/* -------------------------
   Main Container
------------------------- */

.container {
    width: 100%;
    max-width: 700px;

    margin: 0 auto;

    padding: 20px;
}


/* -------------------------
   Header
------------------------- */

.main-header {
    display: flex;

    flex-direction: column;

    gap: 18px;

    margin-bottom: 24px;
}

.main-header h1 {
    margin: 0 0 6px;

    font-size: 28px;
}

.subtitle {
    margin: 0;

    color: #666;

    line-height: 1.5;
}


/* -------------------------
   Add Song Button
------------------------- */

.add-song-button {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;
    min-height: 50px;

    padding: 12px 18px;

    border-radius: 10px;

    background: #222;
    color: #ffffff;

    text-decoration: none;

    font-size: 16px;
    font-weight: 700;
}

.add-song-button:hover {
    background: #000;
}


/* -------------------------
   Search
------------------------- */

.search-form {
    margin-bottom: 26px;
}

.search-wrapper {
    display: flex;

    width: 100%;

    gap: 8px;
}

.search-wrapper input {
    flex: 1;

    min-width: 0;

    min-height: 50px;

    padding: 12px 14px;

    border: 1px solid #d1d5db;
    border-radius: 10px;

    background: #ffffff;

    color: #222;

    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;

    outline: none;
}

.search-wrapper input:focus {
    border-color: #555;

    box-shadow:
        0 0 0 3px rgba(0, 0, 0, 0.08);
}

.search-button {
    min-height: 50px;

    padding: 12px 16px;

    border: none;
    border-radius: 10px;

    background: #444;
    color: #ffffff;

    font-size: 16px;
    font-weight: 700;

    cursor: pointer;
}

.search-button:hover {
    background: #222;
}

.clear-search {
    display: inline-block;

    margin-top: 10px;

    color: #555;

    font-size: 14px;

    text-decoration: none;
}

.clear-search:hover {
    text-decoration: underline;
}


/* -------------------------
   Songs Section
------------------------- */

.songs-section {
    width: 100%;
}

.section-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    margin-bottom: 12px;
}

.section-header h2 {
    margin: 0;

    font-size: 20px;
}

.song-count {
    color: #777;

    font-size: 14px;
}


/* -------------------------
   Song List
------------------------- */

.song-list {
    display: flex;

    flex-direction: column;

    gap: 10px;
}


/* -------------------------
   Song Card
------------------------- */

.song-card {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 17px;

    background: #ffffff;

    border-radius: 12px;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06);
}

.song-card-main {
    min-width: 0;
}

.song-title {
    margin: 0 0 6px;

    font-size: 17px;

    line-height: 1.35;

    overflow-wrap: anywhere;
}

.song-leader {
    margin: 0;

    color: #666;

    font-size: 14px;
}

.song-key {
    flex-shrink: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    min-width: 48px;
    min-height: 48px;

    padding: 8px;

    border-radius: 10px;

    background: #f0f1f3;

    font-size: 17px;
    font-weight: 700;

    text-align: center;
}


/* -------------------------
   Empty State
------------------------- */

.empty-state {
    padding: 30px 20px;

    background: #ffffff;

    border-radius: 12px;

    text-align: center;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06);
}

.empty-title {
    margin-bottom: 8px;

    font-size: 18px;
    font-weight: 700;
}

.empty-state p {
    margin: 0 0 18px;

    color: #666;

    line-height: 1.5;
}

.empty-link {
    color: #222;

    font-weight: 700;

    text-decoration: none;
}

.empty-link:hover {
    text-decoration: underline;
}


/* -------------------------
   Add Song Form
------------------------- */

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    margin-top: 18px;
}

.back-link {
    display: inline-block;

    padding: 8px 0;

    color: #333;

    text-decoration: none;

    font-weight: 600;
}

.back-link:hover {
    text-decoration: underline;
}


/* -------------------------
   Messages
------------------------- */

.message {
    padding: 15px;

    margin-bottom: 20px;

    border-radius: 10px;

    line-height: 1.5;
}

.message-title {
    margin-bottom: 4px;

    font-weight: 700;
}

.success-message {
    background: #e8f7ed;
    color: #217a3b;

    border: 1px solid #b9e4c5;
}

.error-message {
    background: #fdecec;
    color: #a12626;

    border: 1px solid #f2b8b8;
}


/* -------------------------
   Form
------------------------- */

.song-form {
    background: #ffffff;

    border-radius: 16px;

    padding: 20px;

    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.08);
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;

    margin-bottom: 8px;

    font-size: 16px;
    font-weight: 700;
}


/* -------------------------
   Inputs
------------------------- */

input[type="text"],
input[type="search"],
select,
textarea {
    width: 100%;

    border: 1px solid #d1d5db;

    border-radius: 10px;

    background: #ffffff;
    color: #222;

    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;

    padding: 13px 14px;

    outline: none;

    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

input[type="text"],
select {
    min-height: 50px;
}

textarea {
    min-height: 110px;

    resize: vertical;

    line-height: 1.5;
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: #555;

    box-shadow:
        0 0 0 3px rgba(0, 0, 0, 0.08);
}


/* -------------------------
   File Input
------------------------- */

input[type="file"] {
    width: 100%;

    padding: 12px;

    border: 1px dashed #aaa;

    border-radius: 10px;

    background: #fafafa;

    cursor: pointer;

    font-size: 16px;
}


/* -------------------------
   Help Text
------------------------- */

.field-help {
    margin: -2px 0 10px;

    color: #666;

    font-size: 14px;

    line-height: 1.5;
}


/* -------------------------
   Image Preview
------------------------- */

.image-preview-container {
    margin-bottom: 22px;
}

.preview-label {
    margin: 0 0 8px;

    font-weight: 700;
}

.image-preview {
    display: block;

    width: 100%;
    max-height: 500px;

    object-fit: contain;

    border-radius: 10px;

    border: 1px solid #ddd;

    background: #f5f5f5;
}


/* -------------------------
   Primary Button
------------------------- */

.btn-primary {
    display: block;

    width: 100%;

    min-height: 52px;

    padding: 14px 20px;

    border: none;

    border-radius: 10px;

    background: #222;
    color: #ffffff;

    font-size: 17px;
    font-weight: 700;

    cursor: pointer;
}

.btn-primary:hover {
    background: #000;
}

.btn-primary:active {
    transform: scale(0.99);
}


/* -------------------------
   Database Status
------------------------- */

.status {
    padding: 14px;

    border-radius: 10px;

    font-weight: 600;
}

.success {
    background: #e8f7ed;

    color: #217a3b;
}

.database-name {
    margin-top: 20px;

    color: #555;
}


/* -------------------------
   Desktop
------------------------- */

@media (min-width: 768px) {

    .container {
        padding-top: 50px;
        padding-bottom: 50px;
    }

    .main-header {
        flex-direction: row;

        align-items: center;
        justify-content: space-between;
    }

    .add-song-button {
        width: auto;

        padding-left: 24px;
        padding-right: 24px;
    }

    .song-form {
        padding: 28px;
    }

}

/* =========================================================
   PHASE 6 - SONG DETAILS
========================================================= */


/* -------------------------
   Clickable Song Card
------------------------- */

.song-card {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;

    width: 100%;

    padding: 17px;

    background: #ffffff;

    border-radius: 12px;

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.06);

    color: #222;

    text-decoration: none;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.song-card:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.10);
}

.song-card:active {
    transform: scale(0.99);
}


/* -------------------------
   Details Page
------------------------- */

.details-container {
    padding-bottom: 40px;
}

.details-header {
    margin-bottom: 18px;
}


/* -------------------------
   Song Details Card
------------------------- */

.song-details-card {
    background: #ffffff;

    border-radius: 16px;

    padding: 20px;

    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.08);
}


/* -------------------------
   Song Title
------------------------- */

.song-details-title {
    padding-bottom: 20px;

    border-bottom: 1px solid #eeeeee;
}

.song-details-title h1 {
    margin: 0;

    font-size: 28px;

    line-height: 1.25;

    overflow-wrap: anywhere;
}


/* -------------------------
   Song Metadata
------------------------- */

.song-meta {
    display: flex;

    flex-direction: column;

    gap: 16px;

    padding: 20px 0;

    border-bottom: 1px solid #eeeeee;
}

.meta-item {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;
}

.meta-label {
    color: #666;

    font-size: 14px;

    font-weight: 600;
}

.meta-value {
    color: #222;

    font-size: 16px;

    font-weight: 700;

    text-align: right;
}

.song-key-large {
    display: flex;

    align-items: center;
    justify-content: center;

    min-width: 52px;
    min-height: 52px;

    padding: 8px 12px;

    border-radius: 10px;

    background: #f0f1f3;

    color: #222;

    font-size: 20px;

    font-weight: 700;
}


/* -------------------------
   Chord Sections
------------------------- */

.chord-section {
    padding: 22px 0;

    border-bottom: 1px solid #eeeeee;
}

.chord-section h2,
.image-section h2 {
    margin: 0 0 12px;

    font-size: 15px;

    letter-spacing: 0.4px;

    color: #555;
}


/* -------------------------
   Chord Content
------------------------- */

.chord-content {
    padding: 16px;

    min-height: 55px;

    background: #f7f7f8;

    border-radius: 10px;

    color: #222;

    font-family:
        "Courier New",
        Courier,
        monospace;

    font-size: 18px;

    font-weight: 600;

    line-height: 1.7;

    overflow-wrap: anywhere;

    white-space: normal;
}


/* -------------------------
   Missing Chords
------------------------- */

.not-provided {
    color: #999;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 14px;

    font-style: italic;

    font-weight: 400;
}


/* -------------------------
   Handwritten Image
------------------------- */

.image-section {
    padding: 22px 0 5px;
}

.handwritten-image-wrapper {
    width: 100%;

    overflow: auto;

    border-radius: 10px;

    background: #eeeeee;

    /*
     * Prevent the image from being
     * larger than the phone screen
     * initially.
     */
    text-align: center;

    /*
     * Allow touch scrolling/zoom behavior.
     */
    -webkit-overflow-scrolling: touch;
}

.handwritten-image {
    display: block;

    width: 100%;

    height: auto;

    max-width: 100%;

    border-radius: 10px;

    /*
     * Keep the original image quality
     * as much as possible.
     */
    object-fit: contain;

    /*
     * Allow the browser to handle
     * pinch/gesture interaction.
     */
    touch-action: pinch-zoom;

    cursor: zoom-in;
}

.image-help {
    margin: 10px 0 0;

    color: #777;

    font-size: 13px;

    text-align: center;
}

.image-not-provided {
    padding: 16px;

    background: #f7f7f8;

    border-radius: 10px;
}


/* -------------------------
   Back Button
------------------------- */

.back-button {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;

    min-height: 50px;

    margin-top: 18px;

    padding: 12px 18px;

    border-radius: 10px;

    background: #222;

    color: #ffffff;

    text-decoration: none;

    font-size: 16px;

    font-weight: 700;
}

.back-button:hover {
    background: #000;
}


/* -------------------------
   Desktop Details
------------------------- */

@media (min-width: 768px) {

    .details-container {
        max-width: 700px;
    }

    .song-details-card {
        padding: 28px;
    }

    .song-details-title h1 {
        font-size: 32px;
    }

    .song-meta {
        flex-direction: row;

        justify-content: space-between;

        gap: 30px;
    }

    .meta-item {
        flex: 1;
    }

}

/* =========================================================
   PHASE 7 - EDIT AND DELETE
========================================================= */


/* -------------------------
   Song Actions
------------------------- */

.song-actions {
    display: flex;

    flex-direction: column;

    gap: 10px;

    padding: 20px 0;

    border-bottom: 1px solid #eeeeee;
}


/* -------------------------
   Edit Button
------------------------- */

.edit-button {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;

    min-height: 50px;

    padding: 12px 18px;

    border-radius: 10px;

    background: #222;

    color: #ffffff;

    text-decoration: none;

    font-size: 16px;

    font-weight: 700;
}

.edit-button:hover {
    background: #000;
}


/* -------------------------
   Delete Form
------------------------- */

.delete-form {
    width: 100%;

    margin: 0;

    padding: 0;
}


/* -------------------------
   Delete Button
------------------------- */

.delete-button {
    display: block;

    width: 100%;

    min-height: 50px;

    padding: 12px 18px;

    border: 1px solid #c62828;

    border-radius: 10px;

    background: #ffffff;

    color: #c62828;

    font-size: 16px;

    font-weight: 700;

    cursor: pointer;
}

.delete-button:hover {
    background: #fff1f1;
}


/* -------------------------
   Current Image
------------------------- */

.current-image-wrapper {
    width: 100%;

    padding: 10px;

    border-radius: 10px;

    background: #f5f5f5;

    text-align: center;

    overflow: auto;
}

.current-handwritten-image {
    display: block;

    width: 100%;

    max-width: 100%;

    height: auto;

    max-height: 500px;

    margin: 0 auto;

    object-fit: contain;

    border-radius: 8px;
}


/* -------------------------
   Desktop Actions
------------------------- */

@media (min-width: 768px) {

    .song-actions {
        flex-direction: row;
    }

    .edit-button,
    .delete-form {
        flex: 1;
    }

}