/* =====================================================================
   ADMIN PANEL — login va boshqaruv paneli uslubi
   ===================================================================== */

.login-body {
    background: linear-gradient(160deg, var(--color-primary-dark) 0%, var(--color-primary) 60%, #2563eb 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-family: 'Inter', sans-serif;
    padding: 1.5rem;
}

.login-wrap { width: 100%; max-width: 420px; }

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.25rem 2rem;
}

.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .brand-logo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 0.9rem;
}
.login-brand h4 { font-weight: 800; color: var(--color-text); margin-bottom: 0.35rem; }
.login-brand p { font-size: 0.85rem; color: var(--color-text-muted); margin: 0; }

.login-card .form-label { font-weight: 600; font-size: 0.85rem; color: var(--color-text); }
.login-card .form-control {
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--color-border);
}
.login-card .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
.login-card .btn-primary {
    background: var(--color-primary);
    border: none;
    font-weight: 700;
    padding: 0.7rem;
    border-radius: var(--radius-sm);
}
.login-card .btn-primary:hover { background: var(--color-primary-dark); }

.login-footer-note {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.85);
}
.login-footer-note a { color: #fff; text-decoration: underline; }

/* =====================================================================
   ADMIN SHELL — sidebar + topbar (7-bosqichdan boshlab barcha admin
   sahifalarida ishlatiladi)
   ===================================================================== */
.admin-body { margin: 0; background: var(--color-bg); font-family: 'Inter', sans-serif; }

.admin-shell {
    display: flex;
    min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.admin-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--color-primary-dark);
    color: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.2s ease;
    z-index: 1030;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1.25rem 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .brand-logo {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(255,255,255,0.12);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: #fff; flex-shrink: 0;
}
.sidebar-title { font-weight: 800; color: #fff; font-size: 0.95rem; letter-spacing: 0.4px; }
.sidebar-subtitle { font-size: 0.72rem; color: rgba(255,255,255,0.6); }

.sidebar-nav { padding: 0.75rem 0.6rem 1.5rem; display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.8);
    font-size: 0.88rem;
    font-weight: 500;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: var(--color-primary); color: #fff; font-weight: 700; }
.sidebar-nav a i { width: 18px; text-align: center; }

.sidebar-nav .nav-sub { padding-left: 2.1rem; font-size: 0.83rem; }
.nav-group-label {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.4px;
    color: rgba(255,255,255,0.5); font-weight: 700;
    padding: 0.9rem 0.75rem 0.3rem;
}

/* ---- MAIN AREA ---- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.85rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.sidebar-toggle-btn {
    display: none;
    border: none;
    background: transparent;
    font-size: 1.2rem;
    color: var(--color-text);
}
.topbar-title { font-weight: 800; font-size: 1.1rem; color: var(--color-text); flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 0.6rem; }
.topbar-username { font-size: 0.88rem; font-weight: 600; color: var(--color-text); }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--color-primary-light); color: var(--color-primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.9rem;
}
.logout-link { color: var(--color-text-muted); font-size: 1.05rem; padding: 0.3rem; }
.logout-link:hover { color: var(--color-danger); }

.admin-content { padding: 1.5rem; }

/* ---- DASHBOARD STAT CARDS ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.dash-stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    box-shadow: var(--shadow-sm);
}
.dash-stat-icon {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 0.6rem; font-size: 0.95rem;
}
.icon-blue  { background: var(--color-primary-light); color: var(--color-primary); }
.icon-green { background: var(--color-success-bg); color: var(--color-success); }
.icon-red   { background: var(--color-danger-bg); color: var(--color-danger); }
.icon-amber { background: var(--color-warning-bg); color: var(--color-warning); }

.dash-stat-value { font-size: 1.5rem; font-weight: 800; color: var(--color-text); }
.dash-stat-label { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.15rem; }

/* ---- DASHBOARD PANELS (chart + top books) ---- */
.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
}
.dash-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.dash-panel-title { font-weight: 700; font-size: 0.9rem; color: var(--color-text); margin-bottom: 1rem; }

.top-books-list { list-style: decimal; padding-left: 1.1rem; margin: 0; }
.top-books-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.88rem;
}
.top-books-list li:last-child { border-bottom: none; }
.tb-title { color: var(--color-text); }
.tb-count { font-weight: 700; color: var(--color-primary); flex-shrink: 0; }

/* ---- RESPONSIVE ---- */
@media (max-width: 991px) {
    .admin-sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
    }
    .admin-sidebar.open { transform: translateX(0); }
    .sidebar-toggle-btn { display: inline-flex; align-items: center; justify-content: center; }
    .dash-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   BOOKS LIST + FORM (8-bosqich)
   ===================================================================== */
.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.admin-search-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.admin-search-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.8rem;
    min-width: 280px;
}
.admin-search-input i { color: var(--color-text-muted); }
.admin-search-input input { border: none; outline: none; background: transparent; flex: 1; font-size: 0.9rem; }

.admin-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; white-space: nowrap; }
.admin-table th {
    background: var(--color-bg);
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 700;
    color: var(--color-text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--color-border);
}
.admin-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--color-bg); }
.admin-table .cell-title { white-space: normal; min-width: 220px; font-weight: 600; }
.admin-table .cell-actions { display: flex; gap: 0.35rem; white-space: nowrap; }

.status-badge-sm { padding: 0.25rem 0.5rem; font-size: 0.9rem; border-radius: 999px; }

.admin-form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    max-width: 900px;
    box-shadow: var(--shadow-sm);
}
.form-section-title {
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-primary);
    margin: 1.25rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-border);
}
.form-section-title:first-of-type { margin-top: 0; }

@media (max-width: 768px) {
    .admin-page-header { flex-direction: column; align-items: stretch; }
    .admin-search-form { flex-direction: column; align-items: stretch; }
    .admin-search-input { min-width: 0; }
}

/* =====================================================================
   READER PROFILE (9-bosqich)
   ===================================================================== */
.reader-profile-head {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}
.reader-avatar {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--color-primary-light); color: var(--color-primary-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.4rem; flex-shrink: 0;
}
.reader-meta { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.85rem; color: var(--color-text-muted); align-items: center; }
.reader-meta i { margin-right: 0.3rem; color: var(--color-primary); }

.reader-tabs {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}
.reader-tabs a {
    padding: 0.7rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
}
.reader-tabs a.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab-count {
    background: var(--color-muted-bg);
    color: var(--color-text-muted);
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    margin-left: 0.25rem;
}
.reader-tabs a.active .tab-count { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* =====================================================================
   BORROW PAGE (10-bosqich)
   ===================================================================== */
.borrow-book-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

/* =====================================================================
   READER AUTOCOMPLETE (kitob berish / bron qilish formalarida)
   ===================================================================== */
.reader-ac-wrap { position: relative; }
.reader-ac-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    margin-top: 0.25rem;
    max-height: 260px;
    overflow-y: auto;
}
.reader-ac-item { padding: 0.55rem 0.9rem; cursor: pointer; font-size: 0.88rem; border-bottom: 1px solid var(--color-border); }
.reader-ac-item:last-child { border-bottom: none; }
.reader-ac-item:hover { background: var(--color-bg); }

/* =====================================================================
   EXCEL IMPORT PROGRESS (15-bosqich)
   ===================================================================== */
.import-progress-wrap { margin-bottom: 1rem; }
.import-progress-bar {
    width: 100%;
    height: 22px;
    background: var(--color-bg);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}
.import-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    transition: width 0.3s ease;
}
.import-progress-text { margin-top: 0.5rem; font-weight: 600; font-size: 0.9rem; color: var(--color-text); }
.import-log {
    max-height: 260px;
    overflow-y: auto;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-top: 0.75rem;
}
.import-log div { padding: 0.15rem 0; border-bottom: 1px dashed var(--color-border); }
.import-log div:last-child { border-bottom: none; }

/* =====================================================================
   EXCEL EXPORT (16-bosqich)
   ===================================================================== */
.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.export-option-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    color: var(--color-text);
    transition: all 0.15s ease;
}
.export-option-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); color: var(--color-text); }
.export-option-card i { font-size: 1.4rem; }

/* =====================================================================
   LIBRARIANS (17-bosqich)
   ===================================================================== */
.role-badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}
.role-super_admin { background: #fde8e8; color: #b91c1c; }
.role-admin { background: var(--color-primary-light); color: var(--color-primary-dark); }
.role-librarian { background: var(--color-muted-bg); color: var(--color-text-muted); }

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.source-self { background: var(--color-warning-bg); color: var(--color-warning); }
.source-librarian { background: var(--color-muted-bg); color: var(--color-text-muted); }

/* =====================================================================
   MESSAGES / CHAT (kutubxonachi <-> kitobxon)
   ===================================================================== */
.sidebar-badge {
    margin-left: auto;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
}
.sidebar-nav a { position: relative; }

.unread-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    padding: 0 0.3rem;
    margin-left: 0.4rem;
}

.chat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 70vh;
    max-height: 640px;
}
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-bubble-row { display: flex; }
.chat-bubble-row.from-librarian { justify-content: flex-end; }
.chat-bubble-row.from-reader { justify-content: flex-start; }
.chat-bubble {
    max-width: 70%;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.4;
}
.from-librarian .chat-bubble { background: var(--color-primary); color: #fff; border-bottom-right-radius: 2px; }
.from-reader .chat-bubble { background: var(--color-bg); color: var(--color-text); border-bottom-left-radius: 2px; }
.chat-bubble-time { font-size: 0.68rem; opacity: 0.75; margin-top: 0.3rem; text-align: right; }

.chat-input-row { border-top: 1px solid var(--color-border); padding: 0.9rem 1.25rem; }
.chat-templates { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.chat-input-wrap { display: flex; gap: 0.6rem; align-items: flex-end; }
.chat-input-wrap textarea { flex: 1; resize: none; }

@media (max-width: 768px) {
    .chat-card { height: 78vh; }
    .chat-bubble { max-width: 88%; }
}
