/**
 * Estilos para Sistema de Progresso de Leitura e Notificações
 * CGBookStore v3
 */

/* ========== TOAST NOTIFICATIONS ========== */

.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-notification.toast-success {
    border-left: 4px solid #28a745;
}

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

.toast-notification.toast-error {
    border-left: 4px solid #dc3545;
}

.toast-notification.toast-error i {
    color: #dc3545;
}

.toast-notification i {
    font-size: 1.2rem;
}

.toast-notification span {
    font-size: 0.95rem;
    color: #333;
}

/* ========== PROGRESS WIDGET ========== */

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

.progress-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.progress-widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.progress-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.progress-badge.on-track {
    background: #d4edda;
    color: #155724;
}

.progress-badge.approaching {
    background: #fff3cd;
    color: #856404;
}

.progress-badge.overdue {
    background: #f8d7da;
    color: #721c24;
}

.progress-badge.abandoned {
    background: #e2e3e5;
    color: #383d41;
}

.progress-bar-container {
    background: #e9ecef;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-bar {
    height: 100%;
    /* ✅ CORREÇÃO: Removemos a cor de fundo fixa daqui. */
    /* Agora, a classe .bg-success do Bootstrap poderá ser aplicada. */
    transition: width 0.3s ease;
}

/* ✅ MELHORIA: Garantir que a cor de sucesso seja aplicada corretamente. */
/* Esta regra reforça a cor verde apenas quando .bg-success está presente. */
.progress-bar.bg-success {
    background-color: #198754; /* Cor padrão 'success' do Bootstrap 5 */
}

.progress-slider-container {
    margin-bottom: 15px;
}

.progress-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e9ecef;
    outline: none;
    -webkit-appearance: none;
}

.progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.progress-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
    margin-top: 8px;
    display: block;
}

.progress-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.progress-actions .btn {
    flex: 1;
    min-width: 120px;
    font-size: 0.9rem;
    padding: 8px 16px;
}

/* ========== DEADLINE MODAL ========== */

.deadline-modal {
    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: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.deadline-modal.show {
    opacity: 1;
}

.deadline-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.deadline-modal.show .deadline-modal-content {
    transform: scale(1);
}

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

.deadline-modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: #333;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-close-modal:hover {
    background: #f8f9fa;
    color: #333;
}

.deadline-modal-body {
    padding: 20px;
}

.deadline-modal-body p {
    margin-bottom: 15px;
    color: #666;
}

.deadline-modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.deadline-modal-body input[type="date"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

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

/* ========== NOTIFICATIONS DROPDOWN (ADAPTÁVEL AO TEMA) ========== */

.notifications-container {
    position: relative;
    display: flex;
    align-items: center;
}

.notifications-toggle {
    position: relative;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s;
}

.navbar .notifications-toggle {
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid transparent;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
}

.navbar .notifications-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.notifications-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    background: var(--danger-color); /* ✅ Usa variável */
    color: var(--text-light);      /* ✅ Usa variável */
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    display: none;
    align-items: center;
    justify-content: center;
}

.notifications-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: var(--card-bg); /* ✅ Usa variável */
    color: var(--text-primary); /* ✅ Usa variável */
    border: 1px solid var(--border-color); /* ✅ Usa variável */
    border-radius: 12px;
    box-shadow: var(--shadow-lg); /* ✅ Usa variável */
    width: 380px;
    max-height: 500px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

.notifications-dropdown.show {
    display: flex;
}

.notifications-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color); /* ✅ Usa variável */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notifications-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary); /* ✅ Usa variável */
}

.btn-mark-all-read {
    background: none;
    border: none;
    color: var(--text-link); /* ✅ Usa variável */
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-mark-all-read:hover {
    background: var(--body-bg); /* ✅ Usa variável */
}

.notifications-list {
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color); /* ✅ Usa variável */
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: background 0.2s;
    cursor: pointer;
}

.notification-item:hover {
    background: var(--body-bg); /* ✅ Usa variável */
}

[data-theme="light"] .notification-item.unread {
    background: #e7f3ff; /* Cor específica para tema claro */
}

[data-theme="dark"] .notification-item.unread {
    background: rgba(93, 195, 209, 0.1); /* Cor específica para tema escuro */
}

.notification-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--body-bg); /* ✅ Usa variável */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    color: var(--text-primary); /* ✅ Usa variável */
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.notification-book {
    color: var(--text-secondary); /* ✅ Usa variável */
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.notification-message {
    color: var(--text-muted); /* ✅ Usa variável */
    font-size: 0.8rem;
    /* ... (resto das propriedades) ... */
}

.notification-time {
    color: var(--text-muted); /* ✅ Usa variável */
    font-size: 0.75rem;
}

.btn-mark-read {
    /* ... (propriedades de layout) ... */
    color: var(--success-color); /* ✅ Usa variável */
}

.btn-mark-read:hover {
    background: rgba(var(--success-rgb, 25, 135, 84), 0.1); /* ✅ Usa variável com opacidade */
}

.notification-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted); /* ✅ Usa variável */
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
    .toast-notification {
        right: 10px;
        left: 10px;
        max-width: calc(100% - 20px);
    }

    .notifications-dropdown {
        width: 100vw;
        max-width: 100vw;
        right: -10px;
    }

    .progress-actions {
        flex-direction: column;
    }

    .progress-actions .btn {
        width: 100%;
    }
}

/* ========== MODAL DE PRATELEIRA PERSONALIZADA - FIX ========== */

/* Garantir que o backdrop funcione corretamente */
.modal-backdrop {
    z-index: 1040 !important;
}

/* Garantir que o modal fique acima do backdrop */
#libraryCustomShelfModal {
    z-index: 1050 !important;
}

/* Garantir que modal fique visível quando ativo */
#libraryCustomShelfModal.show {
    display: block !important;
    pointer-events: auto !important;
}

/* Garantir que o modal seja clicável */
#libraryCustomShelfModal .modal-dialog {
    position: relative;
    z-index: 1051 !important;
    pointer-events: auto !important;  /* ✅ CORREÇÃO CRÍTICA */
}

/* Prevenir que o body fique travado */
body.modal-open {
    overflow: hidden !important;
}

/* Estilo adicional para o modal */
#libraryCustomShelfModal .modal-content {
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    pointer-events: auto !important;  /* ✅ CORREÇÃO CRÍTICA */
}

/* Input do modal */
#libraryCustomShelfName:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* ========== SWEETALERT2 - TEMAS CUSTOMIZADOS ========== */

/* Tema Escuro */
[data-theme="dark"] .swal2-popup,
.theme-dark .swal2-popup {
    background-color: #2d3748 !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .swal2-title,
.theme-dark .swal2-title {
    color: #f7fafc !important;
}

[data-theme="dark"] .swal2-html-container,
.theme-dark .swal2-html-container {
    color: #e2e8f0 !important;
}

[data-theme="dark"] .swal2-input,
.theme-dark .swal2-input {
    background-color: #1a202c !important;
    color: #e2e8f0 !important;
    border: 1px solid #4a5568 !important;
}

[data-theme="dark"] .swal2-input:focus,
.theme-dark .swal2-input:focus {
    border-color: #4299e1 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.3) !important;
}

[data-theme="dark"] .swal2-confirm,
.theme-dark .swal2-confirm {
    background-color: #4299e1 !important;
}

[data-theme="dark"] .swal2-cancel,
.theme-dark .swal2-cancel {
    background-color: #718096 !important;
}

/* Tema Claro */
[data-theme="light"] .swal2-popup,
.theme-light .swal2-popup {
    background-color: #ffffff !important;
    color: #2d3748 !important;
}

[data-theme="light"] .swal2-input,
.theme-light .swal2-input {
    background-color: #f7fafc !important;
    color: #2d3748 !important;
    border: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .swal2-input:focus,
.theme-light .swal2-input:focus {
    border-color: #4299e1 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.3) !important;
}

/* Fix: Garantir que o input seja clicável */
.swal2-input {
    pointer-events: auto !important;
    cursor: text !important;
}

/* Fix: Container do SweetAlert2 deve estar acima de tudo */
.swal2-container {
    z-index: 10000 !important;
}

/* Fix: Backdrop do SweetAlert2 */
.swal2-container.swal2-backdrop-show {
    background: rgba(0, 0, 0, 0.6) !important;
}

/**
 * =========================================================================
 * ATUALIZAÇÃO: Sistema de Notificações v3.0.0
 *
 * Data: Outubro 2025
 *
 * Novos Componentes:
 * - Filtros de notificações (status, categoria)
 * - Category chips (badges)
 * - Botão de toggle de som
 * - Melhorias responsivas
 * =========================================================================
 */

/* ========== NOTIFICATION FILTERS ========== */

.notification-filters {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

.notification-filters select {
    padding: 6px 12px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    background: white;
    font-size: 0.85rem;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    flex: 1;
    min-width: 120px;
}

.notification-filters select:hover {
    border-color: #4a90e2;
    background: #f8f9fa;
}

.notification-filters select:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Estilo específico para cada filtro */
.filter-status {
    border-left: 3px solid #28a745;
}

.filter-category {
    border-left: 3px solid #6c757d;
}

/* Dark mode - Filtros */
[data-theme="dark"] .notification-filters {
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .notification-filters select {
    background: #2d3748;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

[data-theme="dark"] .notification-filters select:hover {
    background: #374151;
    border-color: #4a90e2;
}

/* ========== CATEGORY CHIPS ========== */

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 6px;
}

.category-chip.category-reading {
    background: rgba(74, 144, 226, 0.1);
    color: #4a90e2;
    border: 1px solid rgba(74, 144, 226, 0.2);
}

.category-chip.category-system {
    background: rgba(108, 117, 125, 0.1);
    color: #6c757d;
    border: 1px solid rgba(108, 117, 125, 0.2);
}

/* Dark mode - Category Chips */
[data-theme="dark"] .category-chip.category-reading {
    background: rgba(74, 144, 226, 0.2);
    color: #7ab3ff;
}

[data-theme="dark"] .category-chip.category-system {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}

/* ========== SOUND TOGGLE BUTTON ========== */

.btn-toggle-sound {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6c757d;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
}

.btn-toggle-sound:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: #4a90e2;
    color: #4a90e2;
    transform: translateY(-1px);
}

.btn-toggle-sound:active {
    transform: translateY(0);
}

.btn-toggle-sound i {
    font-size: 1rem;
    transition: color 0.2s ease;
}

/* Estado ativo (som ligado) */
.btn-toggle-sound.sound-enabled {
    color: #28a745;
    border-color: rgba(40, 167, 69, 0.3);
}

.btn-toggle-sound.sound-enabled:hover {
    background: rgba(40, 167, 69, 0.1);
    border-color: #28a745;
}

/* Estado inativo (som desligado) */
.btn-toggle-sound.sound-disabled {
    color: #dc3545;
    border-color: rgba(220, 53, 69, 0.3);
}

.btn-toggle-sound.sound-disabled:hover {
    background: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
}

/* Dark mode - Sound Button */
[data-theme="dark"] .btn-toggle-sound {
    border-color: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
}

[data-theme="dark"] .btn-toggle-sound:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #4a90e2;
}

[data-theme="dark"] .btn-toggle-sound.sound-enabled {
    color: #48bb78;
    border-color: rgba(72, 187, 120, 0.3);
}

[data-theme="dark"] .btn-toggle-sound.sound-disabled {
    color: #f56565;
    border-color: rgba(245, 101, 101, 0.3);
}

/* ========== NOTIFICATION HEADER IMPROVEMENTS ========== */

.notifications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 8px;
}

.notifications-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    flex-shrink: 0;
}

.notifications-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Dark mode - Header */
[data-theme="dark"] .notifications-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .notifications-header h4 {
    color: #e2e8f0;
}

/* ========== NOTIFICATION ITEM IMPROVEMENTS ========== */

.notification-item {
    position: relative;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.notification-item.category-reading {
    border-left: 3px solid #4a90e2;
}

.notification-item.category-system {
    border-left: 3px solid #6c757d;
}

.notification-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

.notification-item.read {
    opacity: 0.7;
}

/* Dark mode - Notification Item */
[data-theme="dark"] .notification-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .notification-item.category-reading {
    border-left-color: #7ab3ff;
}

[data-theme="dark"] .notification-item.category-system {
    border-left-color: #9ca3af;
}

/* ========== NOTIFICATION TITLE IMPROVEMENTS ========== */

.notification-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

[data-theme="dark"] .notification-title {
    color: #e2e8f0;
}

/* ========== EMPTY STATE ========== */

.notification-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 0.9rem;
}

.notification-empty::before {
    content: "🔕";
    display: block;
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

[data-theme="dark"] .notification-empty {
    color: #9ca3af;
}

/* ========== RESPONSIVE ADJUSTMENTS ========== */

@media (max-width: 768px) {
    .notifications-dropdown {
        width: 95vw;
        max-width: 95vw;
        right: 2.5vw;
    }

    .notification-filters {
        padding: 8px;
    }

    .notification-filters select {
        font-size: 0.8rem;
        padding: 5px 8px;
        min-width: 100px;
    }

    .notifications-header {
        padding: 10px 12px;
    }

    .notifications-header h4 {
        font-size: 1rem;
    }

    .notifications-header-actions {
        flex: 1 0 100%;
        justify-content: flex-end;
    }

    .btn-toggle-sound {
        padding: 5px 8px;
        min-width: 32px;
        height: 32px;
    }

    .category-chip {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .notification-item {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .notifications-dropdown {
        width: 100vw;
        max-width: 100vw;
        right: 0;
        border-radius: 0;
    }

    .notification-filters {
        flex-direction: column;
    }

    .notification-filters select {
        width: 100%;
        min-width: unset;
    }

    .category-chip {
        font-size: 0.6rem;
    }
}

/* ========== ANIMATIONS ========== */

@keyframes filterHighlight {
    0% {
        background: rgba(74, 144, 226, 0.1);
    }
    50% {
        background: rgba(74, 144, 226, 0.2);
    }
    100% {
        background: rgba(74, 144, 226, 0.1);
    }
}

.notification-filters select:focus {
    animation: filterHighlight 0.3s ease;
}

@keyframes soundBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

.btn-toggle-sound:active {
    animation: soundBounce 0.3s ease;
}

/* ========== ACCESSIBILITY ========== */

.notification-filters select:focus-visible,
.btn-toggle-sound:focus-visible {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Reduzir movimento para usuários com preferência */
@media (prefers-reduced-motion: reduce) {
    .notification-filters select,
    .btn-toggle-sound,
    .notification-item,
    .category-chip {
        transition: none;
    }

    .btn-toggle-sound:active {
        animation: none;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    .notification-filters,
    .btn-toggle-sound,
    .btn-mark-read,
    .btn-mark-all-read,
    .btn-edit-notifications {
        display: none !important;
    }

    .notification-item {
        page-break-inside: avoid;
        border: 1px solid #ddd;
        margin-bottom: 8px;
    }
}

/* ========== FIM DA ATUALIZAÇÃO ========== */