/* ============================================================
   Library Management System - Custom styles
   ============================================================ */

body {
    background-color: #f4f6fb;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #212529;
}

/* ==================== Admin layout ==================== */

/* Branding: logo + "AXBOROT RESURS MARKAZI MS" text */
.brand-logo {
    width: 110px;
    height: 110px;
    object-fit: contain;
    flex-shrink: 0;
}

.navbar .brand-text {
    font-size: 1.5rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.navbar .brand-subtitle {
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Top navbar is sized to fit the 110px brand logo */
:root {
    --navbar-height: 118px;
}

.navbar {
    min-height: var(--navbar-height);
}

/* Remove default vertical padding so the logo defines the navbar height */
.navbar {
    --bs-navbar-padding-y: 0;
}

.navbar .container-fluid {
    min-height: var(--navbar-height);
}

.navbar .navbar-brand {
    --bs-navbar-brand-padding-y: 0;
    padding-top: 0;
    padding-bottom: 0;
}

/* Sidebar and content area start below the taller navbar */
.app-sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: 240px;
    background-color: #1e293b;
    overflow-y: auto;
    z-index: 1020;
    padding-top: 0.75rem;
}

.app-sidebar .nav-link {
    color: #cbd5e1;
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.95rem;
    transition: background-color 0.15s ease;
}

.app-sidebar .nav-link i {
    font-size: 1.1rem;
}

.app-sidebar .nav-link:hover,
.app-sidebar .nav-link.active {
    background-color: #2563eb;
    color: #ffffff;
}

/* Mobile offcanvas sidebar uses the same dark theme */
.app-offcanvas {
    width: 260px;
}

.app-offcanvas .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-offcanvas .nav-link {
    color: #1e293b;
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.95rem;
}

.app-offcanvas .nav-link i {
    font-size: 1.1rem;
}

.app-offcanvas .nav-link:hover,
.app-offcanvas .nav-link.active {
    background-color: #2563eb;
    color: #ffffff;
}

/* Push content to the right of the desktop sidebar */
.app-main {
    margin-left: 240px;
    margin-top: var(--navbar-height);
    min-height: 100vh;
}

@media (max-width: 991.98px) {
    .app-main {
        margin-left: 0;
    }
}

/* ==================== Stat cards (dashboard) ==================== */

/* Each card takes its accent colour from its icon's bg-soft-* class */
.stat-card {
    --accent: #4f46e5;
    --accent-2: #818cf8;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 1.25rem;
    background:
        radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--accent) 10%, transparent) 0, transparent 55%),
        #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:has(.bg-soft-primary)   { --accent: #4f46e5; --accent-2: #818cf8; }
.stat-card:has(.bg-soft-success)   { --accent: #059669; --accent-2: #34d399; }
.stat-card:has(.bg-soft-warning)   { --accent: #d97706; --accent-2: #fbbf24; }
.stat-card:has(.bg-soft-danger)    { --accent: #dc2626; --accent-2: #f87171; }
.stat-card:has(.bg-soft-info)      { --accent: #0891b2; --accent-2: #22d3ee; }
.stat-card:has(.bg-soft-secondary) { --accent: #475569; --accent-2: #94a3b8; }

/* Accent bar on top */
.stat-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* Soft decorative ring in the corner */
.stat-card::after {
    content: '';
    position: absolute;
    right: -38px;
    bottom: -38px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 18px solid color-mix(in srgb, var(--accent) 7%, transparent);
    transition: transform 0.4s ease;
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04),
                0 18px 36px -16px color-mix(in srgb, var(--accent) 45%, transparent);
}

.stat-card:hover::after { transform: scale(1.15); }

.stat-card .card-body {
    position: relative;
    z-index: 1;
    padding: 1.4rem 1.5rem;
    min-height: 110px;
}

.stat-card .icon-box {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 8px 18px -8px var(--accent);
    transition: transform 0.25s ease;
}

.stat-card:hover .icon-box { transform: rotate(-6deg) scale(1.06); }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
    margin-top: 0.2rem;
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 500;
}

@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .stat-card::after,
    .stat-card .icon-box { transition: none; }
}

/* ==================== Cards & tables ==================== */

.table-card,
.form-card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.table-card .table {
    margin-bottom: 0;
}

.table-card thead th {
    background-color: #eef2ff;
    color: #4338ca;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.table-card .table td {
    vertical-align: middle;
}

.form-card .form-label {
    font-weight: 500;
    font-size: 0.9rem;
}

/* ==================== Auth (login) page ==================== */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    border: none;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* ============== Language switcher with circular flags ==============
   [uz flag] UZ | [gb flag] ENG | [ru flag] RU
   Used on the dark navbar and on the dark auth / portal screens. */
.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    line-height: 1;
}

.lang-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.1rem;
    transition: color 0.15s ease;
    white-space: nowrap;
}

.lang-link:hover {
    color: #ffffff;
}

.lang-link.active {
    color: #ffffff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Circular flag icon: 20px, perfectly round, subtle border + soft shadow.
   The container AND the image are both forced to a perfect circle so the
   flags can never render rectangular/square. */
.lang-flag {
    display: inline-block;
    width: 20px;
    height: 20px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.08);
    vertical-align: middle;
}

.lang-flag img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    image-rendering: auto;
}

.lang-sep {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 300;
}

/* Slightly compact switcher on small phones so it stays in the top bar. */
@media (max-width: 575.98px) {
    .lang-switcher {
        gap: 0.25rem;
        font-size: 0.78rem;
    }
    .lang-link {
        gap: 0.25rem;
        padding: 0.1rem;
    }
    .lang-flag {
        width: 18px;
        height: 18px;
    }
}

/* ============ First screen / portal branding (index.php only) ============
   White, bold, larger text + noticeably larger logo on the dark gradient.
   Scoped via .portal-brand so login pages and panels are untouched.
   Explicit px values + !important so no other selector (Bootstrap, media
   query, .brand-logo, .text-muted) can override them. */
.portal-wrap {
    flex-direction: column;
}

.portal-wrap .row {
    width: 100%;
}

.portal-brand .brand-logo {
    width: 160px !important;
    height: auto !important;
}

.portal-brand h3 {
    color: #ffffff !important;
    font-size: 38px !important;
    font-weight: 800 !important;
    letter-spacing: 0.02em;
    line-height: 1.15;
}

.portal-brand p {
    color: #ffffff !important;
    font-size: 24px !important;
    font-weight: 700 !important;
    letter-spacing: 0.03em;
    margin-top: 0.25rem;
}

@media (max-width: 575.98px) {
    .portal-brand .brand-logo {
        width: 130px !important;
        height: auto !important;
    }
    .portal-brand h3 {
        font-size: 26px !important;
    }
    .portal-brand p {
        font-size: 18px !important;
    }
}

/* ==================== Utilities ==================== */

/* Soft (light) background + colored text badges */
.bg-soft-primary   { background-color: #e0e7ff; color: #4338ca; }
.bg-soft-success   { background-color: #dcfce7; color: #15803d; }
.bg-soft-warning   { background-color: #fef3c7; color: #b45309; }
.bg-soft-danger    { background-color: #fee2e2; color: #b91c1c; }
.bg-soft-info      { background-color: #cffafe; color: #0e7490; }
.bg-soft-secondary { background-color: #e2e8f0; color: #475569; }

.object-fit-cover { object-fit: cover; }

/* ==================== e-Book reader ==================== */

.ebook-viewer {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background-color: #ffffff;
    width: 100%;
    height: 70vh;
}

.ebook-text {
    background-color: #fffdf5;
    border: 1px solid #f1e5c0;
    border-radius: 0.75rem;
    padding: 2rem;
    white-space: pre-wrap;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 1rem;
    line-height: 1.7;
    max-height: 70vh;
    overflow-y: auto;
}

/* ==================== Book catalog cards ==================== */

.book-card .card-body {
    display: flex;
    flex-direction: column;
}

.book-card .card-text {
    flex-grow: 1;
}

/* ==================== Multimedia subject buttons ==================== */

.subject-heading,
.subject-name {
    font-family: 'Montserrat', system-ui, sans-serif;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
    perspective: 1000px;
}

.subject-tile {
    --rx: 0deg;
    --ry: 0deg;
    --mx: 50%;
    --my: 50%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 200px;
    padding: 1.4rem;
    border-radius: 1.25rem;
    overflow: hidden;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(135deg, var(--from), var(--to));
    box-shadow: 0 10px 25px -10px var(--from);
    transform: rotateX(var(--rx)) rotateY(var(--ry));
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out, box-shadow 0.3s ease;
    animation: subject-in 0.5s ease both;
    animation-delay: var(--delay, 0ms);
}

/* Light that follows the cursor */
.subject-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.35), transparent 55%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* Diagonal shine sweep on hover */
.subject-tile::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 40%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: rotate(20deg) translateX(-150%);
    pointer-events: none;
}

.subject-tile:hover,
.subject-tile:focus-visible {
    color: #fff;
    box-shadow: 0 22px 40px -14px var(--from);
}

.subject-tile:hover::before { opacity: 1; }
.subject-tile:hover::after  { transition: transform 0.8s ease; transform: rotate(20deg) translateX(450%); }
.subject-tile:active        { transform: rotateX(var(--rx)) rotateY(var(--ry)) scale(0.98); }

.subject-tile:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

.subject-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 1rem;
    font-size: 1.6rem;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(6px);
    transition: transform 0.3s ease;
}

.subject-tile .subject-icon { transform: translateZ(40px); }
.subject-tile:hover .subject-icon { transform: translateZ(40px) rotate(-8deg) scale(1.08); }

.subject-tile .subject-name {
    position: relative;
    margin: 1rem 0 0.75rem;
    font-size: 1.3rem;
    line-height: 1.2;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transform: translateZ(30px);
}

.subject-meta {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: 'Montserrat', system-ui, sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    opacity: 0.9;
    transform: translateZ(20px);
}

.subject-arrow {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.subject-tile:hover .subject-arrow { transform: translateX(4px); }

/* Decorative background: subject symbols + floating orbs */
.subject-symbols {
    position: absolute;
    right: -0.25rem;
    top: 0.6rem;
    font-family: 'Montserrat', system-ui, sans-serif;
    font-weight: 800;
    font-size: 1.9rem;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.13);
    pointer-events: none;
    transition: transform 0.6s ease;
}

.subject-tile:hover .subject-symbols { transform: translateX(-12px); }

.subject-orb {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
    animation: subject-float 6s ease-in-out infinite;
}

.subject-orb-1 { width: 140px; height: 140px; right: -40px; bottom: -50px; }
.subject-orb-2 { width: 70px;  height: 70px;  right: 70px;  bottom: 40px; animation-delay: -3s; }

/* Banner on a subject page */
.subject-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-radius: 1.25rem;
    color: #fff;
    background: linear-gradient(135deg, var(--from), var(--to));
    box-shadow: 0 10px 25px -12px var(--from);
}

.subject-banner .subject-name { font-size: 1.4rem; }

@keyframes subject-in {
    from { opacity: 0; translate: 0 16px; scale: 0.97; }
    to   { opacity: 1; translate: 0 0;    scale: 1; }
}

@keyframes subject-float {
    0%, 100% { translate: 0 0; }
    50%      { translate: -8px -10px; }
}

@media (prefers-reduced-motion: reduce) {
    .subject-tile,
    .subject-orb { animation: none; }
}

@media (max-width: 575.98px) {
    .subject-banner { flex-wrap: wrap; }
    .subject-tile { min-height: 170px; }
}

/* ==================== Utilities ==================== */

@media (max-width: 575.98px) {
    .table-responsive-sm {
        overflow-x: auto;
    }
    .stat-card .stat-value {
        font-size: 1.6rem;
    }
    .stat-card .card-body {
        padding: 1.1rem 1.2rem;
        min-height: 96px;
    }
    .stat-card .icon-box {
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
    }
    /* Compact, responsive branding on phones: shrink the navbar logo and
       its fixed height so nothing overlaps. The sidebar/main offsets use
       the same CSS variable, so they stay aligned automatically. */
    :root {
        --navbar-height: 72px;
    }
    .navbar .brand-logo {
        width: 56px;
        height: 56px;
    }
    .navbar .brand-text {
        font-size: 1rem;
        white-space: normal;
        line-height: 1.15;
    }
    .navbar .brand-subtitle {
        font-size: 0.6rem;
        letter-spacing: 0.06em;
    }
}
