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

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #334155;
    background-color: #f1f5f9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =============================================================================
   Layout
   ============================================================================= */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* =============================================================================
   Navigation
   ============================================================================= */
.navbar {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 0.875rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 0.5rem;
    align-items: center;
}

.nav-menu a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.nav-menu a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-menu .active {
    background: var(--primary);
    color: white;
}

.user-greeting {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    padding: 0.5rem;
}

/* =============================================================================
   Main Content
   ============================================================================= */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* =============================================================================
   Footer
   ============================================================================= */
.footer {
    background: var(--dark);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: auto;
}

/* =============================================================================
   Messages
   ============================================================================= */
.messages {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    border: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid var(--info);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid var(--warning);
}

/* =============================================================================
   Typography
   ============================================================================= */
h1, h2, h3, h4, h5, h6 {
    color: var(--dark);
    font-weight: 700;
    line-height: 1.3;
}

h1 {
    font-size: 2.25rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.25rem;
}

h3 {
    font-size: 1.375rem;
    margin-bottom: 1rem;
}

p {
    margin-bottom: 1rem;
}

/* =============================================================================
   Buttons
   ============================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--dark);
}

.btn-outline:hover {
    background: var(--light);
    border-color: var(--gray);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.0625rem;
}

/* =============================================================================
   Cards
   ============================================================================= */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-body {
    padding: 1.5rem;
}

/* =============================================================================
   Forms
   ============================================================================= */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9375rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control::placeholder {
    color: var(--gray);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

.form-help {
    font-size: 0.8125rem;
    color: var(--gray);
    margin-top: 0.375rem;
}

.errorlist {
    color: var(--danger);
    font-size: 0.875rem;
    list-style: none;
    margin-top: 0.375rem;
}

/* =============================================================================
   Tables
   ============================================================================= */
.table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8fafc;
    color: var(--dark);
    font-weight: 600;
    text-align: left;
    padding: 1rem 1.25rem;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: #f8fafc;
}

/* =============================================================================
   Book Grid
   ============================================================================= */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.book-card-image {
    position: relative;
    height: 220px;
    overflow: hidden;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

.book-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.book-card-no-cover {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray);
    font-size: 3rem;
}

.book-card-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-card-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.375rem;
    line-height: 1.4;
}

.book-card-title a {
    color: inherit;
    text-decoration: none;
}

.book-card-title a:hover {
    color: var(--primary);
}

.book-card-author {
    color: var(--secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.book-card-author a {
    color: var(--primary);
    text-decoration: none;
}

.book-card-author a:hover {
    text-decoration: underline;
}

.book-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* =============================================================================
   Categories
   ============================================================================= */
.categories-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.category-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.category-tag:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-1px);
}

/* =============================================================================
   Authors Grid
   ============================================================================= */
.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

.author-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.author-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.author-card h3 {
    margin-bottom: 0.5rem;
}

.author-card h3 a {
    color: var(--dark);
    text-decoration: none;
}

.author-card h3 a:hover {
    color: var(--primary);
}

.author-card .books-count {
    color: var(--secondary);
    font-size: 0.875rem;
}

/* =============================================================================
   Auth Forms
   ============================================================================= */
.auth-form {
    max-width: 440px;
    margin: 2rem auto;
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-form .btn {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
}

.auth-form-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--secondary);
}

.auth-form-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-form-footer a:hover {
    text-decoration: underline;
}

/* =============================================================================
   Search
   ============================================================================= */
.search-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-form input[type="text"],
.search-form select {
    padding: 0.625rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    min-width: 180px;
}

.search-form input[type="text"]:focus,
.search-form select:focus {
    outline: none;
    border-color: var(--primary);
}

.search-form input[type="text"] {
    flex: 1;
    min-width: 220px;
}

/* =============================================================================
   Detail Pages
   ============================================================================= */
.detail-header {
    display: flex;
    gap: 2.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.detail-image {
    width: 240px;
    height: 360px;
    object-fit: cover;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.detail-image-placeholder {
    width: 240px;
    height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-radius: var(--radius);
    color: var(--gray);
    font-size: 4rem;
}

.detail-info {
    flex: 1;
    min-width: 300px;
}

.detail-info p {
    margin-bottom: 0.75rem;
    font-size: 1.0625rem;
}

.detail-info strong {
    color: var(--dark);
    font-weight: 600;
}

/* =============================================================================
   Actions Bar
   ============================================================================= */
.actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* =============================================================================
   Hero Section
   ============================================================================= */
.hero {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 4rem 2rem;
    border-radius: var(--radius);
    margin-bottom: 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

.hero h1 {
    color: white;
    font-size: 2.75rem;
    margin-bottom: 1rem;
    position: relative;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

/* =============================================================================
   Stats
   ============================================================================= */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card .number {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-card .label {
    color: var(--secondary);
    font-weight: 600;
    font-size: 0.9375rem;
}

/* =============================================================================
   Section
   ============================================================================= */
.section {
    margin-bottom: 3rem;
}

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

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

/* =============================================================================
   Page Header
   ============================================================================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* =============================================================================
   Empty State
   ============================================================================= */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .detail-header {
        flex-direction: column;
        align-items: center;
    }

    .detail-image,
    .detail-image-placeholder {
        width: 200px;
        height: 300px;
    }

    .search-form {
        flex-direction: column;
    }

    .search-form input,
    .search-form select {
        width: 100%;
    }

    .auth-form {
        padding: 1.5rem;
        margin: 1rem;
    }
}

/* =============================================================================
   Animations
   ============================================================================= */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Stagger animations for grid items */
.book-grid > .book-card {
    animation: fadeIn 0.4s ease backwards;
}

.book-grid > .book-card:nth-child(1) { animation-delay: 0.05s; }
.book-grid > .book-card:nth-child(2) { animation-delay: 0.1s; }
.book-grid > .book-card:nth-child(3) { animation-delay: 0.15s; }
.book-grid > .book-card:nth-child(4) { animation-delay: 0.2s; }
.book-grid > .book-card:nth-child(5) { animation-delay: 0.25s; }
.book-grid > .book-card:nth-child(6) { animation-delay: 0.3s; }
