/* ============================================
   NovelShelf — Admin Theme
   Functional, minimal, no-nonsense design
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937;
    background: #f9fafb;
    line-height: 1.5;
    font-size: 14px;
}

a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Login Page --- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f3f4f6;
}
.login-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    padding: 40px;
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}
.login-sub {
    color: #6b7280;
    font-size: .88rem;
    margin-bottom: 24px;
}
.back-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    font-size: .82rem;
    color: #9ca3af;
}

/* --- Navigation --- */
.admin-nav {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand a {
    font-weight: 700;
    font-size: 1.1rem;
    color: #111827;
}
.nav-brand a:hover { text-decoration: none; }
.nav-tag {
    background: #eef2ff;
    color: #4f46e5;
    font-size: .7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: .88rem;
}
.nav-links a {
    color: #4b5563;
    padding: 4px 0;
}
.nav-links a.active {
    color: #4f46e5;
    font-weight: 600;
}
.nav-sep { color: #d1d5db; }
.nav-user {
    color: #6b7280;
    font-size: .82rem;
}

/* --- Main Content --- */
.admin-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

/* --- Alerts --- */
.alert {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: .88rem;
}
.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h2 {
    font-size: 1.3rem;
}
.breadcrumb {
    font-size: .82rem;
    color: #9ca3af;
    display: block;
    margin-top: 2px;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}
.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: #4f46e5;
}
.stat-label {
    font-size: .82rem;
    color: #6b7280;
    margin-top: 4px;
}

/* --- Section --- */
.section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}
.section h3 {
    font-size: 1.05rem;
    margin-bottom: 16px;
}

/* --- Data Table --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #6b7280;
    padding: 10px 12px;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
}
.data-table td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tbody tr:hover {
    background: #f9fafb;
}
.data-table .text-muted {
    font-size: .82rem;
    color: #9ca3af;
}

.table-thumb {
    width: 36px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 8px;
}

.actions {
    white-space: nowrap;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.badge-published {
    background: #ecfdf5;
    color: #065f46;
}
.badge-draft {
    background: #f3f4f6;
    color: #6b7280;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: .88rem;
    font-weight: 500;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    transition: all .15s;
}
.btn:hover {
    background: #f9fafb;
    text-decoration: none;
}
.btn-primary {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}
.btn-primary:hover {
    background: #4338ca;
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: #6b7280;
}
.btn-ghost:hover {
    background: #f3f4f6;
    color: #374151;
}
.btn-danger {
    color: #dc2626;
    border-color: #fecaca;
}
.btn-danger:hover {
    background: #fef2f2;
}
.btn-sm {
    padding: 4px 10px;
    font-size: .78rem;
}

/* --- Search Bar --- */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}
.search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .9rem;
}
.search-bar input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* --- Form Card --- */
.form-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: 6px;
    color: #374151;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .9rem;
    font-family: inherit;
    background: #fff;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-group textarea {
    resize: vertical;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
    margin-top: 8px;
}

/* --- Radio Group --- */
.radio-group {
    display: flex;
    gap: 20px;
    padding-top: 4px;
}
.radio-group label {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* --- Checkbox Label --- */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-weight: 400;
    font-size: .85rem;
    color: #6b7280;
    cursor: pointer;
}

/* --- Current Cover Preview --- */
.current-cover {
    margin-top: 10px;
}
.current-cover img {
    width: 80px;
    height: 110px;
    object-fit: cover;
    border-radius: 4px;
}

/* --- Editor Toolbar --- */
.editor-toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}
.editor-toolbar button {
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 6px 14px;
    cursor: pointer;
    font-size: .85rem;
    color: #374151;
}
.editor-toolbar button:hover {
    background: #f3f4f6;
}
.editor-textarea {
    border-radius: 0 0 6px 6px !important;
    font-family: 'Courier New', monospace;
    font-size: .88rem;
    line-height: 1.6;
    min-height: 400px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #9ca3af;
    font-size: .92rem;
}

/* --- Login Form Overrides --- */
.login-card label {
    display: block;
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: 4px;
}
.login-card input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .92rem;
    margin-bottom: 16px;
}
.login-card input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.login-card button {
    width: 100%;
    padding: 10px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
}
.login-card button:hover {
    background: #4338ca;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .admin-nav {
        padding: 0 16px;
    }
    .nav-links {
        gap: 10px;
        font-size: .82rem;
    }
    .admin-main {
        padding: 16px;
    }
    .form-row {
        flex-direction: column;
    }
    .search-bar {
        flex-wrap: wrap;
    }
    .search-bar input {
        min-width: 0;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .data-table {
        display: block;
        overflow-x: auto;
    }
}