/**
 * UYI Write - Component Styles
 * Buttons, forms, cards, alerts
 */

/* Buttons */
.btn {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn:hover {
    background-color: var(--accent);
    border-color: var(--accent);
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-block {
    display: block;
    width: 100%;
}

.oauth-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    margin: var(--spacing-lg) 0;
}

.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    width: 100%;
    opacity: 0.6;
    cursor: not-allowed;
}

.oauth-icon {
    font-weight: bold;
    font-size: 1.1rem;
}

.oauth-note {
    display: block;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: var(--spacing-sm);
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-help {
    display: block;
    margin-top: var(--spacing-xs);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.auth-form {
    margin-bottom: var(--spacing-lg);
}

.auth-divider {
    text-align: center;
    margin: var(--spacing-lg) 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
}

.auth-divider span {
    position: relative;
    background-color: var(--bg-secondary);
    padding: 0 var(--spacing-md);
    color: var(--text-secondary);
}

.auth-links {
    text-align: center;
    margin-top: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.auth-links a {
    color: var(--accent);
    font-size: 0.9rem;
}

/* Alerts */
.alert {
    position: fixed;
    top: calc(var(--header-height) + var(--spacing-md));
    left: 50%;
    transform: translateX(-50%);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: 4px;
    margin-bottom: var(--spacing-md);
    z-index: 10001;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.alert-error {
    background-color: var(--bg-secondary);
    border: 1px solid var(--error);
    color: var(--error);
}

.alert:hover {
    opacity: 0.9;
}

.alert-success {
    background-color: var(--bg-secondary);
    border: 1px solid var(--success);
    color: var(--success);
}

/* Cards */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.1rem;
    font-weight: bold;
}

.card-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* Book Card */
.book-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.book-card:hover {
    border-color: var(--accent);
    background-color: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.book-card-cover {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-tertiary);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.book-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-md);
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
}

.book-card-title-section {
    flex: 1;
    min-width: 0;
}

.book-card-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
    line-height: 1.4;
    word-wrap: break-word;
}

.book-card-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: var(--spacing-xs);
    line-height: 1.4;
    word-wrap: break-word;
}

.book-card-menu {
    position: relative;
    flex-shrink: 0;
}

.book-card-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
}

.book-card-menu-btn:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.book-card-menu-btn svg {
    width: 20px;
    height: 20px;
}

.book-card-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    min-width: 160px;
    z-index: 100;
    overflow: hidden;
}

.book-menu-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    transition: background-color 0.2s;
}

.book-menu-item:hover {
    background-color: var(--bg-tertiary);
}

.book-menu-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.book-menu-item:hover svg {
    color: var(--accent);
}

.book-menu-item-danger {
    color: var(--error);
}

.book-menu-item-danger:hover {
    background-color: rgba(211, 47, 47, 0.1);
}

.book-menu-item-danger svg {
    color: var(--error);
}

.book-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.book-stat {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.book-stat-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.9;
}

.book-card-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: auto;
    padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-lg);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: calc(var(--spacing-xl) * 2);
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-sm);
}

.empty-state-text {
    margin-bottom: var(--spacing-lg);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    margin-top: var(--spacing-md);
}

.form-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-lg);
}

