:root {
    /* Default spacing and sizes */
    --padding-sm: 0.5rem;
    --padding-md: 1rem;
    --padding-lg: 2rem;
    --border-radius: 12px;
    --sidebar-width: 250px;
    
    /* Configurable Colors - will be injected by PHP if set */
    --accent-primary: #6366f1; /* Indigo */
    --accent-secondary: #a855f7; /* Purple */
    
    /* Dark Theme Palette */
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    padding: var(--padding-lg);
    display: flex;
    flex-direction: column;
    position: fixed;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.logo-container img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    margin-bottom: 0.25rem;
}

.nav-group {
    margin-top: 1.5rem;
}

.nav-group-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    font-weight: 600;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-links a.active {
    border-left: 4px solid var(--accent-primary);
    color: var(--accent-primary);
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: var(--padding-lg);
    max-width: 1400px;
}

.header {
    margin-bottom: 3rem;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glass Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: var(--padding-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-8px) scale(1.01);
    border-color: var(--accent-primary);
    box-shadow: 0 15px 45px 0 rgba(0, 0, 0, 0.5);
}

.card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.card:hover::after {
    opacity: 1;
}

/* Inputs and Forms */
input, select, textarea, button {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: #fff;
    width: 100%;
    margin-bottom: 1rem;
    outline: none;
}

input:focus {
    border-color: var(--accent-primary);
}

button {
    background: var(--accent-primary);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

button:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background: rgba(255, 255, 255, 0.1);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-secondary);
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Utils */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
}

.badge-admin { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.badge-visitor { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-suspended { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Tabs */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    width: auto;
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.actions-cell {
    display: flex;
    gap: 0.5rem;
}

/* Maintenance Page Utils */
.thumb-small {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
}

.table-selectable tr.selected {
    background: rgba(99, 102, 241, 0.1);
}

.table-selectable input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
}

.alert-info {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--accent-primary);
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    color: var(--text-primary);
}

/* View Switcher */
.view-switcher {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 2px;
}

.view-btn {
    padding: 0.5rem 1rem;
    width: auto;
    margin: 0;
    background: transparent;
    border-radius: 6px;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.view-btn.active {
    background: var(--accent-primary);
    color: #fff;
}

/* List View Table Specific */
.table-books th {
    cursor: pointer;
    white-space: nowrap;
}

.table-books th:hover {
    color: var(--accent-primary);
}

.table-books .badge {
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
}



.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

/* Login Page Specific */
.login-container {
    height: 100vh;
    width: 100vw;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at center, #1e293b, #0a0f1a);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo img {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    margin-bottom: 1rem;
    box-shadow: 0 0 20px var(--accent-primary);
}

.logout-link {
    margin-top: auto;
    color: #ef4444 !important;
}

.logout-link:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* Books Gallery Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.book-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    border-color: var(--accent-primary);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    background: #1e293b;
    border-bottom: 1px solid var(--glass-border);
    transition: transform 0.5s ease;
}

.book-card:hover .book-cover {
    transform: scale(1.05);
}

.book-info {
    padding: 1rem;
    flex-grow: 1;
}

.book-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #fff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    margin-top: auto;
}

.filter-bar {
    display: flex;
    gap: 1rem;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .form-group {
    margin: 0;
    flex: 1;
    min-width: 150px;
}

.filter-bar input, .filter-bar select {
    margin: 0;
}

/* Modal Styling */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    place-items: center;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Star Rating Styling */
.star-rating {
    display: flex;
    gap: 0.5rem;
    cursor: pointer;
}

.star {
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.star.active {
    color: #fbbf24; /* Amber-400 */
}

/* UI Utility for Quick Add Button */
.input-with-action {
    display: flex;
    gap: 0.5rem;
}

.btn-add-inline {
    background: var(--accent-primary);
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* ==========================================
   Tom Select Custom Dark Mode Styling
   ========================================== */
.ts-wrapper .ts-control {
    background: rgba(15, 23, 42, 0.5) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 8px !important;
    padding: 0.75rem 1rem !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
    transition: border-color 0.3s ease !important;
}

/* Ensure the control retains its dark background when active/focused */
.ts-wrapper.input-active .ts-control,
.ts-wrapper.focus .ts-control {
    background: rgba(15, 23, 42, 0.7) !important;
    border-color: var(--accent-primary) !important;
}

/* Style the internal input being typed */
.ts-wrapper .ts-control input {
    color: var(--text-primary) !important;
    background: transparent !important;
    font-family: inherit !important;
    font-size: inherit !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    width: auto !important;
}

/* Main dropdown container */
.ts-dropdown {
    background: #1e293b !important;
    border: 1px solid var(--glass-border) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
    margin-top: 4px !important;
}

/* Dropdown list options styling */
.ts-dropdown .option {
    padding: 0.75rem 1rem !important;
    color: var(--text-primary) !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
}

/* Active / hovered / selected option in list */
.ts-dropdown .active {
    background-color: var(--accent-primary) !important;
    color: #ffffff !important;
}

/* Disabled option */
.ts-dropdown .option.disabled {
    color: var(--text-secondary) !important;
    opacity: 0.5 !important;
}

/* Placeholder item selected */
.ts-wrapper.single .ts-control .item {
    color: var(--text-primary) !important;
}




