/* Classy Bookshelf Scanner - Sophisticated & Elegant */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Source+Sans+Pro:wght@300;400;600;700&display=swap');

:root {
    /* Sophisticated Color Palette */
    --rich-navy: #1a1d29;
    --deep-charcoal: #2c2f3a;
    --warm-gray: #8b8b8b;
    --light-gray: #f5f5f5;
    --cream: #faf9f7;
    --ivory: #ffffff;
    
    --gold: #d4af37;
    --gold-light: #e6c547;
    --bronze: #cd7f32;
    --copper: #b87333;
    
    --sage: #9caf88;
    --forest: #6b7c32;
    --olive: #808000;
    
    --text-primary: #2c2f3a;
    --text-secondary: #5a5a5a;
    --text-muted: #8b8b8b;
    --text-light: #b8b8b8;
    
    --shadow-subtle: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-medium: 0 8px 24px rgba(0, 0, 0, 0.15);
    --shadow-deep: 0 16px 32px rgba(0, 0, 0, 0.2);
    
    --border-subtle: #e8e8e8;
    --border-soft: #d8d8d8;
    
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --font-serif: 'Libre Baskerville', 'Times New Roman', serif;
    --font-script: 'Crimson Text', 'Times New Roman', serif;
    --font-sans: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, #f8f6f0 0%, #f0ede5 100%);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Elegant Background Pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(212, 175, 55, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(156, 175, 136, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 40% 60%, rgba(44, 62, 80, 0.01) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Sophisticated Header */
header {
    text-align: center;
    margin-bottom: 4rem;
    padding: 4rem 3rem;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-deep);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="elegant" width="50" height="50" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="0.5" fill="rgba(212,175,55,0.1)"/><circle cx="10" cy="10" r="0.3" fill="rgba(212,175,55,0.05)"/><circle cx="40" cy="40" r="0.3" fill="rgba(212,175,55,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23elegant)"/></svg>');
    opacity: 0.4;
}

header h1 {
    font-family: var(--font-serif);
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--ivory);
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-family: var(--font-script);
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.85);
    font-style: italic;
    position: relative;
    z-index: 1;
    font-weight: 400;
}

/* Refined Button System */
.btn {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.875rem 2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    box-shadow: var(--shadow-subtle);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--bronze) 100%);
    color: var(--rich-navy);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
}

.btn-secondary {
    background: var(--ivory);
    color: var(--text-primary);
    border: 2px solid var(--border-soft);
}

.btn-secondary:hover {
    background: var(--light-gray);
    border-color: var(--gold);
}

.btn-success {
    background: linear-gradient(135deg, var(--sage) 0%, var(--forest) 100%);
    color: var(--ivory);
    border: 1px solid rgba(156, 175, 136, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, var(--forest) 0%, var(--sage) 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    color: var(--ivory);
    border: 1px solid rgba(192, 57, 43, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #a93226 0%, #c0392b 100%);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Elegant Section Styling */
section {
    background: var(--ivory);
    border-radius: var(--radius-lg);
    padding: 3rem;
    margin-bottom: 3rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-subtle);
    position: relative;
}

section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold), var(--sage), var(--bronze));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Sophisticated Input Tabs */
.input-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 3rem;
    justify-content: center;
    background: var(--light-gray);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
}

.tab-btn {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 1rem 2rem;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    letter-spacing: 0.5px;
}

.tab-btn.active {
    background: var(--ivory);
    color: var(--text-primary);
    box-shadow: var(--shadow-subtle);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}

/* Refined Camera Container */
.camera-container {
    position: relative;
    background: #2c3e50;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--border-subtle);
}

#video {
    width: 100%;
    height: 450px;
    object-fit: cover;
    display: block;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.detection-overlay {
    position: absolute;
    border: 3px solid var(--gold);
    border-radius: var(--radius);
    background: rgba(212, 175, 55, 0.15);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.4);
    display: none;
}

/* Camera Controls */
.camera-controls {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}

/* Elegant Upload Area */
.upload-area {
    border: 3px dashed var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 4rem;
    text-align: center;
    background: var(--light-gray);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--gold);
    background: var(--ivory);
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.upload-icon {
    font-size: 4rem;
    color: var(--text-muted);
}

.upload-content h3 {
    font-family: var(--font-serif);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Uploaded Image */
.uploaded-image-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--border-subtle);
}

#uploadedImage {
    width: 100%;
    height: auto;
    display: block;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Photo Controls */
.photo-controls {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}

/* Processing Section */
.processing-container {
    display: flex;
    align-items: center;
    gap: 3rem;
    padding: 3rem;
    background: var(--light-gray);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
}

.captured-image-container {
    flex: 0 0 220px;
}

.captured-image-container img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-subtle);
}

.processing-status {
    flex: 1;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-soft);
    border-top: 4px solid var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#processingText {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Book Details */
.book-info {
    display: flex;
    gap: 3rem;
    margin-bottom: 3rem;
}

.book-cover {
    flex: 0 0 220px;
}

.book-cover img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-medium);
}

.book-metadata {
    flex: 1;
}

.book-metadata h4 {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.book-metadata p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.book-metadata .author {
    font-family: var(--font-script);
    font-style: italic;
    color: var(--gold);
    font-weight: 600;
    font-size: 1.2rem;
}

.book-metadata .isbn {
    font-family: 'Courier New', monospace;
    background: var(--light-gray);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    font-size: 0.9rem;
    border: 1px solid var(--border-subtle);
}

.book-metadata .published {
    color: var(--text-muted);
}

.book-metadata .description {
    line-height: 1.8;
    color: var(--text-primary);
    font-size: 1rem;
}

/* Book Actions */
.book-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Library Section */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    gap: 2rem;
}

.library-title-section {
    display: flex;
    align-items: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.library-title-section h3 {
    font-family: var(--font-serif);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.library-search {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    padding: 1rem 1.25rem 1rem 3rem;
    border: 2px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--ivory);
    color: var(--text-primary);
    width: 350px;
    transition: all 0.3s ease;
    font-weight: 400;
}

.search-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.library-actions {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

/* Library Grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.book-card {
    background: var(--ivory);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--border-subtle);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.book-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold), var(--sage));
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
    border-color: var(--border-soft);
}

.book-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-subtle);
}

.book-card h4 {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.book-card .author {
    font-family: var(--font-script);
    font-style: italic;
    color: var(--gold);
    margin-bottom: 0.75rem;
    font-weight: 500;
    font-size: 1rem;
}

.book-card .isbn {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--light-gray);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-subtle);
}

.book-card .added-date {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

.empty-library {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.25rem;
    font-family: var(--font-script);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 2rem 1rem;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    .book-info {
        flex-direction: column;
    }
    
    .library-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .library-title-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input {
        width: 100%;
    }
    
    .library-grid {
        grid-template-columns: 1fr;
    }
    
    .camera-controls,
    .photo-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Elegant Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--light-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--border-soft);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Sophisticated Text Selection */
::selection {
    background: var(--gold);
    color: var(--rich-navy);
}

::-moz-selection {
    background: var(--gold);
    color: var(--rich-navy);
}

/* Replace Modal Styling */
.replace-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.replace-modal-content {
    background: var(--paper-white);
    border-radius: 24px;
    max-width: 600px;
    max-height: 80vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--deep-shadow);
    border: 1px solid var(--subtle-shadow);
    overflow: hidden;
}

.replace-modal-content h2 {
    font-family: var(--elegant-font);
    font-size: 1.8rem;
    color: var(--paper-white);
    text-align: center;
    padding: 1.5rem;
    margin: 0;
    background: linear-gradient(135deg, var(--deep-navy) 0%, var(--charcoal) 100%);
    border-bottom: 1px solid var(--subtle-shadow);
    font-weight: 600;
}

.replace-modal-content > p {
    padding: 1rem 1.5rem 0;
    margin: 0;
    color: var(--charcoal);
    font-size: 1.1rem;
    text-align: center;
}

.book-options {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    max-height: 400px;
}

.book-option {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--soft-gray);
    border-radius: 16px;
    border: 1px solid var(--subtle-shadow);
    cursor: pointer;
    transition: all 0.2s ease;
}

.book-option:hover {
    border-color: var(--sage-green);
    transform: translateY(-2px);
    box-shadow: var(--soft-shadow);
}

.book-option.selected {
    border-color: var(--sage-green);
    background: var(--paper-white);
    box-shadow: var(--medium-shadow);
}

.book-option img {
    width: 60px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: var(--soft-shadow);
}

.book-option-info {
    flex: 1;
}

.book-option-info h4 {
    font-family: var(--elegant-font);
    font-size: 1.2rem;
    color: var(--charcoal);
    margin-bottom: 0.5rem;
    line-height: 1.3;
    font-weight: 600;
}

.book-option-info p {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    color: var(--light-charcoal);
}

.book-option-info strong {
    color: var(--sage-green);
}

.replace-modal-buttons {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--soft-gray);
    border-top: 1px solid var(--subtle-shadow);
    position: sticky;
    bottom: 0;
    justify-content: center;
    flex-shrink: 0;
}

.btn-replace-cancel {
    font-family: var(--body-font);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--warm-gray) 0%, var(--light-charcoal) 100%);
    color: var(--paper-white);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-replace-cancel:hover {
    background: linear-gradient(135deg, var(--light-charcoal) 0%, var(--warm-gray) 100%);
    transform: translateY(-1px);
    box-shadow: var(--soft-shadow);
}

.btn-replace-confirm {
    font-family: var(--body-font);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--burnt-orange) 0%, #a03c0a 100%);
    color: var(--paper-white);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-replace-confirm:hover:not(:disabled) {
    background: linear-gradient(135deg, #a03c0a 0%, var(--burnt-orange) 100%);
    transform: translateY(-1px);
    box-shadow: var(--soft-shadow);
}

.btn-replace-confirm:disabled {
    background: var(--subtle-shadow);
    color: var(--light-charcoal);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Responsive Replace Modal */
@media (max-width: 768px) {
    .replace-modal {
        padding: 1rem;
    }
    
    .replace-modal-content {
        max-height: 90vh;
    }
    
    .book-option {
        flex-direction: column;
        text-align: center;
    }
    
    .book-option img {
        align-self: center;
    }
    
    .replace-modal-buttons {
        flex-direction: column;
    }
    
    .btn-replace-cancel,
    .btn-replace-confirm {
        width: 100%;
    }
}

/* Classic Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--cream);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-brown);
    border-radius: 6px;
    border: 2px solid var(--cream);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dark-brown);
}

/* Vintage Text Selection */
::selection {
    background: var(--gold);
    color: var(--charcoal);
}

::-moz-selection {
    background: var(--gold);
    color: var(--charcoal);
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Section Styles */
section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

/* Input Options */
.input-options {
    margin-bottom: 30px;
}

.input-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 24px;
    border: 2px solid #007bff;
    background: white;
    color: #007bff;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active,
.tab-btn:hover {
    background: #007bff;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,123,255,0.3);
}

/* Camera Section */
.camera-container {
    position: relative;
    max-width: 800px;
    margin: 0 auto 30px;
    border-radius: 15px;
    overflow: hidden;
    background: #f8f9fa;
}

#video {
    width: 100%;
    height: 500px;
    object-fit: cover;
    display: block;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.detection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.book-detection {
    position: absolute;
    border: 3px solid #28a745;
    border-radius: 8px;
    background: rgba(40, 167, 69, 0.1);
    backdrop-filter: blur(2px);
}

.book-label {
    position: absolute;
    top: -30px;
    left: 0;
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Photo Upload Section */
.upload-container {
    max-width: 800px;
    margin: 0 auto;
}

.upload-area {
    border: 3px dashed #007bff;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    background: #f8f9ff;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #0056b3;
    background: #e6f3ff;
}

.upload-area.dragover {
    border-color: #28a745;
    background: #e6ffe6;
}

.upload-content .upload-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 20px;
}

.upload-content h3 {
    margin-bottom: 10px;
    color: #333;
}

.upload-content p {
    color: #666;
    margin-bottom: 20px;
}

.uploaded-image-container {
    position: relative;
    margin-bottom: 20px;
}

.uploaded-image-container img {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.photo-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-width: 140px;
    justify-content: center;
}

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

.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,123,255,0.3);
}

.btn-secondary {
    background: linear-gradient(45deg, #6c757d, #545b62);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108,117,125,0.3);
}

.btn-success {
    background: linear-gradient(45deg, #28a745, #1e7e34);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40,167,69,0.3);
}

.btn-danger {
    background: linear-gradient(45deg, #dc3545, #c82333);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220,53,69,0.3);
}

/* Processing Section */
.processing-container {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.captured-image-container {
    flex: 1;
    max-width: 300px;
}

.captured-image-container img {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.processing-status {
    flex: 1;
    text-align: center;
    min-width: 200px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results Section */
.book-info {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.book-cover {
    flex-shrink: 0;
}

.book-cover img {
    width: 150px;
    height: 200px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.book-metadata {
    flex: 1;
    min-width: 300px;
}

.book-metadata h4 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.book-metadata p {
    margin-bottom: 8px;
    line-height: 1.5;
}

.author {
    font-style: italic;
    color: #666;
}

.isbn, .published {
    font-size: 0.9rem;
    color: #888;
}

.description {
    margin-top: 15px;
    color: #555;
}

.book-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.extracted-text {
    text-align: center;
}

.text-content {
    margin: 20px 0;
}

#ocrResult {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-family: monospace;
    font-size: 14px;
    resize: vertical;
}

/* Library Section */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.library-title-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
}

.library-search {
    position: relative;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.search-input:focus {
    border-color: #007bff;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.search-input::placeholder {
    color: #6c757d;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #6c757d;
    pointer-events: none;
}

.library-header h3 {
    font-size: 1.5rem;
    color: #333;
}

.library-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.book-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 0;
    text-align: center;
    transition: transform 0.3s ease;
    border: 1px solid #e9ecef;
    position: relative;
    overflow: hidden;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.book-card-content {
    padding: 15px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.book-card-content:hover {
    background: rgba(0,0,0,0.02);
}

.book-card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    gap: 5px;
}

.book-card:hover .book-card-actions {
    opacity: 1;
}

.btn-remove {
    background: #dc3545;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-remove:hover {
    background: #c82333;
    transform: scale(1.1);
}

.btn-remove .icon {
    font-size: 14px;
}

.btn-locate {
    background: #ff6600;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-locate:hover {
    background: #e55a00;
    transform: scale(1.1);
}

.btn-locate .icon {
    font-size: 14px;
}

.btn-replace {
    background: #007bff;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-replace:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.btn-replace .icon {
    font-size: 14px;
}

.no-image {
    width: 80px;
    height: 120px;
    background: #e9ecef;
    border-radius: 5px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #6c757d;
}

.book-card img {
    width: 80px;
    height: 120px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 10px;
}

.book-card h5 {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #333;
    line-height: 1.3;
}

.book-card p {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 3px;
}

.empty-library {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-library p {
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    section {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .book-info {
        flex-direction: column;
        text-align: center;
    }
    
    .book-metadata {
        min-width: auto;
    }
    
    .library-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .library-actions {
        justify-content: center;
    }
    
    .btn {
        min-width: auto;
        padding: 10px 20px;
    }
}

@media (max-width: 480px) {
    .camera-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .book-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .library-actions {
        flex-direction: column;
    }
}

/* Replace Modal Styles */
.replace-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.replace-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.replace-modal h2 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

.book-options {
    display: grid;
    gap: 16px;
    margin: 20px 0;
}

.book-option {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 16px;
}

.book-option:hover {
    border-color: #007bff;
    background-color: #f8f9fa;
}

.book-option.selected {
    border-color: #007bff;
    background-color: #e7f3ff;
}

.book-option img {
    width: 60px;
    height: auto;
    border-radius: 4px;
}

.book-option-info {
    flex: 1;
}

.book-option-info h4 {
    margin: 0 0 8px 0;
    color: #333;
}

.book-option-info p {
    margin: 4px 0;
    color: #666;
    font-size: 14px;
}

.replace-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.replace-modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-replace-confirm {
    background: #007bff;
    color: white;
}

.btn-replace-confirm:hover {
    background: #0056b3;
}

.btn-replace-confirm:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.btn-replace-cancel {
    background: #6c757d;
    color: white;
}

.btn-replace-cancel:hover {
    background: #5a6268;
}

/* Search highlighting */
mark {
    background-color: #fff3cd;
    color: #856404;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 500;
}
