/* eLibrary V2 Custom Styles */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 60px;
    --primary-color: #2c7db5;
    --sidebar-bg: #1a5a8a;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: #f8f9fa;
}

/* Header */
.main-header {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--header-height);
    background: linear-gradient(135deg, #2c7db5 0%, #1a5a8a 100%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    transition: left 0.3s ease;
}

.main-header.expanded {
    left: 0;
}

.main-header.sidebar-collapsed {
    left: var(--sidebar-collapsed-width);
}

.main-header .logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-header .logo-img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    padding: 2px;
}

.main-header .site-title {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.main-header .header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.main-header .user-info {
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease;
    z-index: 1040;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-hidden {
    transform: translateX(-100%);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--header-height);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0.5rem;
}

.sidebar.collapsed .sidebar-header .site-title {
    display: none;
}

.sidebar-header .logo-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    padding: 2px;
    flex-shrink: 0;
}

.sidebar-header .site-title {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

/* Sidebar Collapse Button */
.sidebar-collapse-btn {
    padding: 0.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.btn-collapse {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-collapse:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
}

.btn-collapse i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu .menu-item {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-menu .menu-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: all 0.3s;
    gap: 12px;
    position: relative;
    white-space: nowrap;
}

.sidebar.collapsed .menu-link {
    justify-content: center;
    padding: 1rem 0.5rem;
}

.sidebar.collapsed .menu-text,
.sidebar.collapsed .bi-chevron-down {
    display: none;
}

.sidebar-menu .menu-link:hover,
.sidebar-menu .menu-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
    padding-left: 2rem;
}

.sidebar.collapsed .menu-link:hover,
.sidebar.collapsed .menu-link.active {
    padding-left: 0.5rem;
}

.sidebar-menu .menu-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu .menu-text {
    font-size: 0.95rem;
}

/* Dropdown Menu Icon */
.menu-dropdown .bi-chevron-down {
    font-size: 0.9rem;
    transition: transform 0.3s;
}

.menu-dropdown[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Submenu */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(0,0,0,0.2);
}

.sidebar.collapsed .submenu {
    display: none;
}

.submenu-item {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.submenu-link {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem 0.8rem 3rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
    gap: 10px;
    font-size: 0.85rem;
}

.submenu-link:hover,
.submenu-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
    padding-left: 3.5rem;
}

.submenu-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left 0.3s ease;
    min-height: calc(100vh - var(--header-height));
}

.main-content.expanded {
    margin-left: 0;
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* Toggle Button */
.sidebar-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    display: none;
    margin-right: 1rem;
}

/* Public Header (Not Logged In) */
.public-header {
    background: linear-gradient(135deg, #2c7db5 0%, #1a5a8a 100%);
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.public-navbar {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.public-navbar .nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.public-navbar .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Search Box */
.search-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.search-box {
    display: flex;
    gap: 0.5rem;
}

.search-box input {
    flex: 1;
}

/* Book Card */
.book-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    height: 100%;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.book-card img {
    width: 100%;
    height: 300px;
    object-fit: cover;
}

.book-card .card-body {
    padding: 1rem;
}

.book-card .book-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card .book-author {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

/* Page Title */
.page-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--primary-color);
}

/* Custom Button */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #1a5a8a;
    border-color: #1a5a8a;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-header {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }
}

/* Scrollbar Custom */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Alert Custom */
.alert {
    border-radius: 8px;
    border: none;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Table Custom */
.table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.table thead {
    background-color: var(--primary-color);
    color: white;
}

.table thead th {
    border: none;
    font-weight: 500;
}

/* Form Custom */
.form-label {
    font-weight: 500;
    color: #333;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(44, 125, 181, 0.25);
}

/* Card Custom */
.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
}

.card-header {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    border-radius: 8px 8px 0 0 !important;
}

/* Badge Custom */
.badge {
    padding: 0.4rem 0.8rem;
    font-weight: 500;
}