/* Admin Panel Styles — extends shared/theme.css */

/* ============ Modal Base ============ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    padding-right: 1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* ============ Tab Panels ============ */

.tab-panel {
    display: none;
}

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

/* ============ Admin Sections ============ */

.admin-section {
    margin-bottom: 2.5rem;
}

.admin-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ============ Search Row ============ */

.search-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-row input[type="search"],
.search-row input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.input-year {
    width: 80px !important;
    min-width: 80px !important;
    flex: 0 0 80px !important;
}

.want-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.want-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ============ Search Result Cards ============ */

.search-result-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s;
}

.search-result-card:hover {
    border-color: var(--accent);
}

.search-result-poster {
    width: 60px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.search-result-poster img {
    width: 100%;
    display: block;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.search-result-year {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-result-overview {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* ============ Admin List Items ============ */

.admin-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.admin-list-item:hover {
    background: var(--bg-tertiary);
}

.admin-list-item:last-child {
    border-bottom: none;
}

.admin-list-thumb {
    width: 40px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.admin-list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-list-info {
    flex: 1;
    min-width: 0;
}

.admin-list-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-list-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.admin-list-stars {
    flex-shrink: 0;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

.admin-list-stars .star-filled {
    color: #f5c518;
}

.admin-list-stars .star-empty {
    color: var(--text-muted);
    opacity: 0.3;
}

.admin-list-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ============ Buttons ============ */

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============ Modal Additions ============ */

.modal-sm {
    max-width: 420px;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.form-label:first-child {
    margin-top: 0;
}

/* ============ Textarea / Select ============ */

textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    width: 100%;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

/* ============ Star Input ============ */

.star-input {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.star-input .star {
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.15s;
    color: var(--text-muted);
    opacity: 0.4;
    user-select: none;
}

.star-input .star.active {
    color: #f5c518;
    opacity: 1;
}

.star-input .star:hover {
    color: #f5c518;
    opacity: 0.8;
}

/* ============ Sub-tabs (Books) ============ */

.sub-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.sub-tab-btn {
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.sub-tab-btn:hover {
    color: var(--text-primary);
}

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

.sub-tab-panel {
    display: none;
}

.sub-tab-panel.active {
    display: block;
}

/* ============ Form Grid ============ */

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

/* ============ Toast Notifications ============ */

#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #fff;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
    max-width: 350px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: var(--accent);
    color: #000;
}

.toast-error {
    background: #e74c3c;
}

/* ============ Auth ============ */

#auth-modal .modal-body input {
    width: 100%;
    margin-top: 0.75rem;
}

.auth-error {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: none;
}

.auth-error.visible {
    display: block;
}

/* ============ Empty State ============ */

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ============ Loading ============ */

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.btn .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.4rem;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ Blacklist Items ============ */

.blacklist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.blacklist-item:last-child {
    border-bottom: none;
}

.blacklist-item:hover {
    background: var(--bg-tertiary);
}

.blacklist-name {
    font-size: 0.9rem;
}

.blacklist-code {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.blacklist-reason {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin-left: 0.75rem;
    flex: 1;
}

/* ============ Page Header ============ */

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

/* ============ Responsive ============ */

@media (max-width: 768px) {
    .search-row {
        flex-direction: column;
    }

    .search-row input {
        min-width: unset !important;
    }

    .input-year {
        width: 100% !important;
        flex: 1 !important;
    }

    .admin-list-thumb {
        width: 30px;
        height: 45px;
    }

    .admin-list-actions {
        flex-direction: column;
        gap: 0.25rem;
    }

    .admin-list-stars {
        display: none;
    }

    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab-btn {
        white-space: nowrap;
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .search-result-card {
        flex-direction: column;
    }

    .search-result-poster {
        width: 80px;
    }

    .search-result-actions {
        align-self: flex-start;
    }
}
