* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: #f8f9fa;
    color: #212529;
}

.top-nav-bar {
    display: flex;
    gap: 15px;
    padding: 10px 24px;
    font-size: 0.9em;
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.top-nav-bar a {
    color: #495057;
    text-decoration: none;
    transition: color 0.2s;
}

.top-nav-bar a:hover {
    color: #2e7d32;
    text-decoration: underline;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h1 {
    margin: 0 0 10px 0;
    color: #212529;
    font-size: 2em;
}

.subtitle {
    color: #6c757d;
    margin: 0;
}

.songbook-description {
    margin-bottom: 20px;
}

.song-selection-header {
    background: white;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.song-selection-header h2 {
    margin: 0;
    color: #343a40;
    font-size: 1.5em;
}

.layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: start;
}

.layout .panel {
    border-radius: 8px;
}

.layout .panel h3 {
    margin-top: 0;
    color: #343a40;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 10px;
    font-size: 1.3em;
}

.arrow-separator {
    width: 30px;
    height: 100%;
    position: relative;
    display: flex;
    align-items: start;
    justify-content: center;
    padding-top: 80px;
}

.arrow-separator::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    border-left: 20px solid #007bff;
}

@media (max-width: 968px) {
    .layout {
        grid-template-columns: 1fr;
    }
    
    .arrow-separator {
        width: 100%;
        height: 30px;
        transform: rotate(90deg);
    }
}

.panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.panel h2 {
    margin-top: 0;
    color: #343a40;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 10px;
}

.search-box {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 15px;
    transition: border-color 0.2s;
}

.search-box:focus {
    outline: none;
    border-color: #007bff;
}

.filter-section {
    margin-bottom: 15px;
}

.filter-section label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.filter-section select {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
}

.stats {
    background: #e9ecef;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
}

.song-list {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.song-item {
    padding: 10px 15px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s;
}

.song-item:hover {
    background-color: #f8f9fa;
}

.song-item:last-child {
    border-bottom: none;
}

.song-item.selected {
    background-color: #e7f3ff;
}

.song-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.song-info {
    flex: 1;
}

.song-title {
    font-weight: 500;
    color: #212529;
}

.song-title a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.song-title a:hover {
    color: #0056b3;
    border-bottom-color: #0056b3;
}

.song-title a::after {
    content: '↗';
    font-size: 0.8em;
    margin-left: 4px;
    opacity: 0.6;
}

.song-meta {
    font-size: 12px;
    color: #6c757d;
    margin-top: 2px;
}

/* Aggregated items (artists, text_authors, genres) */
.aggregated-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
    background: linear-gradient(to right, #f8f9fa 0%, #ffffff 100%);
    border-left: 4px solid transparent;
}

.aggregated-item:hover {
    background: linear-gradient(to right, #e9ecef 0%, #f8f9fa 100%);
}

.aggregated-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.aggregated-item.artist-item {
    border-left-color: #007bff;
}

.aggregated-item.artist-item:hover {
    background: linear-gradient(to right, #cfe2ff 0%, #e7f1ff 100%);
}

.aggregated-item.text-author-item {
    border-left-color: #28a745;
}

.aggregated-item.text-author-item:hover {
    background: linear-gradient(to right, #d4edda 0%, #e9f7ec 100%);
}

.aggregated-item.genre-item {
    border-left-color: #ffc107;
}

.aggregated-item.genre-item:hover {
    background: linear-gradient(to right, #fff3cd 0%, #fff9e6 100%);
}

.aggregated-item .material-symbols-outlined {
    font-size: 24px;
    color: #6c757d;
}

.aggregated-item .item-info {
    flex: 1;
}

.aggregated-item .item-title {
    font-weight: 600;
    color: #212529;
    font-size: 14px;
}

.aggregated-item .item-meta {
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
    font-style: italic;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #495057;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* Dynamic Filters */
#dynamicFiltersList {
    margin-top: 10px;
}

.filter-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
}

.filter-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.filter-controls select {
    padding: 6px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    background: white;
}

.filter-controls input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 6px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
}

.filter-match-count {
    font-size: 12px;
    color: #28a745;
    font-weight: 500;
    margin-top: 5px;
}

.selected-songs {
    margin-top: 15px;
    max-height: 600px;
    overflow-y: auto;
}

.selection-summary {
    background: #e7f3ff;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 13px;
}

.filter-summary {
    padding: 4px 0;
    color: #495057;
}

.final-song-list {
    margin-top: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
}

.final-song-list summary {
    padding: 10px;
    cursor: pointer;
    background: #f8f9fa;
    user-select: none;
}

.final-song-list summary:hover {
    background: #e9ecef;
}

.final-songs-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.final-song-item {
    padding: 6px 10px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.final-song-item:last-child {
    border-bottom: none;
}

.final-song-item .song-number {
    color: #6c757d;
    font-weight: 500;
    min-width: 30px;
}

.final-song-item .song-title {
    flex: 1;
    color: #212529;
}

.final-song-item .song-title a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.final-song-item .song-title a:hover {
    color: #0056b3;
    border-bottom-color: #0056b3;
}

.final-song-item .song-title a::after {
    content: '↗';
    font-size: 0.8em;
    margin-left: 4px;
    opacity: 0.6;
}

.final-song-item .remove-song-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.final-song-item .remove-song-btn:hover {
    background: #c82333;
}

.final-song-item .filter-badge {
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
}

.selected-song {
    background: #f8f9fa;
    padding: 8px 12px;
    margin-bottom: 5px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.remove-btn:hover {
    background: #c82333;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

.btn-primary {
    background: #007bff;
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    flex: 1;
}

.btn-secondary:hover {
    background: #5a6268;
}

.output-area {
    margin-top: 15px;
}

.output-area textarea {
    width: 100%;
    min-height: 300px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.batch-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.batch-actions button {
    padding: 6px 12px;
    font-size: 13px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.loader {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.file-upload {
    background: #fff3cd;
    border: 2px dashed #ffc107;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload label {
    display: inline-block;
    padding: 10px 20px;
    background: #ffc107;
    color: #212529;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.file-upload label:hover {
    background: #e0a800;
}

.dynamic-filters {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #dee2e6;
}

.dynamic-filters h3 {
    font-size: 1em;
    margin: 0 0 10px 0;
    color: #495057;
}

.filter-item {
    background: #f8f9fa;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.filter-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.filter-item select,
.filter-item input {
    width: 100%;
    padding: 6px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 5px;
}

.filter-remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
}

.filter-remove-btn:hover {
    background: #c82333;
}

.add-filter-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    width: 100%;
}

.add-filter-btn:hover {
    background: #218838;
}

/* ==========================================================================
   Header Auth & Cloud Actions (Phase 3)
   ========================================================================== */

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-titles {
    flex: 1;
    min-width: 250px;
}

.header-auth {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-auth {
    background: white;
    border: 1px solid #dadce0;
    color: #3c4043;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(60,64,67,0.1);
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-auth:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(60,64,67,0.2);
}

.btn-auth .material-symbols-outlined {
    font-size: 20px;
    color: #1a73e8;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f1f3f4;
    padding: 6px 14px;
    border-radius: 24px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-avatar-initials {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: #202124;
}

.user-menu-links {
    font-size: 12px;
    color: #5f6368;
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: #1a73e8;
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
}

.btn-link:hover {
    color: #0d47a1;
}

.user-menu-links .sep {
    color: #aaa;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.action-group-cloud,
.action-group-file {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-success {
    background: #28a745;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-success:hover {
    background: #218838;
}

.btn-outline {
    background: transparent;
    border: 1px solid #ced4da;
    color: #495057;
}

.btn-outline:hover {
    background: #e9ecef;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn .material-symbols-outlined {
    font-size: 18px;
    vertical-align: middle;
}

.cloud-status-badge {
    font-size: 13px;
    font-weight: 500;
    color: #28a745;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25em;
    color: #333;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
    line-height: 1;
}

.modal-close-btn:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Songbook card in modal list */
.songbook-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    transition: box-shadow 0.2s;
    background: #fff;
}

.songbook-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.songbook-card-info {
    flex: 1;
}

.songbook-card-title {
    font-weight: 600;
    font-size: 1.05em;
    color: #1a73e8;
    cursor: pointer;
}

.songbook-card-meta {
    font-size: 0.85em;
    color: #666;
    margin-top: 4px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.songbook-card-actions {
    display: flex;
    gap: 8px;
}

.badge-public {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-private {
    background: #fff3e0;
    color: #ef6c00;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* Collaborators list */
.collaborator-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 13px;
}

.collaborator-role {
    font-weight: 600;
    color: #666;
    margin-left: 8px;
    font-size: 11px;
    text-transform: uppercase;
}

/* Publication Modal & Steps */
.publish-steps-list {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.publish-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.publish-step .step-icon {
    font-size: 1.3rem;
    color: #adb5bd;
}

.publish-step .step-text {
    flex: 1;
    font-weight: 500;
    color: #495057;
}

.publish-step .step-status {
    font-size: 0.85em;
    color: #6c757d;
}

.publish-step.running {
    background: #eef6ff;
    border-color: #b6d4fe;
}
.publish-step.running .step-icon {
    color: #0d6efd;
    animation: spin 1.5s linear infinite;
}
.publish-step.running .step-status {
    color: #0d6efd;
    font-weight: 500;
}

.publish-step.success {
    background: #e8f5e9;
    border-color: #c8e6c9;
}
.publish-step.success .step-icon {
    color: #2e7d32;
}
.publish-step.success .step-status {
    color: #2e7d32;
    font-weight: 600;
}

.publish-step.error {
    background: #fdf2f2;
    border-color: #fecaca;
}
.publish-step.error .step-icon {
    color: #dc3545;
}
.publish-step.error .step-status {
    color: #dc3545;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Download Badges for Publication Modal */
.badge-download {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    transition: all 0.15s ease;
}
.badge-download .material-symbols-outlined {
    font-size: 1.1rem;
}
.badge-download.badge-epub {
    background-color: #e8f5e9;
    color: #1b5e20 !important;
    border: 1px solid #c8e6c9;
}
.badge-download.badge-epub:hover {
    background-color: #c8e6c9;
    transform: translateY(-1px);
}
.badge-download.badge-pdf-a5 {
    background-color: #fdf2f2;
    color: #991b1b !important;
    border: 1px solid #fecaca;
}
.badge-download.badge-pdf-a5:hover {
    background-color: #fee2e2;
    transform: translateY(-1px);
}
.badge-download.badge-pdf-a4 {
    background-color: #f1f5f9;
    color: #334155 !important;
    border: 1px solid #cbd5e1;
}
.badge-download.badge-pdf-a4:hover {
    background-color: #e2e8f0;
    transform: translateY(-1px);
}

