* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    background: #f4f6f9;
    color: #222;
}

/* Institute background for all logged-in/inner pages */
.app-bg {
    background-image: linear-gradient(rgba(230, 235, 242, 0.80), rgba(230, 235, 242, 0.80)),
                       url('../assets/img/building.jpeg');
    background-size: cover;
    background-position: center top;
    background-attachment: fixed;
    background-repeat: no-repeat;
    min-height: 100vh;
}

/* ---------- Navbar ---------- */
.navbar {
    background: #1e3a5f;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 30px;
    flex-wrap: wrap;
}

.nav-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

@media (min-width: 769px) {
    .nav-brand {
        width: auto;
    }
}

.nav-brand a {
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-brand img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 2px;
}

.nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 10px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.nav-links a {
    color: #dce6f0;
    text-decoration: none;
    font-size: 15px;
}

.nav-links a:hover {
    color: #ffcc00;
}

.nav-user {
    font-size: 14px;
    color: #b8c9dc;
}

/* ---------- Mobile Navbar (phones / tablets) ---------- */
@media (max-width: 768px) {
    .navbar {
        padding: 12px 16px;
    }

    .nav-hamburger {
        display: block;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 4px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid rgba(255,255,255,0.15);
    }

    .nav-links.mobile-open {
        display: flex;
    }

    .nav-links a {
        width: 100%;
        padding: 10px 4px;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .nav-user {
        width: 100%;
        padding: 10px 4px 4px;
        order: 10;
    }

    .nav-more {
        width: 100%;
        order: 11;
    }

    .nav-more-btn {
        width: 100%;
        text-align: left;
        border-radius: 6px;
        padding: 10px;
    }

    .nav-dropdown {
        position: static;
        width: 100%;
        box-shadow: none;
        margin-top: 6px;
        border-radius: 6px;
    }
}

.logout-btn {
    background: #d9534f;
    padding: 6px 14px;
    border-radius: 5px;
    color: #fff !important;
}

/* 3-dot dropdown menu */
.nav-more {
    position: relative;
}

.nav-more-btn {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: none;
    font-size: 20px;
    line-height: 1;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
}

.nav-more-btn:hover {
    background: rgba(255,255,255,0.22);
}

.nav-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #d9534f;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.nav-badge-inline {
    background: #d9534f;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    border-radius: 20px;
    padding: 2px 8px;
    margin-left: 6px;
}

.nav-dropdown {
    display: none;
    flex-direction: column;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0,0,0,0.22);
    min-width: 200px;
    overflow: hidden;
    z-index: 1000;
}

.nav-dropdown.show {
    display: flex;
}

.nav-dropdown a {
    padding: 12px 18px;
    color: #222 !important;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.nav-dropdown a:hover {
    background: #f4f6f9;
}

.nav-dropdown a.logout-link {
    color: #d9534f !important;
    font-weight: bold;
    border-top: 1px solid #eee;
}

/* ---------- Auth Pages (Login/Register) ---------- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f, #2c5985);
}

/* Institute building photo as background, with dark overlay for readability */
.auth-bg {
    background-image: linear-gradient(rgba(10, 20, 35, 0.88), rgba(10, 20, 35, 0.92)),
                       url('../assets/img/building.jpeg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.auth-box {
    background: #fff;
    padding: 40px;
    border-radius: 10px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.auth-logo img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border-radius: 50%;
}

.auth-box h2 {
    text-align: center;
    color: #1e3a5f;
    margin-bottom: 6px;
    font-size: 20px;
}

.auth-note {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #888;
}

.auth-box p.subtitle {
    text-align: center;
    color: #777;
    margin-bottom: 20px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #444;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px; /* 16px prevents iOS Safari from auto-zooming on focus */
}

.btn {
    width: 100%;
    background: #1e3a5f;
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    transition: 0.2s;
}

.btn:hover {
    background: #2c5985;
}

.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-danger {
    background: #d9534f;
}

.btn-danger:hover {
    background: #c9302c;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
}

.auth-switch a {
    color: #1e3a5f;
    font-weight: bold;
}

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fdecea;
    color: #c9302c;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #e6f4ea;
    color: #1e7e34;
    border: 1px solid #c3e6cb;
}

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

.page-title {
    font-size: 24px;
    color: #1e3a5f;
    margin-bottom: 20px;
}

@media (max-width: 480px) {
    .container {
        margin: 16px auto;
        padding: 0 12px;
    }

    .page-title {
        font-size: 20px;
    }
}

/* ---------- Dashboard Cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    padding: 22px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 5px solid #1e3a5f;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.14);
}

.stat-card-alert {
    border-left-color: #d9534f;
}

.stat-card-alert h3 {
    color: #d9534f;
}

/* Quick Actions box - blue themed */
.quick-actions-box {
    background: #eaf2fb;
    border: 2px solid #1e3a5f;
    border-radius: 10px;
    padding: 22px;
    box-shadow: 0 2px 10px rgba(30, 58, 95, 0.12);
}

.quick-actions-box h3 {
    color: #1e3a5f;
}

.quick-actions-box p a {
    color: #1e3a5f;
    font-weight: 600;
    text-decoration: none;
}

.quick-actions-box p a:hover {
    text-decoration: underline;
}

.stat-card h3 {
    font-size: 28px;
    color: #1e3a5f;
}

.stat-card p {
    color: #777;
    margin-top: 4px;
    font-size: 14px;
}

/* ---------- Tables ---------- */
.table-wrap {
    background: #fff;
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

th {
    background: #1e3a5f;
    color: #fff;
}

tr:hover {
    background: #f9fafc;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.badge-issued { background: #fff3cd; color: #856404; }
.badge-returned { background: #d4edda; color: #155724; }
.badge-overdue { background: #f8d7da; color: #721c24; }
.badge-fine { background: #f8d7da; color: #a71d2a; font-weight: bold; }
.badge-nofine { background: #e2e3e5; color: #555; }
.badge-role-staff { background: #d1ecf1; color: #0c5460; }
.badge-role-teacher { background: #e2d9f3; color: #4a2c8a; }
.badge-role-student { background: #d4edda; color: #155724; }
.badge-active { background: #d4edda; color: #155724; }
.badge-suspended { background: #f8d7da; color: #721c24; font-weight: bold; }

/* ---------- Book / Ebook Cards ---------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
}

.book-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

.book-cover {
    width: 100%;
    height: 160px;
    background: #1e3a5f;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 40px;
    margin-bottom: 12px;
    overflow: hidden;
}

.book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-card h4 {
    color: #1e3a5f;
    font-size: 16px;
    margin-bottom: 4px;
}

.book-card p {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.book-actions {
    margin-top: auto;
    display: flex;
    gap: 8px;
    padding-top: 10px;
}

.book-actions a, .book-actions button {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    border: none;
    cursor: pointer;
}

.btn-view { background: #1e3a5f; color: #fff; }
.btn-download { background: #28a745; color: #fff; }
.btn-issue { background: #ffb703; color: #222; }
.btn-edit { background: #6c757d; color: #fff; }

.search-bar {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.search-bar input {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
}

.search-bar button {
    padding: 12px 18px;
    background: #1e3a5f;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
}

@media (max-width: 480px) {
    .search-bar {
        flex-wrap: wrap;
    }

    .search-bar input {
        width: 100%;
    }

    .search-bar button {
        flex: 1;
    }

    .book-actions {
        flex-direction: column;
    }
}

/* PDF viewer page */
.pdf-viewer-wrap {
    background: #fff;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.pdf-viewer-wrap iframe {
    width: 100%;
    height: 80vh;
    border: none;
    border-radius: 6px;
}

@media (max-width: 480px) {
    .pdf-viewer-wrap {
        padding: 8px;
    }

    .pdf-viewer-wrap iframe {
        height: 70vh;
    }
}
