/* ==========================================
   MangaStudio - Modals Component
   ========================================== */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.modal-overlay.visible {
    display: flex;
    opacity: 1;
}

/* Modal Container */
.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

.modal.modal-lg {
    max-width: 700px;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal Header */
.modal-header {
    padding: 24px 24px 0;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Modal Body */
.modal-body {
    padding: 24px;
}

/* Modal Inputs */
.modal-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: var(--transition);
    margin-bottom: 16px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

.modal-textarea {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

/* Modal Footer */
.modal-footer {
    padding: 0 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Chapter Preview Modal Styles */
.chapter-preview-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chapter-preview-summary {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
}

.chapter-preview-summary h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.chapter-preview-summary p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Improve Idea Section */
.improve-idea-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.improve-idea-section label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.improve-idea-input {
    width: 100%;
    min-height: 100px;
    padding: 14px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.improve-idea-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* Chapter Preview Actions */
.chapter-preview-actions {
    display: flex;
    gap: 12px;
}

.chapter-preview-actions .btn {
    flex: 1;
}

/* Chapter Number Badge */
.chapter-number-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-right: 12px;
}

/* Modal Sizes */
.modal.modal-sm {
    max-width: 400px;
}

/* Form Group */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-label .required {
    color: #ff3b30;
    margin-left: 2px;
}

/* Modal Select */
.modal-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

/* Image Upload Container */
.image-upload-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.image-preview {
    width: 100%;
    height: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-tertiary);
}

.image-preview-placeholder svg {
    width: 48px;
    height: 48px;
}

.image-preview-placeholder span {
    font-size: 13px;
}

.image-upload-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.btn-upload {
    cursor: pointer;
}

/* Disabled Button */
.btn-disabled,
.btn[disabled],
button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-disabled:hover,
.btn[disabled]:hover,
button[disabled]:hover {
    transform: none;
    box-shadow: none;
}

/* Tooltip Badge */
.tooltip-badge {
    font-size: 11px;
    color: var(--text-tertiary);
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

/* Danger Modal */
.modal-header-danger {
    text-align: center;
    padding-bottom: 16px;
}

.modal-icon-danger {
    width: 64px;
    height: 64px;
    background: rgba(255, 59, 48, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.modal-icon-danger svg {
    width: 32px;
    height: 32px;
    color: #ff3b30;
}

.confirm-delete-message {
    font-size: 15px;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 12px;
    line-height: 1.6;
}

.confirm-delete-message strong {
    color: var(--text-primary);
}

.confirm-delete-warning {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.6;
}

/* Danger Button */
.btn-danger {
    background: #ff3b30;
    color: white;
}

.btn-danger:hover {
    background: #e63329;
    transform: scale(1.02);
}

/* ==========================================
   Create Chapter Modal Styles
   ========================================== */

/* Form Label Hint */
.form-label-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    margin-left: 4px;
}

/* Chapter Idea Container */
.chapter-idea-container {
    background: #f9f9fb;
    border-radius: var(--radius-md);
    padding: 4px;
}

.chapter-idea-textarea {
    background: #f9f9fb;
    border: 1px solid transparent;
    min-height: 120px;
}

.chapter-idea-textarea:focus {
    background: var(--bg-primary);
    border-color: var(--accent);
}

/* Chapter AI Actions */
.chapter-ai-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
}

/* ==========================================
   Edit Title Modal Styles
   ========================================== */

/* Small modal adjustments */
.modal.modal-sm .modal-body {
    padding: 20px 24px;
}

.modal.modal-sm .form-group {
    margin-bottom: 0;
}

/* ==========================================
   Chapter Preview Modal - Detailed View
   ========================================== */

/* Modal Header with Close Button */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.chapter-preview-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chapter-preview-header .modal-title {
    display: flex;
    align-items: center;
}

.modal-close-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Scrollable Body */
.chapter-preview-body {
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Detail Section */
.chapter-detail-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
}

.chapter-detail-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.chapter-detail-section-title svg {
    color: var(--accent);
}

.chapter-detail-content {
    color: var(--text-primary);
}

/* Summary and Narrative Text */
.chapter-summary-text,
.chapter-narrative-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    margin: 0;
}

/* Tensions Grid */
.tensions-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tension-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tension-bar-label {
    width: 80px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.tension-bar-container {
    flex: 1;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.tension-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Tension colors */
.tension-bar-fill.tension-external {
    background: linear-gradient(90deg, #ff6b6b, #ff4757);
}

.tension-bar-fill.tension-internal {
    background: linear-gradient(90deg, #a29bfe, #6c5ce7);
}

.tension-bar-fill.tension-moral {
    background: linear-gradient(90deg, #feca57, #ff9f43);
}

.tension-bar-fill.tension-mystery {
    background: linear-gradient(90deg, #48dbfb, #0abde3);
}

.tension-bar-value {
    width: 40px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: right;
    flex-shrink: 0;
}

/* Characters Present List */
.characters-present-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.character-present-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.character-present-avatar {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.character-present-info {
    flex: 1;
    min-width: 0;
}

.character-present-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.character-present-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.character-role-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.character-role-badge.role-protagonist {
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
}

.character-role-badge.role-ally {
    background: rgba(52, 199, 89, 0.1);
    color: #34c759;
}

.character-role-badge.role-antagonist {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.character-role-badge.role-support {
    background: rgba(255, 149, 0, 0.1);
    color: #ff9500;
}

.character-present-highlight {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Scenarios Tags */
.scenarios-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scenario-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.scenario-tag svg {
    color: var(--text-tertiary);
}

/* Hook Section */
.hook-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hook-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 149, 0, 0.1);
    color: #ff9500;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    width: fit-content;
}

.hook-description-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
    font-style: italic;
}

/* Empty State for Sections */
.chapter-detail-empty {
    font-size: 13px;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Hide sections when empty */
.chapter-detail-section.hidden {
    display: none;
}
