@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #f2f6f3;      /* soft light green-tinted background */
    --bg-secondary: #ffffff;    /* pure white panels */
    --bg-tertiary: #e6eee9;     /* light mint accent panels */
    
    --accent-emerald: #059669;  /* rich green for primary actions */
    --accent-green: #10b981;    /* bright green accents */
    --accent-glow: rgba(16, 185, 129, 0.05);
    
    --text-primary: #1f2937;    /* dark slate for readable text */
    --text-secondary: #4b5563;  /* slate for meta info */
    --text-muted: #6b7280;      /* muted gray */
    
    --border-color: rgba(5, 150, 105, 0.15);
    --border-focus: rgba(16, 185, 129, 0.4);
    
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(5, 150, 105, 0.12);
    --glass-shadow: 0 10px 30px 0 rgba(5, 150, 105, 0.05);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Background Glowing Orbs */
.glow-orb {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
    opacity: 0.8;
}
.glow-orb-1 { top: -200px; right: -200px; }
.glow-orb-2 { bottom: -200px; left: -200px; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #111827;
}

a {
    color: var(--accent-emerald);
    text-decoration: none;
    transition: var(--transition-smooth);
}
a:hover {
    color: var(--accent-green);
}

/* Glassmorphism Container */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    padding: 2rem;
    transition: var(--transition-smooth);
}
.glass-panel:hover {
    border-color: rgba(5, 150, 105, 0.25);
    box-shadow: 0 12px 35px 0 rgba(5, 150, 105, 0.08);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent-emerald) 0%, #047857 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px 0 rgba(5, 150, 105, 0.2);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(5, 150, 105, 0.35);
    background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-emerald) 100%);
}
.btn-secondary {
    background: #eef2f0;
    color: var(--text-primary);
    border: 1px solid rgba(5, 150, 105, 0.1);
}
.btn-secondary:hover {
    background: #e2e8e5;
    transform: translateY(-2px);
}
.btn-danger {
    background: #ef4444;
    color: #ffffff;
}
.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
}
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Header & Navbar */
header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(5, 150, 105, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 2rem;
}
.navbar {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.logo-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #111827, var(--accent-emerald));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.logo-tag {
    background: rgba(5, 150, 105, 0.1);
    border: 1px solid var(--accent-emerald);
    color: var(--accent-emerald);
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
}
.nav-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
    list-style: none;
}
.nav-link {
    font-family: var(--font-heading);
    font-weight: 500;
    color: var(--text-secondary);
}
.nav-link:hover, .nav-link.active {
    color: var(--accent-emerald);
}

/* Form Controls */
.form-group {
    margin-bottom: 1.5rem;
}
.form-label {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    background: #ffffff;
    border: 1px solid rgba(5, 150, 105, 0.2);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent-emerald);
    box-shadow: 0 0 10px rgba(5, 150, 105, 0.1);
    background: #ffffff;
}
.form-textarea {
    resize: vertical;
    min-height: 120px;
}
.form-select option {
    background-color: #ffffff;
    color: var(--text-primary);
}
.form-input[type="file"] {
    background: #f9fafb;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
}
.form-input[type="file"]::file-selector-button {
    background: rgba(5, 150, 105, 0.08);
    border: 1px solid var(--accent-emerald);
    color: var(--accent-emerald);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    margin-right: 0.75rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-family: var(--font-heading);
    font-weight: 600;
}
.form-input[type="file"]::file-selector-button:hover {
    background: var(--accent-emerald);
    color: #ffffff;
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
}
.badge-admin { background: rgba(239, 68, 68, 0.1); color: #dc2626; border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-superlib { background: rgba(245, 158, 11, 0.1); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-lib { background: rgba(59, 130, 246, 0.1); color: #2563eb; border: 1px solid rgba(59, 130, 246, 0.2); }
.badge-visitor { background: rgba(16, 185, 129, 0.1); color: #059669; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-general { background: rgba(107, 114, 128, 0.1); color: #4b5563; border: 1px solid rgba(107, 114, 128, 0.2); }

/* Main layout grid */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* Notification banner */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
}
.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #065f46;
}
.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #991b1b;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 5rem 1rem;
    position: relative;
}
.hero-tag {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-emerald);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
    display: inline-block;
}
.hero-title {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #111827 30%, var(--accent-emerald) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto 2.5rem;
}

/* Search Bar styling */
.search-container {
    max-width: 800px;
    margin: 0 auto;
}
.search-form {
    display: flex;
    gap: 0.5rem;
    background: #ffffff;
    border: 1px solid rgba(5, 150, 105, 0.2);
    padding: 0.5rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(5, 150, 105, 0.05);
}
.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
}
.search-input:focus {
    outline: none;
}

/* Book Grid & Cards */
.book-section-title {
    margin: 2rem 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}
.book-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}
.book-badge-source {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
}
.source-local {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.source-external {
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, 0.2);
}
.book-cover {
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: 12px;
    background: var(--bg-tertiary);
    margin-bottom: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}
.book-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.book-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.book-abstract {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1.5rem;
    flex: 1;
}

/* Dashboard & Tabs */
.dashboard-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
}
.dashboard-sidebar {
    height: fit-content;
}
.tab-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    color: var(--text-secondary);
    border-radius: 10px;
    font-family: var(--font-heading);
    font-weight: 600;
    transition: var(--transition-smooth);
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
}
.tab-btn:hover, .tab-btn.active {
    background: rgba(5, 150, 105, 0.06);
    color: var(--accent-emerald);
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    padding: 1.5rem;
    text-align: center;
    background: #ffffff;
    border: 1px solid rgba(5, 150, 105, 0.08);
    border-radius: 16px;
}
.stat-num {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--accent-emerald);
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Table styling */
.table-container {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
th {
    background: #f9fafb;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.95rem;
}
tr:hover td {
    background: #fcfdfe;
}

/* Chat Interface Styling */
.chat-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 160px);
    margin: 1rem auto;
    border-radius: 20px;
    overflow: hidden;
}
.chat-sidebar {
    background: #f9fafb;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}
.chat-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat-thread-btn {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.04);
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}
.chat-thread-btn:hover, .chat-thread-btn.active {
    background: rgba(5, 150, 105, 0.06);
    color: var(--accent-emerald);
    border-color: rgba(5, 150, 105, 0.15);
}
.chat-main {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    height: 100%;
    min-height: 0;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: #ffffff;
}
.message-bubble {
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    font-size: 0.95rem;
}
.message-user {
    align-self: flex-end;
    background: var(--accent-emerald);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.15);
}
.message-assistant {
    align-self: flex-start;
    background: #f3f4f6;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: 4px;
}
.chat-input-area {
    padding: 1.5rem 2rem;
    background: #f9fafb;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.chat-form {
    display: flex;
    gap: 1rem;
}
.chat-input {
    flex: 1;
    background: #ffffff;
    border: 1px solid rgba(5, 150, 105, 0.2);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    color: var(--text-primary);
    font-family: var(--font-body);
}
.chat-input:focus {
    outline: none;
    border-color: var(--accent-emerald);
}

/* Auth Pages Layout */
.auth-container {
    max-width: 480px;
    margin: 4rem auto;
}

/* Modal styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}
.modal.open {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    width: 90%;
    max-width: 600px;
    background: #ffffff;
    border: 1px solid rgba(5, 150, 105, 0.15);
    border-radius: 20px;
    padding: 2rem;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

/* API Tester Layout */
.api-test-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}
.api-test-panel {
    background: #f9fafb;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 1rem;
    height: 300px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    color: #111827;
}

/* Responsive Utilities */
@media (max-width: 968px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .chat-container {
        grid-template-columns: 1fr;
    }
    .chat-sidebar {
        display: none;
    }
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .hero-title {
        font-size: 2.5rem;
    }
}
