/**
 * Reusable Components
 * Buttons, forms, cards, badges, tables, and other UI components
 */

/* ===== HEADER ===== */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

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

/* ===== API KEY SECTION ===== */
.api-key-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
}

.api-key-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin: 0;
    white-space: nowrap;
}

.api-key-label i {
    font-size: 1rem;
}

.api-key-input {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
    background: white;
    color: var(--gray-900);
    width: 300px;
    transition: border-color var(--transition-base);
}

.api-key-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.api-key-input::placeholder {
    color: var(--gray-400);
    font-family: system-ui, -apple-system, sans-serif;
}

.btn-icon {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-600);
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--gray-50);
    color: var(--gray-900);
    border-color: var(--gray-400);
}

.btn-save {
    padding: 0.375rem 0.875rem;
    border: none;
    background: var(--success-color);
    color: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: all var(--transition-base);
}

.btn-save:hover {
    background: #059669;
    box-shadow: var(--shadow-sm);
}

.btn-clear {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--danger-color);
    background: white;
    color: var(--danger-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear:hover {
    background: var(--danger-color);
    color: white;
}

/* ===== TABS NAVIGATION ===== */
.tabs-nav {
    display: flex;
    gap: 0.5rem;
    background: white;
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

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

.tab-btn:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

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

/* ===== MAIN CONTAINER ===== */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn var(--transition-slow) ease-in;
}

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

/* ===== CARDS ===== */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gray-100);
}

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

/* ===== STATS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.info {
    border-left-color: var(--info-color);
}

.stat-card.purple {
    border-left-color: var(--purple-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-change {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 500;
}

.status-badge.searching_now,
.status-badge.searching {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.status-badge.found_pending,
.status-badge.found {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.status-badge.grabbed,
.status-badge.downloading {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

.status-badge.completed {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.status-badge.failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.status-badge.monitored,
.status-badge.not_found {
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple-color);
}

.status-badge.processing {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--secondary-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-300);
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.125rem;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-base);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===== SEARCH ===== */
.search-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1.25rem;
}

/* ===== BOOK CARDS ===== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-slow);
}

.book-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.book-cover-wrapper {
    height: 240px;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.book-cover-placeholder {
    font-size: 4rem;
    color: var(--gray-400);
}

.book-info {
    padding: 1.25rem;
}

.book-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-authors {
    color: var(--gray-600);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.book-meta {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
}

.book-actions {
    display: flex;
    gap: 0.75rem;
}

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--gray-50);
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== CHECKBOX ===== */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* ===== PROGRESS BAR ===== */
.progress-wrapper {
    min-width: 200px;
}

.progress-bar-container {
    width: 100%;
    height: 1.5rem;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width var(--transition-slow) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.progress-bar.success {
    background: var(--success-color);
}

.progress-bar.danger {
    background: var(--danger-color);
}

.progress-bar.warning {
    background: var(--warning-color);
}

.progress-bar.animated {
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 1rem 1rem;
    animation: progress-animation 1s linear infinite;
}

@keyframes progress-animation {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 1rem 1rem;
    }
}

/* ===== FILTERS ===== */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-600);
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.empty-state-text {
    color: var(--gray-600);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    padding: 1rem 1.25rem;
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn var(--transition-slow) ease;
    border-left: 4px solid var(--primary-color);
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--info-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

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

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-size: 1.25rem;
    padding: 0;
    display: flex;
    align-items: center;
}

.toast-close:hover {
    color: var(--gray-600);
}

/* ===== MONITORING SPECIFIC ===== */
.monitoring-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple-color);
}

.interval-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--gray-100);
    color: var(--gray-700);
}

/* ===== ENRICHMENT BADGE ===== */
.enrichment-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    transition: all var(--transition-base);
}

.enrichment-badge.enriched {
    background: var(--success-color);
    color: white;
}

.enrichment-badge.unenriched {
    background: var(--warning-color);
    color: var(--gray-900);
}

.enrichment-badge i {
    font-size: 0.875rem;
}

.countdown-timer {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* ===== BULK ACTIONS BAR ===== */
.bulk-actions-bar {
    background: var(--primary-color);
    color: white;
    padding: 1rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    display: none;
    align-items: center;
    gap: 1rem;
}

.bulk-actions-bar.active {
    display: flex;
}

.bulk-actions-info {
    flex: 1;
    font-weight: 500;
}

.bulk-actions-buttons {
    display: flex;
    gap: 0.75rem;
}

/* ===== SPINNER ===== */
.spinner {
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 1.25rem;
    height: 1.25rem;
    animation: spin 0.8s linear infinite;
}

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

/* ===== MODAL DIALOGS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.modal-dialog {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    z-index: 1;
    pointer-events: auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--gray-100);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ===== BOOK DETAILS MODAL ===== */
.book-details-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
}

.book-details-cover {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.book-details-cover-image {
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.book-details-cover-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
}

.book-details-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.book-details-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.book-details-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.3;
    margin: 0;
}

.book-details-authors {
    font-size: 1.125rem;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.book-details-series {
    font-size: 1rem;
    color: var(--purple-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.book-details-metadata {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius-md);
}

.book-details-metadata-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.book-details-metadata-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.book-details-metadata-value {
    font-size: 0.95rem;
    color: var(--gray-900);
}

.book-details-metadata-value.mono {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    word-break: break-all;
}

.book-details-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.book-details-description {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--gray-700);
    white-space: pre-wrap;
}

.book-details-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.book-details-storage {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius-md);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
}

.badge-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
}

.badge-warning {
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
}

.badge-danger {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

/* ===== API KEY MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Modal Responsive */
@media (max-width: 768px) {
    .modal-dialog {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .book-details-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .book-details-cover {
        order: 1;
    }

    .book-details-info {
        order: 2;
    }

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

/* ===== METADATA COMPARISON MODAL ===== */
.metadata-comparison-modal {
    max-width: 95vw;
    max-height: 90vh;
    width: 1400px;
}

.comparison-table-container {
    overflow-x: auto;
    max-height: 60vh;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.comparison-table thead {
    position: sticky;
    top: 0;
    background: var(--gray-50);
    z-index: 10;
}

.comparison-table th {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 2px solid var(--gray-300);
    font-weight: 600;
    white-space: nowrap;
}

.comparison-table .field-column {
    width: 120px;
    position: sticky;
    left: 0;
    background: var(--gray-50);
    z-index: 11;
}

.comparison-table .source-column {
    min-width: 200px;
}

.comparison-table tbody tr {
    border-bottom: 1px solid var(--gray-100);
}

.comparison-table tbody tr:hover {
    background: var(--gray-50);
}

.field-label {
    padding: 0.75rem;
    font-weight: 500;
    position: sticky;
    left: 0;
    background: white;
    border-right: 1px solid var(--gray-200);
}

.comparison-table tbody tr:hover .field-label {
    background: var(--gray-50);
}

.source-cell {
    padding: 0.5rem;
    vertical-align: top;
}

.source-cell.current-value {
    background: var(--gray-25);
}

.source-cell.unavailable {
    background: var(--gray-50);
    color: var(--gray-400);
}

.radio-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.radio-wrapper input[type="radio"] {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.radio-wrapper .value {
    flex: 1;
    word-break: break-word;
}

.value-long {
    max-height: 100px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.4;
}

.cover-row {
    background: var(--gray-25);
}

.cover-thumbnail {
    max-width: 120px;
    max-height: 180px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.cover-available {
    padding: 0.5rem;
    background: var(--success-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-align: center;
}

.no-cover {
    padding: 0.5rem;
    color: var(--gray-400);
    font-style: italic;
    text-align: center;
}

.error-state {
    padding: 2rem;
    text-align: center;
    color: var(--gray-500);
}

.loading-state {
    padding: 3rem;
    text-align: center;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    flex-wrap: wrap;
    gap: 1rem;
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    margin: 0.125rem;
}

.text-muted {
    color: var(--gray-400);
}

.text-sm {
    font-size: 0.875rem;
}

/* Custom column styles */
.custom-column {
    background: var(--warning-light, #fff8e1);
    font-weight: 600;
}

.custom-cell {
    background: var(--warning-light, #fff8e1);
}

.custom-input-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.custom-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s;
}

.custom-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.custom-input[type="textarea"],
.custom-input textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.custom-input::placeholder {
    color: var(--gray-400);
    font-style: italic;
}

.custom-cell small {
    color: var(--gray-500);
    font-size: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .metadata-comparison-modal {
        max-width: 100vw;
        max-height: 100vh;
        width: 100%;
        border-radius: 0;
    }

    .comparison-table {
        font-size: 0.8rem;
    }

    .comparison-table .source-column {
        min-width: 150px;
    }

    .modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .quick-actions,
    .action-buttons {
        width: 100%;
        flex-direction: column;
    }

    .quick-actions .btn,
    .action-buttons .btn {
        width: 100%;
    }
}
