/* Shared Styles for Selling Price Inspector */

/* Base Styles */
html, body {
    max-width: 100%;
    overflow-x: auto;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
}

/* Container Styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: visible;
    padding-left: 15px;
    padding-right: 15px;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 300;
}

/* Stats Styles */
.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
}

.stat {
    text-align: center;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 600;
    display: block;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Table Container */
.table-container {
    padding: 20px;
    overflow-x: auto;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

td {
    word-break: break-word;
    overflow-wrap: anywhere;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #f8f9fa;
}

tr.clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

tr.clickable:hover {
    background-color: #e9ecef;
}

/* EAN Styles */
.ean {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #007bff;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Title Styles */
.title {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Cover Image Styles */
.cover {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.book-cover {
    max-width: 200px;
    height: auto;
    margin: 0 auto;
    display: block;
}

img {
    max-width: 100%;
    height: auto;
}

/* Price Info Styles */
.price-info {
    font-size: 0.9rem;
}

.highest-price {
    color: #28a745;
    font-weight: 600;
}

.lowest-price {
    color: #dc3545;
    font-weight: 600;
}

/* Unified Button System */
.btn {
    display: inline-block;
    padding: 8px 16px;
    margin-bottom: 0;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn:disabled {
    background: #6c757d !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.btn:focus {
    outline: 2px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Button Variants */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #212529;
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%);
    color: white;
}

.btn-light {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #212529;
    border: 1px solid #dee2e6;
}

.btn-dark {
    background: linear-gradient(135deg, #343a40 0%, #212529 100%);
    color: white;
}

/* Button Sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 3px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 6px;
}

/* Button with margin utilities */
.btn + .btn {
    margin-left: 8px;
}

/* Legacy button classes for backward compatibility */
.refresh-btn,
.remove-btn,
.refresh-all-btn {
    display: inline-block;
    padding: 8px 16px;
    margin-bottom: 0;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.refresh-btn:hover,
.remove-btn:hover,
.refresh-all-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.refresh-btn:disabled,
.remove-btn:disabled,
.refresh-all-btn:disabled {
    background: #6c757d !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.remove-btn {
    margin-left: 5px;
}

.refresh-all-btn {
    margin-left: 10px;
}

.back-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Loading Styles */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message Styles */
.success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    display: none;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    display: none;
}

/* No Entries Styles */
.no-entries {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

/* Time Styles */
.relative-time {
    font-size: 0.9rem;
    color: #6c757d;
}

/* Link Styles */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover {
    text-decoration: underline;
}

/* Table Responsive Styles */
.table-responsive {
    border-radius: 0.375rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Add comfortable spacing around tables on small screens */
@media (max-width: 768px) {
    .table-responsive {
        padding: 6px 24px;
    }
}

/* Results Page Specific Styles */
.results-container {
    padding: 20px;
}

.results-header {
    margin-bottom: 20px;
}

.results-title {
    margin-bottom: 10px;
}

.results-subtitle {
    color: #6c757d;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Book Info Styles */
.book-info {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.book-cover-container {
    flex-shrink: 0;
}

.book-details {
    flex: 1;
}

/* Alert Styles */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    border-radius: 4px;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-d-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-icon {
    margin-right: 8px;
}

/* Additional Button Variants */
.btn-outline-primary {
    background: transparent;
    color: #007bff;
    border: 2px solid #007bff;
}

.btn-outline-primary:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.btn-outline-secondary {
    background: transparent;
    color: #6c757d;
    border: 2px solid #6c757d;
}

.btn-outline-secondary:hover {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.btn-outline-danger {
    background: transparent;
    color: #dc3545;
    border: 2px solid #dc3545;
}

.btn-outline-danger:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-outline-success {
    background: transparent;
    color: #28a745;
    border: 2px solid #28a745;
}

.btn-outline-success:hover {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

/* Table Striped Styles */
.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0,0,0,.05);
}

.table-hover tbody tr:hover {
    background-color: rgba(0,0,0,.075);
}

.table-dark {
    background-color: #343a40;
    color: #fff;
}

.table-dark th {
    background-color: #343a40;
    border-color: #454d55;
    color: #fff;
}

/* Text Utilities */
.text-muted {
    color: #6c757d !important;
}

.text-success {
    color: #28a745 !important;
}

.text-end {
    text-align: right !important;
}

.fw-medium {
    font-weight: 500 !important;
}

.fw-bold {
    font-weight: 700 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        margin: 0;
        border-radius: 0;
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Align the grid to the container padding to avoid horizontal clipping */
    .row {
        margin-left: -10px;
        margin-right: -10px;
    }
    
    .header {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .table-container {
        padding: 15px;
    }
    
    .book-cover {
        max-width: 150px;
        margin-bottom: 1rem;
    }
    
    .back-button {
        bottom: 15px;
        right: 15px;
        left: 15px;
        width: auto;
    }
    
    .title {
        max-width: 200px;
    }
    
    .cover {
        width: 30px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .stats {
        gap: 10px;
    }
    
    .stat-number {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 8px;
        font-size: 0.9rem;
    }
    
    .btn,
    .refresh-btn,
    .remove-btn,
    .refresh-all-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .title {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .ean {
        font-size: 0.9rem;
        overflow-wrap: anywhere;
    }

    table {
        table-layout: fixed;
    }
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

.col-md-4 {
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
}

.col-md-8 {
    flex: 0 0 66.666667%;
    max-width: 66.666667%;
}

.order-1 {
    order: 1;
}

.order-2 {
    order: 2;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mb-md-0 {
    margin-bottom: 0 !important;
}

@media (max-width: 768px) {
    .col-md-4,
    .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Utility Classes */
.d-flex {
    display: flex !important;
}

.align-items-center {
    align-items: center !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.text-center {
    text-align: center !important;
}

.img-fluid {
    max-width: 100%;
    height: auto;
}

.rounded {
    border-radius: 0.25rem !important;
}

.shadow {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.me-1 {
    margin-right: 0.25rem !important;
}

.me-2 {
    margin-right: 0.5rem !important;
}

.ms-1 {
    margin-left: 0.25rem !important;
}
