/**
 * SP Reader Features Styles
 * Mobile-first responsive design
 */

/* ============================================
   Chapter Navigation Bar
   ============================================ */
   
   /**
 * SP Reader Features Styles
 * Mobile-first responsive design
 */

/* Force navigation to be full width and clear floats */

.sp-chapter-nav {
    clear: both !important;
    display: block !important;
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin: 2rem 0;
    padding: 1rem 0;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    background: #fafafa;
    overflow: visible !important; /* ADD THIS - allow dropdown to overflow */
}

.sp-chapter-nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    gap: 1rem;
    overflow: visible !important; /* ADD THIS */
}

/* ============================================
   Navigation Buttons (Prev/Next)
   ============================================ */

.sp-nav-left,
.sp-nav-right {
    flex: 0 0 auto;
    min-width: 80px;
}

.sp-nav-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.sp-nav-button:hover {
    background: #f0f0f0;
    border-color: #999;
    color: #000;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sp-nav-button i {
    font-size: 0.9rem;
}

/* Hide labels on mobile */
.sp-nav-label {
    display: none;
}

@media (min-width: 640px) {
    .sp-nav-label {
        display: inline;
    }
}

/* ============================================
   Center Actions (Claps & Bookmarks)
   ============================================ */

.sp-nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex: 1 1 auto;
    overflow: visible !important; /* ADD THIS */
}

/* ============================================
   Clap Button
   ============================================ */

.sp-clap-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sp-clap-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 50px;
    color: #666;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.sp-clap-button:hover:not(:disabled) {
    color: inherit; /* Keep the icon color */
    background: #f9f9f9;
    border-color: #999;
    transform: scale(1.05);
}

.sp-clap-button:active:not(:disabled) {
    transform: scale(0.95);
}

.sp-clap-button.has-clapped {
    background: #4CAF50;
    border-color: #4CAF50;
    color: #ffffff;
}

.sp-clap-button.has-clapped:hover:not(:disabled) {
    background: #45a049;
    border-color: #45a049;
}

.sp-clap-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sp-clap-button i {
    font-size: 1.2rem;
}

.sp-clap-count {
    font-size: 0.95rem;
    min-width: 20px;
    text-align: center;
}

.sp-user-claps {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #FF9800;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid white;
}

/* Clap animation */
@keyframes clapPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.sp-clap-button.clapping {
    animation: clapPulse 0.3s ease;
}

/* ============================================
   Bookmark Button & Dropdown
   ============================================ */

.sp-bookmark-container {
    position: relative;
}

.sp-bookmark-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 50%;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sp-bookmark-button i {
    font-size: 1.2rem;
}

.sp-bookmark-button:hover:not(:disabled) {
    background: #f9f9f9;
    border-color: #999;
    transform: scale(1.05);
    color: #666; /* Keep icon gray on hover */
}

.sp-bookmark-button:hover:not(:disabled) i {
    color: #666 !important; /* Force icon to be gray on hover */
}


.sp-bookmark-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sp-bookmark-button.has-bookmarks {
    background: #e11555; /* Red */
    border-color: #e11555;
    color: #ffffff;
}

.sp-bookmark-button.has-bookmarks i {
    /* Change from bookmark-plus to solid bookmark when bookmarked */
    font-size: 1.2rem;
}

.sp-bookmark-button.has-bookmarks i::before {
    font-family: "Font Awesome 6 Pro";
    font-weight: 900;
    content: "\f02e"; /* Unicode for fa-bookmark solid */
}

.sp-clap-button.has-clapped:hover:not(:disabled) i {
    color: #ffffff; /* Keep white color when clapped */
}

.sp-bookmark-button.has-bookmarks:hover:not(:disabled) {
    background: #9F0E3B; /* Darker red on hover */
    border-color: #9F0E3B;
}

.sp-bookmark-button.has-bookmarks:hover:not(:disabled) i {
    color: #ffffff !important; /* Keep icon white when blue */
}


/* Force FontAwesome to render in bookmark button */
.sp-bookmark-button i::before {
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    display: inline-block !important;
}

.sp-bookmark-button.has-bookmarks i::before {
    font-family: "Font Awesome 7 Pro", "Font Awesome 6 Pro", "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
}


/* Bookmark Dropdown */
.sp-bookmark-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-height: 500px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow: hidden;
}

/* Mobile: Center the dropdown */
@media (max-width: 639px) {
    .sp-bookmark-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: calc(100% - 2rem);
        max-width: 320px;
        max-height: 80vh; /* Add max height */
        display: flex; /* Make it flex container */
        flex-direction: column; /* Stack children vertically */
    }
    
    /* Overlay backdrop on mobile */
    .sp-bookmark-dropdown::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: -1;
    }
    
    /* Make lists scrollable if needed */
    .sp-lists-container {
        background-color: #ffffff;
        flex: 1;
        overflow-y: auto;
        min-height: 0; /* Important for flexbox scrolling */
    }
    
    /* Keep footer at bottom */
    .sp-dropdown-footer {
        flex-shrink: 0;
    }
}


.sp-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.sp-dropdown-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.sp-dropdown-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #666;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.sp-dropdown-close:hover {
    color: #000;
}

/* Lists Container */
.sp-lists-container {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.sp-lists-loading {
    padding: 2rem;
    text-align: center;
    color: #999;
}

.sp-list-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
    background: #ffffff; /* Add white background */
}

.sp-list-item:hover {
    background: #f5f5f5;
}

.sp-list-item input[type="checkbox"] {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.sp-list-item label {
    flex: 1;
    cursor: pointer;
    font-size: 0.95rem;
    color: #333;
    margin: 0;
}

.sp-list-item-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sp-list-item:hover .sp-list-item-actions {
    opacity: 1;
}

.sp-list-delete {
    background: none;
    border: none;
    color: #999;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem;
}

.sp-list-delete:hover {
    color: #f44336;
}

.sp-list-default-badge {
    background: #e11555;
    color: #FFC8D9;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* Create List Form */
.sp-dropdown-footer {
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.sp-create-list-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap; /* Prevent wrapping */
}

.sp-new-list-input {
    flex: 1;
    min-width: 0; /* Allow input to shrink */
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.sp-new-list-input:focus {
    outline: none;
    border-color: #2196F3;
}

.sp-create-list-button {
    padding: 0.5rem 1rem;
    background: #e11555; /* Red */
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0; /* Don't let button shrink */
}

.sp-create-list-button:hover {
    background: #9F0E3B; /* Darker red */
}

.sp-create-list-button i {
    margin-right: 0.25rem;
}

/* ============================================
   Text Size Buttons (Simplified)
   ============================================ */

.sp-text-size-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sp-text-size-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 50%;
    color: #666;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sp-text-size-btn span {
    display: flex;
    align-items: center;
    line-height: 1;
}

.sp-text-size-btn sup {
    font-size: 0.6rem;
    margin-left: 1px;
}

.sp-text-size-btn:hover:not(:disabled) {
    background: #f9f9f9;
    border-color: #999;
    transform: scale(1.05);
    color: #666;
}

.sp-text-size-btn.active {
    background: #e11555;
    border-color: #9F0E3B;
    color: #ffffff;
}

.sp-text-size-btn.active:hover {
    background: #9F0E3B;
    border-color: #9F0E3B;
    color: #666;
}

.sp-text-size-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile adjustments */
@media (max-width: 639px) {
    .sp-text-size-buttons {
        gap: 0.35rem;
    }
    
    .sp-text-size-btn {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }
}

/* Text Size Classes for Chapter Content - Keep these! */
body.sp-text-small .chapter-text-above,
body.sp-text-small .chapter-text-below {
    font-size: 14px !important;
}

body.sp-text-medium .chapter-text-above,
body.sp-text-medium .chapter-text-below {
    font-size: 16px !important;
}

body.sp-text-large .chapter-text-above,
body.sp-text-large .chapter-text-below {
    font-size: 18px !important;
}

body.sp-text-extra-large .chapter-text-above,
body.sp-text-extra-large .chapter-text-below {
    font-size: 20px !important;
}

/* Apply to all text elements inside those containers */
body.sp-text-small .chapter-text-above p,
body.sp-text-small .chapter-text-below p {
    font-size: 14px !important;
}

body.sp-text-medium .chapter-text-above p,
body.sp-text-medium .chapter-text-below p {
    font-size: 16px !important;
}

body.sp-text-large .chapter-text-above p,
body.sp-text-large .chapter-text-below p {
    font-size: 18px !important;
}

body.sp-text-extra-large .chapter-text-above p,
body.sp-text-extra-large .chapter-text-below p {
    font-size: 20px !important;
}

/* ============================================
   Membership Prompt
   ============================================ */

.sp-membership-prompt {
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 0 1rem;
}

.sp-membership-prompt p {
    text-align: center;
    padding: 0.75rem 1rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    color: #856404;
    font-size: 0.9rem;
    margin: 0;
}

.sp-membership-prompt a {
    color: #856404;
    font-weight: 600;
    text-decoration: underline;
}

.sp-membership-prompt a:hover {
    color: #533f03;
}

.sp-membership-prompt i {
    color: #ffc107;
    margin-right: 0.25rem;
}

/* ============================================
   Notifications/Toasts
   ============================================ */

.sp-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: #333;
    color: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    animation: slideInUp 0.3s ease;
    max-width: 90%;
}

@media (max-width: 639px) {
    .sp-notification {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
}

.sp-notification.success {
    background: #4CAF50;
}

.sp-notification.error {
    background: #f44336;
}

.sp-notification.info {
    background: #2196F3;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.sp-notification.hiding {
    animation: slideOutDown 0.3s ease;
}

/* ============================================
   Loading States
   ============================================ */

.sp-loading {
    opacity: 0.6;
    pointer-events: none;
}

.sp-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   Tablet & Desktop Adjustments
   ============================================ */

/* Mobile Responsive */
@media (max-width: 639px) {
    .sp-chapter-nav-inner {
        padding: 0 0.5rem;
        gap: 0.5rem;
    }
    
    .sp-nav-center {
        gap: 0.75rem;
    }
    
    /* Make all buttons smaller on mobile */
    .sp-clap-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .sp-clap-button i {
        font-size: 1rem;
    }
    
    .sp-clap-count {
        font-size: 0.85rem;
    }
    
    .sp-bookmark-button {
        width: 40px;
        height: 40px;
    }
    
    .sp-bookmark-button i {
        font-size: 1rem;
    }
    
    .sp-text-size-buttons {
        gap: 0.25rem;
    }
    
    .sp-text-size-btn {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }
    
    .sp-text-size-btn sup {
        font-size: 0.55rem;
    }
    
    /* Hide prev/next labels on mobile */
    .sp-nav-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .sp-nav-left,
    .sp-nav-right {
        min-width: auto;
    }
    
    /* Make user claps badge smaller */
    .sp-user-claps {
        font-size: 0.65rem;
        padding: 1px 4px;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .sp-nav-center {
        gap: 0.5rem;
    }
    
    .sp-text-size-buttons {
        gap: 0.15rem;
    }
    
    .sp-text-size-btn {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
    
    .sp-bookmark-button {
        width: 36px;
        height: 36px;
    }
}

/* ============================================
   Accessibility
   ============================================ */

.sp-clap-button:focus,
.sp-bookmark-button:focus,
.sp-nav-button:focus,
.sp-create-list-button:focus {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .sp-chapter-nav {
        display: none;
    }
}

/* ============================================
   Reading Lists Page
   ============================================ */

.sp-reading-lists-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

.sp-reading-lists-container > h2 {
    margin-bottom: 2rem;
    font-size: 2rem;
    color: #333;
}

/* Login/Membership Messages */
.sp-reading-lists-login,
.sp-reading-lists-membership,
.sp-reading-lists-empty {
    text-align: center;
    padding: 3rem 1rem;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 2rem 0;
}

.sp-reading-lists-login p,
.sp-reading-lists-membership p,
.sp-reading-lists-empty p {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
}

.sp-reading-lists-login a,
.sp-reading-lists-membership a {
    color: #9F0E3B; /* Darker Red */
    font-weight: 600;
    text-decoration: underline;
}

/* Individual Reading List */
.sp-reading-list {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sp-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
    gap: 0.5rem;
}

.sp-list-header h3 {
    margin: 0 !important;
    font-size: 1.5rem !important;
    color: #333;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.4;
}

.sp-list-badge {
    background: #9F0E3B; /* dark red background */
    color: #FFC8D9; /* Pink text */
    font-size: 0.65rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.sp-list-count {
    background: #f5f5f5;
    color: #666;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.sp-list-empty {
    color: #999;
    font-style: italic;
    padding: 2rem;
    text-align: center;
    margin: 0;
}

/* Chapter Items */
.sp-list-chapters {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-list-chapter-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.25rem;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    gap: 1rem;
}

.sp-list-chapter-item:hover {
    background: #f0f0f0;
    border-color: #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sp-chapter-info {
    flex: 1;
    min-width: 0;
}

.sp-chapter-book {
    font-size: 0.75rem;
    color: #999;
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    line-height: 1.2;
}

.sp-chapter-title {
    color: #e11555 !important; /* Red */
    text-decoration: none !important;
    font-weight: 600;
    font-size: 1.05rem;
    display: block;
    transition: color 0.2s ease;
    line-height: 1.5;
    margin: 0;
}

.sp-chapter-title:hover {
    color: #9F0E3B !important; /* Darker red */
    text-decoration: underline !important;
}

/* Remove Chapter Button */
.sp-remove-chapter {
    background: #ffffff;
    border: 1px solid #ddd;
    color: #999;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 1;
    min-width: auto;
}

.sp-remove-chapter:hover {
    background: #ffebee;
    color: #f44336;
    border-color: #f44336;
}

.sp-remove-chapter i {
    display: block;
    font-size: 1.2rem;
}

/* Delete List Button */
.sp-delete-list-button {
    margin-top: 1rem;
    padding: 0.75rem 1.25rem;
    background: #ffffff;
    color: #f44336;
    border: 2px solid #f44336;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sp-delete-list-button:hover {
    background: #f44336;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

.sp-delete-list-button i {
    font-size: 1rem;
}

/* Continue Reading Widget */
.sp-continue-reading {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.sp-continue-reading h3 {
    color: #ffffff !important;
    margin: 0 0 1rem 0 !important;
    font-size: 1.2rem !important;
}

.sp-continue-reading-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #ffffff;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    text-decoration: none !important;
    color: #333 !important;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.sp-continue-reading-link:hover {
    transform: translateX(5px);
}

.sp-continue-reading-link i {
    color: #667eea;
    font-size: 1.5rem;
}

/* Mobile Responsive */
@media (max-width: 639px) {
    .sp-list-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sp-list-chapter-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sp-remove-chapter {
        align-self: flex-end;
        margin-top: 0.5rem;
    }
    
    .sp-reading-lists-container {
        padding: 0 0.5rem;
    }
}

