/* Reset en basis stijlen */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #8B4513;
    --secondary-color: #D2691E;
    --background-color: #FAF0E6;
    --text-color: #333;
    --border-color: #DDD;
    --error-color: #DC3545;
    --success-color: #28A745;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* Login pagina */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #FAF0E6 0%, #F5DEB3 100%);
}

.login-box {
    background: white;
    padding: 30px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 24px;
}

.book-icon {
    text-align: center;
    font-size: 48px;
    margin-bottom: 20px;
}

/* Form stijlen */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    transition: border-color 0.3s;
    background-color: white;
}

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

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary:hover {
    background-color: #6B3410;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #6C757D;
    color: white;
}

.btn-secondary:hover {
    background-color: #5A6268;
}

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

.btn-danger:hover {
    background-color: #C82333;
}

.btn-logout {
    background: none;
    border: 1px solid white;
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

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

/* Error en info berichten */
.error-message {
    color: var(--error-color);
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

.login-info {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

header h1 {
    font-size: 20px;
}

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

/* Zoek sectie */
.search-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    display: flex;
    min-width: 250px;
}

.search-box input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 16px;
}

.btn-search {
    padding: 12px 20px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    font-size: 18px;
}

.btn-search:hover {
    background-color: #B8560E;
}

/* Sorteer sectie */
.sort-section {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.sort-section label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.sort-dropdown {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 180px;
}

.sort-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(138, 77, 46, 0.1);
}

.filter-info {
    margin-bottom: 15px;
    color: #666;
    font-size: 14px;
}

.clear-search-section {
    margin-bottom: 20px;
    text-align: center;
}

.btn-clear-search {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-clear-search:hover {
    background-color: #45A049;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Boeken lijst */
.books-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.book-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.book-cover {
    width: 80px;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.book-cover-placeholder {
    width: 80px;
    height: 120px;
    background: linear-gradient(135deg, #e3e3e3, #c7c7c7);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #888;
    text-align: center;
    line-height: 1.2;
}

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

.book-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.book-author {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.book-info {
    font-size: 12px;
    color: #999;
}

.book-isbn {
    font-family: monospace;
    background: #F5F5F5;
    padding: 2px 6px;
    border-radius: 3px;
}

.book-location {
    font-size: 11px;
    color: #888;
    margin-top: 8px;
}

.book-added-by {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    font-style: italic;
}

.search-found-in {
    font-size: 11px;
    color: #2E7D32;
    background-color: #E8F5E8;
    padding: 4px 8px;
    border-radius: 12px;
    margin-top: 6px;
    display: inline-block;
    font-weight: 500;
    border: 1px solid #C8E6C9;
}

.book-isbn {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
    font-family: 'Courier New', monospace;
}

/* ISBN lookup stijlen */
.isbn-input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.isbn-input-group input {
    flex: 3;
    min-width: 200px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    letter-spacing: 0.8px;
    padding: 14px 12px;
}

.btn-lookup {
    padding: 12px 12px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-lookup:hover {
    background-color: #B8560E;
    transform: translateY(-1px);
}

.btn-lookup:disabled {
    background-color: #CCC;
    cursor: not-allowed;
    transform: none;
}

.btn-scan {
    padding: 12px 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-scan:hover {
    background-color: #45A049;
    transform: translateY(-1px);
}

.btn-scan:disabled {
    background-color: #CCC;
    cursor: not-allowed;
    transform: none;
}

.isbn-status {
    margin-top: 8px;
    font-size: 12px;
    padding: 12px;
    border-radius: 4px;
    display: none;
    white-space: pre-line;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.4;
}

.isbn-status.success {
    background-color: #D4EDDA;
    color: #155724;
    border: 1px solid #C3E6CB;
    display: block;
}

.isbn-status.error {
    background-color: #F8D7DA;
    color: #721C24;
    border: 1px solid #F5C6CB;
    display: block;
}

.isbn-status.loading {
    background-color: #D1ECF1;
    color: #0C5460;
    border: 1px solid #BEE5EB;
    display: block;
}

.isbn-status.info {
    background-color: #D1ECF1;
    color: #0C5460;
    border: 1px solid #BEE5EB;
    display: block;
}

.isbn-status.warning {
    background-color: #FFF3CD;
    color: #856404;
    border: 1px solid #FFECB5;
    display: block;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: white;
    margin: 20px auto;
    padding: 0;
    border-radius: var(--radius);
    max-width: 600px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.modal-header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    opacity: 0.8;
}

#bookForm {
    padding: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.modal-footer {
    padding: 20px;
    background: #F8F9FA;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Boek details */
.book-details {
    padding: 20px;
}

.book-detail-header {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.book-detail-cover {
    width: 120px;
    height: 180px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.book-detail-cover-placeholder {
    width: 120px;
    height: 180px;
    background: linear-gradient(135deg, #e3e3e3, #c7c7c7);
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #888;
    text-align: center;
    line-height: 1.2;
}

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

.detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid #EEE;
}

.detail-label {
    font-weight: 600;
    min-width: 120px;
    color: #666;
}

.detail-value {
    flex: 1;
    color: var(--text-color);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Responsive design */
@media (min-width: 768px) {
    .login-box {
        padding: 40px;
    }
    
    .login-box h1 {
        font-size: 28px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .modal-content {
        margin: 50px auto;
        width: calc(100% - 100px);
    }
}

/* Extra responsive voor ISBN veld op kleine schermen */
@media (max-width: 480px) {
    .isbn-input-group {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .isbn-input-group input {
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    .btn-scan,
    .btn-lookup {
        flex: 1;
        font-size: 12px;
        padding: 10px 8px;
    }
    
    /* Sorteer sectie op mobiel */
    .search-section {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .sort-section {
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .sort-dropdown {
        min-width: 150px;
        flex: 1;
    }
}

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

.book-card {
    animation: fadeIn 0.3s ease-out;
}

/* Barcode Scanner Modal */
.scanner-modal {
    max-width: 500px;
    max-height: 80vh;
}

.scanner-container {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
    min-height: 300px;
}

.scanner-viewport {
    width: 100%;
    height: 100%;
    position: relative;
}

.scanner-viewport canvas,
.scanner-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-guide {
    text-align: center;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.scanner-guide p {
    margin: 10px 0 0 0;
    font-size: 14px;
}

.scanner-line {
    width: 200px;
    height: 2px;
    background: #FF0000;
    margin: 0 auto;
    animation: scanLine 2s ease-in-out infinite;
    box-shadow: 0 0 10px #FF0000;
}

@keyframes scanLine {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.scanner-controls {
    padding: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
    background: #F8F9FA;
    border-top: 1px solid var(--border-color);
}

.scanner-controls .btn {
    width: auto;
    min-width: 120px;
}

/* Responsive scanner */
@media (max-width: 600px) {
    .scanner-modal {
        margin: 10px;
        width: calc(100% - 20px);
        max-height: 90vh;
    }
    
    .scanner-container {
        min-height: 250px;
    }
    
    .scanner-line {
        width: 150px;
    }
    
    .scanner-controls {
        flex-direction: column;
    }
    
    .scanner-controls .btn {
        width: 100%;
    }
    
    /* Kleinere buttons in modal footer voor mobiel */
    .modal-footer .btn {
        padding: 8px 16px;
        font-size: 14px;
        min-width: 80px;
    }
    
    .modal-footer {
        padding: 15px;
        gap: 8px;
        flex-wrap: wrap;
    }
}

/* Print stijlen */
@media print {
    header,
    .search-section,
    .btn,
    .modal {
        display: none !important;
    }
    
    .books-list {
        grid-template-columns: 1fr;
    }
    
    .book-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #DDD;
    }
}