/**
 * StoryManager Component Styles
 */

/* Flash Messages */
.flash-message {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    animation: flashSlide 0.3s ease;
}

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

.flash-message--success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.flash-message--error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Base */
.story-manager {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.story-manager__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e8e8e8;
    flex-wrap: wrap;
    gap: 12px;
}

.story-manager__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
}

.story-manager__title svg {
    color: #4CAF50;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-back:hover {
    color: #333;
}

/* Table */
.stories-table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e8e8e8;
}

.stories-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.stories-table th {
    text-align: left;
    padding: 14px 12px;
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e8e8e8;
    white-space: nowrap;
}

.stories-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.stories-table tr:hover {
    background: #f8f9fa;
}

.stories-table .col-id {
    width: 50px;
    color: #999;
}

.stories-table .col-point {
    max-width: 150px;
}

.stories-table .col-title {
    max-width: 200px;
    font-weight: 500;
}

.stories-table .col-lang {
    width: 60px;
    text-align: center;
}

.stories-table .col-audio {
    width: 60px;
    text-align: center;
}

.stories-table .col-date {
    width: 120px;
    color: #666;
    font-size: 0.85rem;
}

.stories-table .col-actions {
    width: 100px;
    white-space: nowrap;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge--success {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge--muted {
    background: #f5f5f5;
    color: #999;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: #4CAF50;
    color: #fff;
}

.btn-primary:hover {
    background: #43a047;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-secondary:hover {
    background: #e8e8e8;
}

.btn-outline {
    background: transparent;
    border: 2px solid #ddd;
    color: #555;
}

.btn-outline:hover {
    border-color: #4CAF50;
    color: #4CAF50;
}

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

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

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: #f5f5f5;
    color: #666;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #e8e8e8;
    color: #333;
}

.btn-icon--danger:hover {
    background: #ffebee;
    color: #c62828;
}

.btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin: -9px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    padding: 16px;
}

.pagination__link {
    color: #4CAF50;
    text-decoration: none;
    font-weight: 500;
}

.pagination__link:hover {
    text-decoration: underline;
}

.pagination__info {
    color: #666;
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Form Sections (for edit view) */
.form-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid #e8e8e8;
}

.form-section__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.form-section__title svg {
    color: #4CAF50;
}

.form-label {
    display: block;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-label .required {
    color: #f44336;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #4CAF50;
}

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

.form-col--grow {
    flex: 1;
}

.form-col--auto {
    min-width: 140px;
}

/* Media Editor */
.media-editor {
    margin-top: 12px;
}

.media-preview {
    position: relative;
    display: inline-block;
}

.media-preview img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.media-preview audio {
    max-width: 100%;
}

.media-preview .btn-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f44336;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.media-controls .divider {
    color: #999;
    font-size: 0.85rem;
}

.recording-ui {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff3e0;
    border-radius: 8px;
    border: 1px solid #ffcc80;
}

.recording-indicator {
    width: 12px;
    height: 12px;
    background: #f44336;
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#recordingTimer {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Mini Map */
.mini-map {
    height: 150px;
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid #ddd;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #eee;
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .story-manager {
        padding: 12px;
    }

    .story-manager__header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stories-table {
        font-size: 0.8rem;
    }

    .stories-table th,
    .stories-table td {
        padding: 8px 6px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-col--auto {
        min-width: 100%;
    }

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

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }
}
