/* Song View Page Styles */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    background: #f8f9fa;
    color: #212529;
    line-height: 1.6;
}

/* Song Header Section */
.song-header {
    background: white;
    padding: 2rem 0;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

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

.song-info {
    margin-bottom: 1.5rem;
}

.song-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #212529;
}

.song-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #6c757d;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.author-link {
    color: #4285f4;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author-link:hover {
    text-decoration: underline;
}

.author-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e9ecef;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
}

.author-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.song-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary {
    background: #4285f4;
    color: white;
}

.btn-primary:hover {
    background: #357ae8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66,133,244,0.3);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    background: #ffc107;
    color: #856404;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Main Content Grid */
.main-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    margin: 2rem auto;
    max-width: 100%;
    width: 100%;
    padding: 0 20px;
}

/* Song Display Panel */
.song-display {
    background: white;
    border-radius: 8px;
    padding: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-height: 500px;
    overflow: hidden;
}

/* Controls Section */
.controls {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.transpose-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.transpose-controls button {
    width: 32px;
    height: 32px;
    border: 1px solid #ced4da;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.transpose-controls button:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.transpose-value {
    min-width: 3rem;
    text-align: center;
    font-weight: 600;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
}

.btn-sm:hover {
    background: #dee2e6;
    border-color: #adb5bd;
}

/* Capo button and secondary buttons in controls should be grey */
.controls .btn.btn-secondary.btn-sm,
.controls button.btn.btn-secondary.btn-sm {
    background: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    margin-left: 0;
}

.controls .btn.btn-secondary.btn-sm:hover,
.controls button.btn.btn-secondary.btn-sm:hover {
    background: #dee2e6;
    border-color: #adb5bd;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sidebar-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: #495057;
}

.stats-list {
    list-style: none;
}

.stats-list li {
    padding: 0.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
}

.stats-list li:last-child {
    border-bottom: none;
}

.stats-label {
    color: #6c757d;
    font-size: 0.875rem;
}

.stats-value {
    font-weight: 600;
    color: #212529;
}

.related-songs {
    list-style: none;
}

.related-songs li {
    margin-bottom: 0.75rem;
}

.related-songs a {
    color: #495057;
    text-decoration: none;
    font-size: 0.875rem;
    display: block;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.related-songs a:hover {
    background: #f8f9fa;
    color: #212529;
}

.related-songs small {
    color: #6c757d;
}

/* Song Content Styles */
.song-content {
    font-size: calc(1rem * var(--editor-text-scale, 1));
    line-height: 1.8;
    color: #212529;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
}

.song-content p {
    margin-bottom: 0.75em;
}

.song-content p:empty {
    min-height: 1.8em;
}

/* Chord and Section Highlighting - MUST match editor styles */
.chord-highlight {
    color: #0066cc;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace;
    display: inline;
}

.section-label {
    color: #ff9900;
    font-weight: bold;
    display: block;
    margin: 5px 0;
    padding: 0;
    font-size: 1.0625rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Translation Bar */
.translation-bar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 0;
    position: relative;
    overflow: hidden;
}

.translation-bar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    flex-wrap: wrap;
}

.translation-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.current-language {
    background: linear-gradient(135deg, #FFD700, #FFC107);
    color: #333;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.current-language::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

.flag-icon {
    width: 20px;
    height: 15px;
    margin-right: 0.5rem;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 0 1px rgba(0,0,0,0.2);
    display: inline-block;
    background: #e9ecef;
    position: relative;
    z-index: 1;
}

.translation-separator {
    color: #6c757d;
    flex-shrink: 0;
}

.translation-label {
    color: #6c757d;
    font-size: 0.875rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.translation-links-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
    margin: 0 1rem;
    max-width: 600px;
    min-width: 0;
}

.translation-links {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    padding: 0.25rem 0;
    white-space: nowrap;
}

.translation-links::-webkit-scrollbar {
    display: none;
}

/* Toggle button + drawer: hidden on desktop, shown on mobile only */
.translation-toggle { display: none; }
.translation-drawer { display: none; }

.translation-link {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    text-decoration: none;
    color: #495057;
    font-size: 0.875rem;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
}

.translation-link:hover {
    background: #e3f2fd;
    border-color: #90caf9;
    color: #1976d2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.translation-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.btn-manage-translations {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.btn-manage-translations::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-manage-translations:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4);
}

.btn-manage-translations:hover::before {
    opacity: 1;
}

.btn-manage-translations .icon,
.btn-manage-translations span {
    position: relative;
    z-index: 1;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    color: white;
    font-size: 1rem;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    transform: translateY(20px);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.toast.success {
    background-color: #28a745;
}

.toast.error {
    background-color: #dc3545;
}

.toast.info {
    background-color: #17a2b8;
}

/* Print Styles */
@media print {
    @page {
        size: letter;
        margin: 0.5in; /* Standard margins */
    }
    
    /* Hide UI elements */
    .site-header,
    .nav-container,
    nav,
    .song-header,
    .song-actions,
    .song-controls,
    .controls-wrapper,
    .transpose-controls,
    .action-controls,
    .translations-section,
    .sidebar,
    .btn,
    .translation-bar,
    footer {
        display: none !important;
    }
    
    /* Reset body and html */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 11pt !important; /* Reduced from default */
        line-height: 1.5 !important;
    }
    
    /* Main content adjustments */
    .song-container,
    .song-content-wrapper,
    .container,
    .main-content {
        display: block !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        grid-template-columns: 1fr !important;
    }
    
    .song-display {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Add title before content */
    .song-display::before {
        content: attr(data-print-title) !important;
        display: block !important;
        font-size: 16pt !important; /* Reduced from 18pt */
        font-weight: bold !important;
        margin-bottom: 0.75em !important;
        text-align: center !important;
        page-break-after: avoid !important;
    }
    
    /* Song content text sizing */
    .song-text,
    #song-content {
        font-size: 10pt !important; /* Smaller font for content */
        line-height: 1.4 !important;
    }
    
    /* Chord highlights */
    .chord-highlight {
        color: black !important;
        font-weight: bold !important;
        font-size: 9pt !important; /* Slightly smaller than text */
        font-family: 'Courier New', Courier, monospace !important;
    }
    
    /* Section labels */
    .section-label {
        color: black !important;
        font-weight: bold !important;
        font-size: 11pt !important; /* Reduced from default */
        display: block !important;
        margin: 5px 0 !important;
        padding: 0 !important;
        page-break-after: avoid !important;
    }
    
    /* Paragraphs and line breaks */
    .song-display p,
    #song-content p {
        margin: 0 0 0.25em 0 !important;
        page-break-inside: avoid !important;
    }
    
    .song-display br,
    #song-content br {
        height: 0.25em !important;
    }
}

/* Mobile Responsive */
@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 0; /* Remove padding on mobile */
    }
    
    .main-content .container {
        max-width: 100%;
        padding: 0; /* Remove container padding */
    }
    
    .song-display {
        width: 100%;
        margin: 0;
        border-radius: 0; /* Remove border radius for full width */
        box-shadow: none; /* Remove shadow for cleaner look */
    }
    
    .sidebar {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
        padding: 0 1rem; /* Add some padding to sidebar */
    }
}

@media (max-width: 768px) {
    /* Add padding to body to account for fixed navigation */
    body {
        padding-top: 60px;
    }
    
    /* Make container full width on mobile */
    .main-content {
        margin: 0;
        padding: 0;
        grid-template-columns: 1fr;
    }
    
    .main-content .container {
        max-width: 100%;
        padding: 0;
    }
    
    /* Song header mobile adjustments */
    .song-header {
        padding: 1rem 0;
    }
    
    .song-header .container {
        padding: 0 1rem;
    }
    
    .song-title {
        font-size: 1.5rem;
    }
    
    .song-meta {
        font-size: 0.75rem;
        flex-wrap: wrap;
    }
    
    .song-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    
    .btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Full width song display on mobile */
    .song-display {
        width: 100%;
        padding: 0;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        background: white;
    }
    
    /* Controls section */
    .controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin: 0;
        padding: 0.75rem 1rem;
        border-radius: 0;
        background: #f8f9fa;
        border-bottom: 1px solid #dee2e6;
    }
    
    .transpose-controls {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .transpose-controls button {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
    
    .transpose-value {
        min-width: 2rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        margin-left: auto;
        margin-top: 0;
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Full width song content */
    .song-content,
    #song-content {
        margin: 0;
        padding: 1rem;
        width: 100%;
        font-size: 0.95rem;
        line-height: 1.7;
    }
    
    /* Chord and section adjustments */
    .chord-highlight {
        font-size: 0.875rem;
    }
    
    .section-label {
        font-size: 1rem;
        margin: 5px 0;
        padding: 0;
    }
    
    /* Translation bar mobile optimizations */
    .translation-bar {
        padding: 0.75rem 0;
        margin-top: 0;
    }
    
    .translation-bar-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0 1rem;
    }
    
    /* Mobile: whole translation-info scrolls as one row */
    .translation-info {
        width: 100%;
        flex-wrap: nowrap;
        gap: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .translation-info::-webkit-scrollbar { display: none; }

    .current-language {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        flex-shrink: 0;
    }

    .translation-separator,
    .translation-label {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .translation-links-wrapper {
        width: auto;
        margin: 0;
        max-width: none;
        flex-shrink: 0;
        position: relative;
    }

    .translation-links {
        gap: 0.5rem;
        flex-wrap: nowrap;
        overflow: visible;
    }

    /* Hide the scroll arrow — whole bar scrolls now */
    .scroll-arrow-right { display: none; }

    .translation-link {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        flex-shrink: 0;
    }

    /* Mobile toggle button — visible only on mobile */
    .translation-toggle {
        display: flex;
        align-items: center;
        gap: 4px;
        background: #f0f4ff;
        border: 1px solid #c8d8ff;
        border-radius: 16px;
        padding: 0.25rem 0.6rem;
        font-size: 0.75rem;
        color: #1976d2;
        cursor: pointer;
        white-space: nowrap;
        flex-shrink: 0;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    .translation-toggle:active {
        background: #dce8ff;
    }
    .translation-toggle .toggle-arrow {
        font-size: 0.6rem;
        transition: transform 0.2s;
        display: inline-block;
    }
    .translation-toggle.open .toggle-arrow {
        transform: rotate(180deg);
    }

    /* Collapsible drawer — hidden by default, shown when toggled */
    .translation-drawer {
        display: none;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.6rem 1rem 0.75rem;
        background: #f8f9ff;
        border-top: 1px solid #e0e6f0;
    }
    .translation-drawer.open {
        display: flex;
    }
    .translation-drawer .translation-link {
        font-size: 0.8rem;
        padding: 0.3rem 0.65rem;
    }

    /* Hide inline pills when drawer is open */
    .translation-info.drawer-open .translation-links-wrapper { display: none; }
    .translation-info.drawer-open .translation-separator,
    .translation-info.drawer-open .translation-label { display: none; }

    .translation-actions {
        width: 100%;
    }
    
    .btn-manage-translations {
        width: 100%;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Sidebar adjustments */
    .sidebar {
        width: 100%;
        padding: 1rem;
        margin-top: 2rem;
        display: block;
    }
    
    .sidebar-section {
        margin-bottom: 1.5rem;
        padding: 1rem;
    }
    
    .sidebar-section h3 {
        font-size: 0.875rem;
        margin-bottom: 0.75rem;
    }
    
    .stats-list {
        font-size: 0.875rem;
    }
    
    .stats-list li {
        padding: 0.375rem 0;
    }
    
    .related-songs {
        font-size: 0.875rem;
    }
    
    .related-songs li {
        margin-bottom: 0.5rem;
    }
    
    .related-songs a {
        padding: 0.375rem;
        font-size: 0.8125rem;
    }
    
    /* Toast notification adjustments */
    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    /* Print button adjustments */
    #print-button,
    .print-btn {
        min-width: auto;
        padding: 0.5rem;
    }
    
    /* Modal adjustments for mobile */
    .modal-content {
        width: 95%;
        margin: 1rem;
        max-height: 90vh;
    }
    
    .modal-content.modal-lg {
        width: 95%;
    }
    
    /* Flag icons */
    .flag-icon {
        width: 16px;
        height: 12px;
        margin-right: 0.25rem;
    }
}