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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

header {
    background-color: #007bff;
    color: white;
    padding: 1rem;
    text-align: center;
    position: relative;
}

header .site-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    display: block;
    margin: 0 auto 0.5rem;
    border-radius: 12px;
    background: white;
    padding: 8px;
}

header h1 {
    margin-bottom: 0.5rem;
}

.back-link {
    position: absolute;
    left: 1rem;
    top: 1rem;
    color: white;
    text-decoration: none;
    font-size: 1rem;
}

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

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 2rem;
    margin-bottom: 2rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    transition: background-color 0.3s;
}

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

.btn-primary:hover {
    background-color: #0056b3;
}

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

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

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

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.hidden {
    display: none !important;
}

.message {
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
}

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

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

/* QR Reader */
.qr-reader {
    width: 100%;
    max-width: 400px;
    height: 300px;
    margin: 1rem auto;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
}

/* Book Bug */
.book-bug {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
}

.bug-avatar {
    font-size: 3rem;
    margin-right: 1rem;
}

.bug-message {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Admin Navigation */
.admin-nav {
    display: flex;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    overflow-x: auto;
}

.admin-nav a {
    padding: 1rem;
    text-decoration: none;
    color: #333;
    border-bottom: 3px solid transparent;
    transition: border-color 0.3s;
}

.admin-nav a.active {
    border-bottom-color: #007bff;
    color: #007bff;
}

.admin-nav a:hover {
    background-color: #f8f9fa;
}

.admin-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 2rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    text-align: center;
}

.stat-card h3 {
    margin-bottom: 0.5rem;
    color: #666;
}

.stat-card p {
    font-size: 2rem;
    font-weight: bold;
    color: #007bff;
}

/* Lists */
#loans-list, #students-list, #books-list, #loans-list-admin {
    margin-top: 1rem;
}

.loan-item, .student-item, .book-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.loan-item.overdue {
    border-color: #dc3545;
    background-color: #f8d7da;
}

.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.status-available {
    background-color: #d4edda;
    color: #155724;
}

.status-borrowed {
    background-color: #fff3cd;
    color: #856404;
}

.status-overdue {
    background-color: #f8d7da;
    color: #721c24;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

form label {
    font-weight: bold;
}

form input, form select {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

/* QR Generator */
#qr-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.qr-item {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1rem;
    text-align: center;
}

.qr-item img {
    max-width: 100%;
    height: auto;
}

.qr-item .code {
    font-family: monospace;
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    margin: 0.5rem 0;
}

/* QR Grid for home page */
.qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }
    .qr-item, .qr-item * {
        visibility: visible;
    }
    .qr-item {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        page-break-inside: avoid;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 1rem 0.5rem;
    }
    .card {
        padding: 1rem;
    }
    .button-group {
        flex-direction: column;
    }
    .admin-nav {
        flex-wrap: wrap;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}