/* Custom styles to complement Bootstrap */

:root {
    --primary-color: #8b4513;        /* Saddle brown - book leather */
    --primary-dark: #5d2f0e;         /* Darker brown */
    --secondary-color: #d4a574;      /* Tan - aged paper */
    --accent-color: #c9a961;         /* Gold - gilt edges */
    --text-dark: #2c2416;            /* Dark brown text */
    --text-light: #f5f1e8;           /* Cream */
    --background: #faf8f3;           /* Off-white paper */
    --card-bg: #ffffff;
    --border-color: #e0d5c7;
}

/* Smooth scrolling for better UX */
html {
    scroll-behavior: smooth;
}

/* Better focus visibility for accessibility */
*:focus {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    background: linear-gradient(135deg, var(--background) 0%, #f0ebe3 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: var(--text-dark);
}

main {
    flex: 1;
}

/* Override Bootstrap navbar with bookish theme */
.navbar-dark {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border-bottom: 3px solid var(--accent-color);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
    font-family: 'Georgia', serif;
    letter-spacing: 0.5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.navbar-brand i {
    color: var(--accent-color);
}

.nav-link {
    transition: all 0.3s ease;
    font-family: 'Georgia', serif;
    position: relative;
}

.nav-link:hover {
    color: var(--accent-color) !important;
    transform: translateY(-1px);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after {
    width: 80%;
}

/* Footer stays at bottom */
.footer {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: var(--text-light);
    border-top: 3px solid var(--accent-color);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
}

/* Cards with bookish styling */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(139, 69, 19, 0.1), 0 1px 3px rgba(139, 69, 19, 0.08);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 1.5rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(139, 69, 19, 0.15), 0 2px 6px rgba(139, 69, 19, 0.12);
}

.card-header {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #e8d4b0 100%);
    color: var(--text-dark);
    border-bottom: none; /* Remove double border */
    font-weight: 600;
    font-size: 1.25rem;
    padding: 1rem 1.5rem;
    margin: -1.5rem -1.5rem 0 -1.5rem; /* Extend header to card edges */
    border-radius: 8px 8px 0 0;
}

/* Buttons with book-inspired design */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    border-bottom: 3px solid var(--primary-dark);
    color: var(--text-light);
    font-family: 'Georgia', serif;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #4a2509 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-success {
    background: linear-gradient(135deg, #6b8e23 0%, #556b2f 100%);
    border: none;
    border-bottom: 3px solid #556b2f;
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #556b2f 0%, #3f5122 100%);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(135deg, #8b7355 0%, #6b5a47 100%);
    border: none;
    border-bottom: 3px solid #6b5a47;
    color: var(--text-light);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #6b5a47 0%, #5a4a39 100%);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #a0522d 0%, #8b3a1f 100%);
    border: none;
    border-bottom: 3px solid #8b3a1f;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #8b3a1f 0%, #6b2b16 100%);
    transform: translateY(-2px);
}

.btn-warning {
    background: linear-gradient(135deg, #daa520 0%, #b8860b 100%);
    border: none;
    border-bottom: 3px solid #b8860b;
    color: var(--text-dark);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #b8860b 0%, #9a7209 100%);
    transform: translateY(-2px);
}

/* Form styling */
.form-control, .form-select {
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-family: 'Georgia', serif;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fefdfb;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(201, 169, 97, 0.25);
}

.form-group label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-family: 'Georgia', serif;
}

/* Autocomplete results styling */
.autocomplete-results {
    position: relative;
}

.autocomplete-item {
    cursor: pointer;
    font-family: 'Georgia', serif;
}

.autocomplete-item:hover {
    background-color: var(--secondary-color);
    color: var(--text-dark);
}

/* Stats cards for home page */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    text-align: center;
    background: linear-gradient(135deg, var(--card-bg) 0%, #f9f7f4 100%);
    padding: 2rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(139, 69, 19, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px rgba(139, 69, 19, 0.15);
    border-color: var(--accent-color);
}

.stat-number {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary-color);
    font-family: 'Georgia', serif;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.stat-label {
    color: var(--text-dark);
    margin-top: 0.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    font-family: 'Georgia', serif;
}

/* Tables */
.table {
    font-family: 'Georgia', serif;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(139, 69, 19, 0.1);
}

.table thead th {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #e8d4b0 100%);
    color: var(--text-dark);
    border-bottom: 2px solid var(--accent-color);
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: #faf8f5;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border-left: 4px solid;
    font-family: 'Georgia', serif;
}

.alert-success {
    border-left-color: #6b8e23;
    background-color: #f0f8e8;
}

.alert-info {
    border-left-color: var(--accent-color);
    background-color: #fdf9f0;
}

.alert-warning {
    border-left-color: #daa520;
    background-color: #fdf6e8;
}

.alert-danger {
    border-left-color: #a0522d;
    background-color: #fdf0eb;
}

/* Error lists */
.errorlist {
    list-style: none;
    color: #a0522d;
    margin-top: 0.5rem;
    padding-left: 0;
    font-family: 'Georgia', serif;
}

/* Pagination */
.pagination .page-link {
    color: var(--primary-color);
    border-color: var(--border-color);
    font-family: 'Georgia', serif;
}

.pagination .page-link:hover {
    background-color: var(--secondary-color);
    border-color: var(--accent-color);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Tabs */
.nav-tabs {
    border-bottom: 2px solid var(--accent-color);
    font-family: 'Georgia', serif;
}

.nav-tabs .nav-link {
    color: var(--text-dark);
    border: 1px solid transparent;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-tabs .nav-link:hover {
    border-color: var(--border-color);
    background-color: var(--background);
    color: var(--primary-color);
}

.nav-tabs .nav-link.active {
    color: var(--text-dark);
    background: linear-gradient(135deg, var(--secondary-color) 0%, #e8d4b0 100%);
    border-color: var(--accent-color) var(--accent-color) transparent;
    border-width: 2px 2px 0 2px;
    font-weight: 600;
}

.tab-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
}

/* Mobile tab icons */
@media (max-width: 767px) {
    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 1.25rem;
    }

    .nav-tabs .nav-link i {
        display: block;
    }
}

/* Header buttons styling */
.header-buttons {
    display: flex;
    gap: 0.5rem;
}

.header-buttons .btn {
    padding: 0.375rem 0.75rem;
}

@media (max-width: 767px) {
    .header-buttons .btn {
        min-width: 40px;
        padding: 0.5rem;
    }
}

/* Item list styling for homepage cards */
.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item-list li {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
}

.item-list li:last-child {
    border-bottom: none;
}

.item-list li:hover {
    background-color: #fafafa;
}

/* Homepage dashboard cards - ultra-clean minimalist design */
.dashboard-card {
    display: block;
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dashboard-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid #f5f5f5;
    background: white;
}

.dashboard-card-header:hover {
    opacity: 0.9;
}

.dashboard-card-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border-radius: 8px;
    background: #f8f8f8;
}

.dashboard-card-title {
    flex: 1;
    min-width: 0;
}

.dashboard-card-title h3 {
    margin: 0 0 0.15rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.dashboard-card-count {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 400;
    color: #999;
}

.dashboard-card-body {
    background: white;
}

.dashboard-card-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dashboard-card-list li {
    padding: 0;
    transition: background-color 0.12s ease;
    border-bottom: 1px solid #fafafa;
}

.dashboard-card-list li:last-child {
    border-bottom: none;
}

.dashboard-card-list li:hover {
    background-color: #fafafa;
}

.dashboard-card-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: #555;
    text-decoration: none;
    gap: 1rem;
}

.dashboard-card-list a:hover {
    color: rgba(var(--card-color-r), var(--card-color-g), var(--card-color-b), 0.85);
}

.dashboard-card-list a span:first-child {
    flex: 1;
    font-weight: 400;
    font-size: 0.9rem;
}

.dashboard-card-list a span:last-child {
    color: #aaa;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.dashboard-card-empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: #bbb;
    font-style: italic;
    margin: 0;
    font-size: 0.875rem;
}

/* Mobile responsiveness */
@media (max-width: 767px) {
    .dashboard-card-header {
        padding: 1rem 1rem;
        gap: 0.875rem;
    }

    .dashboard-card-icon {
        width: 42px;
        height: 42px;
        font-size: 1.35rem;
    }

    .dashboard-card-title h3 {
        font-size: 1rem;
    }

    .dashboard-card-count {
        font-size: 0.75rem;
    }

    .dashboard-card-list a {
        padding: 0.65rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .dashboard-card-list a span:first-child {
        font-size: 0.875rem;
    }

    .dashboard-card-list a span:last-child {
        font-size: 0.75rem;
    }

    .dashboard-card-empty {
        padding: 1.75rem 1rem;
        font-size: 0.85rem;
    }
}

/* Print styles for better printouts */
@media print {
    /* Hide navigation, buttons, and interactive elements */
    .navbar,
    .footer,
    .btn,
    button,
    .header-buttons,
    .back-to-top,
    .expand-toggle,
    #keyboard-shortcuts-modal,
    .pagination,
    .detail-tabs {
        display: none !important;
    }

    /* Show all tab content when printing */
    .tab-pane {
        display: block !important;
        page-break-inside: avoid;
    }

    .section-header {
        display: block !important;
        font-size: 1.25rem;
        font-weight: 600;
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
        page-break-after: avoid;
    }

    /* Remove backgrounds and shadows for cleaner print */
    body {
        background: white !important;
    }

    .card,
    .card-header,
    .dashboard-card,
    .table {
        box-shadow: none !important;
        border: 1px solid #333 !important;
    }

    /* Ensure good contrast for print */
    body,
    .card,
    .table {
        color: #000 !important;
        background: white !important;
    }

    /* Keep page breaks sensible */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }

    table, dl {
        page-break-inside: avoid;
    }

    /* Expand URLs for links */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Don't show URLs for internal navigation */
    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }

    /* Better spacing for print */
    .container {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }

    main {
        margin: 0;
        padding: 1rem;
    }
}
