/**
 * Page-Specific Styles
 * Styles that are unique to specific pages or views
 */

/* ===== RESPONSIVE BREAKPOINTS ===== */
@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .book-grid {
        grid-template-columns: 1fr;
    }

    .search-form {
        flex-direction: column;
    }

    .filters {
        flex-direction: column;
    }

    .header-content {
        padding: 0 1rem;
    }

    .tabs-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab-btn {
        white-space: nowrap;
    }

    .table-wrapper {
        overflow-x: scroll;
    }

    .bulk-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .bulk-actions-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.25rem;
    }

    .logo i {
        font-size: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

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

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== LIBRARY PAGE SPECIFIC ===== */
.library-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-toggle {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    padding: 0.25rem;
}

.view-toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-toggle-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.view-toggle-btn:hover:not(.active) {
    color: var(--gray-900);
}

.library-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.library-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.genre-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    color: var(--gray-700);
    transition: all var(--transition-base);
    cursor: pointer;
}

.genre-tag:hover {
    background: var(--primary-color);
    color: white;
}

.genre-tag.active {
    background: var(--primary-color);
    color: white;
}

.genre-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
}

.series-group {
    background: var(--gray-50);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: var(--radius-md);
}

.series-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.series-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.series-count {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: normal;
}

/* Book list view (table) specific styles */
.book-list-view .book-row {
    display: grid;
    grid-template-columns: 60px 1fr 200px 150px 100px 150px;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    transition: background var(--transition-base);
}

.book-list-view .book-row:hover {
    background: var(--gray-50);
}

.book-list-cover-small {
    width: 60px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.book-list-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.book-list-title {
    font-weight: 600;
    color: var(--gray-900);
}

.book-list-author {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.book-list-series {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-info {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* ===== RBAC PAGE ===== */
.card-grid.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.card-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: grid;
    gap: 1rem;
}

.card-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stacked-form {
    display: grid;
    gap: 0.75rem;
}

.pill-select {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--gray-100);
    color: var(--gray-800);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.pill input {
    margin: 0;
}

.pill.muted {
    background: var(--gray-50);
    color: var(--gray-700);
}

.list-item {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    margin-bottom: 0.5rem;
}

.list-title {
    font-weight: 600;
    color: var(--gray-900);
}

.list-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.divider {
    height: 1px;
    background: var(--border-color);
}

@media (max-width: 1024px) {
    .card-grid.two-col {
        grid-template-columns: 1fr;
    }
}

/* ===== AUDIOBOOKS PAGE ===== */
.audiobook-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.audiobook-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.audiobook-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

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

.audiobook-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.audiobook-series {
    font-size: 0.875rem;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.audiobook-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.audiobook-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.audiobook-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.audiobook-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.audiobook-actions {
    flex-shrink: 0;
    margin-left: 1rem;
}

/* Audiobook Cover */
.audiobook-cover {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    margin-right: 1rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-100);
}

.audiobook-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.audiobook-cover .no-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
    color: var(--gray-400);
    font-size: 2rem;
}

/* Audiobook Details Panel */
#audiobookDetailsPanel {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow-y: auto;
    transition: right 0.3s ease;
}

#audiobookDetailsPanel.active {
    right: 0;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--card-bg);
}

.details-header h4 {
    margin: 0;
    font-size: 1.125rem;
}

.details-body {
    padding: 1rem;
}

.details-section {
    margin-bottom: 1.5rem;
}

.details-section h6 {
    margin-bottom: 0.75rem;
    color: var(--gray-700);
    font-weight: 600;
}

/* Details Cover Section */
.details-cover-section {
    text-align: center;
}

.details-cover-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.details-table {
    width: 100%;
    font-size: 0.875rem;
}

.details-table td {
    padding: 0.375rem 0;
    vertical-align: top;
}

.details-table td:first-child {
    color: var(--gray-500);
    width: 35%;
}

.details-table td:last-child {
    color: var(--gray-900);
}

.path-cell {
    word-break: break-all;
    font-family: monospace;
    font-size: 0.75rem;
}

.description-text {
    font-size: 0.875rem;
    color: var(--gray-700);
    line-height: 1.6;
}

.files-list, .chapters-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.file-item, .chapter-item {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.file-item:last-child, .chapter-item:last-child {
    border-bottom: none;
}

.file-name {
    display: block;
    color: var(--gray-900);
    word-break: break-all;
}

.file-meta {
    display: block;
    color: var(--gray-500);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chapter-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 0.7rem;
    color: var(--gray-600);
}

.chapter-title {
    flex: 1;
    color: var(--gray-800);
}

.chapter-time {
    flex-shrink: 0;
    color: var(--gray-500);
    font-family: monospace;
}

/* ===== EXTERNAL AUDIOBOOK SEARCH ===== */
.external-search-form {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.external-results-container {
    padding: 1rem;
    min-height: 200px;
}

.external-results-header {
    margin-bottom: 1rem;
}

.external-results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.external-result-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.external-result-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.external-result-cover {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-200);
}

.external-result-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.external-result-cover .no-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 2rem;
}

.external-result-info {
    flex: 1;
    min-width: 0;
}

.external-result-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.external-result-subtitle {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}

.external-result-series {
    font-size: 0.875rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.external-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.external-result-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.external-result-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.external-result-asin {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.external-result-asin code {
    font-size: 0.75rem;
    background: var(--gray-100);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
    .external-result-card {
        flex-direction: column;
    }

    .external-result-cover {
        width: 100%;
        height: 120px;
    }
}

/* ===== AUDIOBOOKBAY RESULTS ===== */

.abb-results-container {
    display: none;
    transition: all 0.3s ease;
}

.abb-results-container.show {
    display: block;
    animation: slideDown 0.3s ease;
}

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

.abb-results {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.abb-results h6 {
    color: var(--gray-700);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.abb-results-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.abb-result-card {
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-color);
}

.abb-result-card:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.abb-result-card .card-body {
    padding: 0.75rem;
}

.abb-result-card .fw-bold {
    font-size: 0.875rem;
    color: var(--gray-900);
}

.abb-result-card .text-muted {
    font-size: 0.75rem;
}

.abb-result-card .badge {
    font-size: 0.7rem;
    margin-right: 0.25rem;
}

.search-abb-btn {
    white-space: nowrap;
    transition: all 0.2s;
}

.search-abb-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.search-abb-btn .spinner-border {
    width: 0.875rem;
    height: 0.875rem;
}

/* Responsive adjustments for AudiobookBay results */
@media (max-width: 768px) {
    .abb-result-card .d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }

    .abb-result-card .d-flex .ms-2 {
        margin-left: 0 !important;
        margin-top: 0.5rem;
    }

    .abb-result-card .flex-shrink-0 {
        width: 100%;
    }
}

/* ===== AUDIOBOOK SUB-TABS ===== */
.audiobook-subtabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: var(--radius-md);
}

.audiobook-subtab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
}

.audiobook-subtab:hover {
    color: var(--gray-900);
    background: rgba(255, 255, 255, 0.5);
}

.audiobook-subtab.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.audiobook-subtab i {
    font-size: 1.125rem;
}

.subtab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-full);
}

.audiobook-subtab-content {
    display: none;
}

.audiobook-subtab-content.active {
    display: block;
}

/* ===== TORRENT DOWNLOAD QUEUE ===== */
.torrent-queue-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.torrent-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-base);
}

.torrent-card:hover {
    border-color: var(--gray-400);
}

.torrent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem;
    gap: 1rem;
}

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

.torrent-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.torrent-title i {
    flex-shrink: 0;
}

.torrent-author {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.torrent-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}

.torrent-size {
    color: var(--gray-600);
}

.torrent-status {
    flex-shrink: 0;
}

.torrent-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.torrent-status-badge.status-pending {
    background: var(--gray-100);
    color: var(--gray-600);
}

.torrent-status-badge.status-adding {
    background: #e0f2fe;
    color: #0369a1;
}

.torrent-status-badge.status-downloading {
    background: #dbeafe;
    color: #1d4ed8;
}

.torrent-status-badge.status-seeding {
    background: #dcfce7;
    color: #15803d;
}

.torrent-status-badge.status-importing {
    background: #fef3c7;
    color: #b45309;
}

.torrent-status-badge.status-completed {
    background: #d1fae5;
    color: #047857;
}

.torrent-status-badge.status-failed {
    background: #fee2e2;
    color: #dc2626;
}

.torrent-status-badge.status-cancelled {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* Progress Section */
.torrent-progress-section {
    padding: 0 1rem 1rem;
}

.torrent-progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.torrent-progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.torrent-progress-fill.status-downloading {
    background: #3b82f6;
}

.torrent-progress-fill.status-seeding {
    background: #22c55e;
}

.torrent-progress-fill.status-importing {
    background: #f59e0b;
}

.torrent-progress-fill.status-adding {
    background: #06b6d4;
}

.torrent-progress-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--gray-600);
}

.progress-percent {
    font-weight: 600;
    color: var(--gray-900);
}

.progress-speeds {
    display: flex;
    gap: 0.75rem;
}

.download-speed {
    color: #3b82f6;
}

.upload-speed {
    color: #22c55e;
}

.progress-eta,
.progress-ratio {
    color: var(--gray-500);
}

/* Error Message */
.torrent-error {
    padding: 0.75rem 1rem;
    background: #fef2f2;
    border-top: 1px solid #fecaca;
    font-size: 0.875rem;
    color: #dc2626;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.torrent-error i {
    flex-shrink: 0;
}

/* Card Footer */
.torrent-card-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-top: 1px solid var(--border-color);
}

.torrent-card-footer .text-success {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* Pagination */
.torrent-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.torrent-pagination .pagination-info {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .audiobook-subtabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .audiobook-subtab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .torrent-card-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .torrent-status {
        align-self: flex-start;
    }

    .torrent-progress-stats {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .progress-speeds {
        flex-direction: column;
        gap: 0.25rem;
    }

    .torrent-card-footer {
        flex-wrap: wrap;
    }
}
