/* Library Management System - Main Stylesheet */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Navigation */
.navbar {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    z-index: 1001;
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-menu {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1001;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav-menu a:hover {
    background-color: #34495e;
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

.container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    overflow: visible;
}

h1 {
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

h2 {
    margin-bottom: 1rem;
    color: #34495e;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.login-box h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.login-box h2 {
    text-align: center;
    color: #7f8c8d;
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: #7f8c8d;
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #667eea;
    color: white;
}

.btn-primary:hover {
    background-color: #5568d3;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

/* Search and Filters */
.search-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Direct input in search-filters (for manage_books.html) */
.search-filters > input[type="text"] {
    flex: 1 1 auto;
    min-width: 300px;
    max-width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.search-filters > button {
    padding: 0.75rem 1.5rem;
    white-space: nowrap;
    flex-shrink: 0;
    height: fit-content;
}

/* Search box wrapper (for browse_books.html) */
.search-box {
    flex: 1 1 auto;
    min-width: 300px;
    max-width: 100%;
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.search-box input {
    flex: 1 1 auto;
    min-width: 200px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.search-box button {
    padding: 0.75rem 1.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 150px;
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.book-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.book-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: #ecf0f1;
}

.book-card-body {
    padding: 1rem;
}

.book-card-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.book-card-author {
    color: #7f8c8d;
    margin-bottom: 0.5rem;
}

.book-card-meta {
    font-size: 0.875rem;
    color: #95a5a6;
    margin-bottom: 0.5rem;
}

.book-card-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-top: 0.5rem;
}

.status-available {
    background-color: #d4edda;
    color: #155724;
}

.status-unavailable {
    background-color: #f8d7da;
    color: #721c24;
}

/* Books List */
.books-list {
    margin-top: 2rem;
}

.book-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.book-item img {
    width: 100px;
    height: 150px;
    object-fit: cover;
    border-radius: 4px;
}

.book-item-info {
    flex: 1;
}

.book-item-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.book-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #ecf0f1;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #7f8c8d;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #2c3e50;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: bold;
}

/* Tables */
.users-table,
.issues-table,
.queues-table {
    margin-top: 2rem;
    overflow-x: auto;
    width: 100%;
    position: relative;
}

.users-table table,
.issues-table table,
.queues-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 600px; /* Ensure table doesn't get too compressed */
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

table th,
table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
}

table td {
    white-space: normal;
    word-wrap: break-word;
    max-width: 200px;
}

table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #2c3e50;
    position: sticky;
    top: 0;
    z-index: 5;
}

table tr:hover {
    background-color: #f8f9fa;
}

/* Action buttons in tables */
table td:last-child {
    white-space: nowrap;
    max-width: none;
}

table td:last-child .btn {
    margin: 0 0.25rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
    z-index: 2001;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* Notifications */
.notifications-list {
    margin-top: 2rem;
}

.notification-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.notification-item.unread {
    border-left: 4px solid #667eea;
    background-color: #f8f9ff;
}

.notification-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.notification-message {
    color: #7f8c8d;
}

.notification-date {
    font-size: 0.875rem;
    color: #95a5a6;
}

.notifications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Profile */
.profile-container {
    margin-top: 2rem;
}

.profile-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 2rem;
}

.profile-info {
    margin-bottom: 2rem;
}

.profile-info-item {
    display: flex;
    padding: 1rem 0;
    border-bottom: 1px solid #ecf0f1;
}

.profile-info-label {
    font-weight: bold;
    width: 150px;
    color: #2c3e50;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.stat-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #7f8c8d;
    margin-top: 0.5rem;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

.stat-box-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.stat-box-label {
    color: #7f8c8d;
    font-size: 0.875rem;
}

.quick-actions {
    margin-top: 2rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #7f8c8d;
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: white;
    border-radius: 4px;
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    min-width: 300px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s;
}

.toast.success {
    border-left: 4px solid #27ae60;
}

.toast.error {
    border-left: 4px solid #e74c3c;
}

.toast.info {
    border-left: 4px solid #3498db;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

/* Categories List */
.categories-list {
    margin-top: 2rem;
}

.category-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.category-description {
    color: #7f8c8d;
}

/* Suggestions List */
.suggestions-list {
    margin-top: 2rem;
}

.suggestion-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.suggestion-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.suggestion-status {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-accepted {
    background-color: #d4edda;
    color: #155724;
}

.status-rejected {
    background-color: #f8d7da;
    color: #721c24;
}

/* Reports */
.reports-container {
    margin-top: 2rem;
}

.report-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 1rem;
}

/* Form Container */
.form-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 2rem;
}

/* Mobile Navigation Toggle */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: nowrap;
    }
    
    .nav-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
        position: absolute;
        top: 100%;
        left: 0;
        background-color: #2c3e50;
        padding: 1rem 20px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 1002;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu a {
        width: 100%;
        padding: 0.75rem 0;
        border-bottom: 1px solid #34495e;
    }
    
    .nav-menu a:last-child {
        border-bottom: none;
    }
    
    .main-content {
        margin: 1rem auto;
        padding: 0 10px;
    }
    
    .container {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    .books-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .profile-stats {
        grid-template-columns: 1fr;
    }
    
    .search-filters {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .search-filters > input {
        width: 100%;
        min-width: 100%;
        box-sizing: border-box;
    }
    
    .search-filters > button {
        width: 100%;
        box-sizing: border-box;
    }
    
    .search-box {
        flex-direction: column;
        min-width: 100%;
        width: 100%;
        gap: 0.75rem;
    }
    
    .search-box input {
        width: 100%;
        min-width: 100%;
        box-sizing: border-box;
    }
    
    .search-box button {
        width: 100%;
        box-sizing: border-box;
    }
    
    .filters {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    
    .filters select {
        width: 100%;
        min-width: 100%;
        box-sizing: border-box;
    }
    
    .book-item {
        flex-direction: column;
        padding: 1rem;
    }
    
    .book-item img {
        width: 100%;
        max-width: 200px;
        height: auto;
        margin: 0 auto;
    }
    
    .book-item-info {
        text-align: center;
    }
    
    .book-item-actions {
        justify-content: center;
        width: 100%;
    }
    
    .book-item-actions .btn {
        flex: 1;
        min-width: 120px;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .page-header .btn {
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    .tabs {
        flex-wrap: wrap;
        overflow-x: auto;
    }
    
    .tab-btn {
        min-width: auto;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
    }
    
    .users-table,
    .issues-table,
    .queues-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: 1rem;
    }
    
    .users-table table,
    .issues-table table,
    .queues-table table {
        min-width: 800px;
    }
    
    table th,
    table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
    
    table td:last-child {
        position: sticky;
        right: 0;
        background-color: white;
        box-shadow: -2px 0 4px rgba(0,0,0,0.1);
    }
    
    table tr:hover td:last-child {
        background-color: #f8f9fa;
    }
    
    .category-item,
    .suggestion-item,
    .notification-item {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .category-item > div:last-child,
    .suggestion-item > div:last-child {
        width: 100%;
    }
    
    .suggestion-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .profile-info-item {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .profile-info-label {
        width: 100%;
    }
    
    .notifications-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    #toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .login-container {
        padding: 10px;
    }
    
    .login-box {
        padding: 1.5rem;
    }
    
    .login-box h1 {
        font-size: 1.5rem;
    }
    
    .login-box h2 {
        font-size: 0.9rem;
    }
    
    #loginForm .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    #otpSection .form-actions {
        flex-direction: column;
    }
    
    #otpSection .btn {
        width: 100%;
    }
    
    .stat-box-value {
        font-size: 2rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .nav-brand a {
        font-size: 1.2rem;
    }
    
    .main-content {
        margin: 0.5rem auto;
        padding: 0 5px;
    }
    
    .container {
        padding: 0.75rem;
    }
    
    .book-card-body {
        padding: 0.75rem;
    }
    
    .book-card-title {
        font-size: 1rem;
    }
    
    .book-card-author {
        font-size: 0.9rem;
    }
    
    /* Prevent text overflow */
    .book-card-title,
    .book-item-title,
    .category-name,
    .suggestion-title {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    .modal-content {
        padding: 0.75rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.625rem;
        font-size: 0.95rem;
    }
    
    .search-filters {
        margin-bottom: 1rem;
    }
    
    .search-filters > input,
    .search-box input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Better text wrapping on very small screens */
    * {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Ensure images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Better table handling on small screens */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    table th,
    table td {
        white-space: normal;
        word-wrap: break-word;
    }
}

