/**
 * Scenarist - Styles
 * AI Instagram Carousel Generator
 */

/* ============================================
   Tool Hero & Content (consistent with other tools)
   ============================================ */

.tool-hero {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-16) 0;
    text-align: center;
}

.tool-hero h1 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: var(--space-3);
    color: var(--text);
}

.tool-hero p {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.tool-content {
    padding: var(--space-12) 0;
}

/* Layout */
.scenarist {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    min-height: 600px;
}

@media (max-width: 1024px) {
    .scenarist {
        grid-template-columns: 1fr;
    }
}

.scenarist__form,
.scenarist__result {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Source Tabs */
.source-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem;
    background: var(--gray-100);
    border-radius: var(--radius-base);
}

.source-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.source-tab:hover {
    color: var(--text);
}

.source-tab--active {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Source Panels */
.source-panel {
    display: none;
}

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

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.15s ease;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea[readonly] {
    background: var(--gray-50);
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    font-size: 0.875rem;
    transition: border-color 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    font-size: 0.875rem;
    background: var(--white);
    cursor: pointer;
}

.form-range {
    width: 100%;
    accent-color: var(--primary);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* YouTube Input */
.youtube-input {
    display: flex;
    gap: 0.5rem;
}

.youtube-input .form-input {
    flex: 1;
}

/* YouTube Preview */
.youtube-preview {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-base);
    border: 1px solid var(--border);
}

.youtube-preview__header {
    margin-bottom: 1rem;
}

.youtube-preview__title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.youtube-preview__channel {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* YouTube Loading */
.youtube-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
}

.youtube-loading:not([hidden]) {
    display: flex;
    color: var(--text-secondary);
}

/* Form Settings */
.form-settings {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-base);
}

.form-details {
    font-size: 0.875rem;
}

.form-details summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-details[open] summary {
    margin-bottom: 0.75rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.limit-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Generation Progress */
.generation-progress {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--gray-50);
    border-radius: var(--radius-base);
    color: var(--text-secondary);
}

.generation-progress:not([hidden]) {
    display: flex;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--white);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn:hover {
    background: var(--gray-50);
}

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

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

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

.btn--secondary {
    background: var(--gray-100);
    border-color: var(--gray-200);
}

.btn--ghost {
    border-color: transparent;
    background: transparent;
}

.btn--ghost:hover {
    background: var(--gray-100);
}

.btn--small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn--large {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

.btn--new {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.btn--new:hover {
    background: #047857;
    border-color: #047857;
}

.btn--telegram {
    background: #0088cc;
    border-color: #0088cc;
    color: var(--white);
}

.btn--telegram:hover {
    background: #006699;
    border-color: #006699;
}

/* Result Area */
.result-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-area[hidden] {
    display: none !important;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.result-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
}

/* Slides List */
.slides-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.slide-item {
    padding: 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    transition: border-color 0.15s ease;
}

.slide-item:hover {
    border-color: var(--gray-300);
}

.slide-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.slide-item__number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50%;
}

.slide-item__type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.slide-item__text {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
}

.slide-item--cover {
    background: linear-gradient(135deg, var(--gray-900), var(--gray-800));
    border-color: var(--gray-700);
}

.slide-item--cover .slide-item__number {
    background: var(--white);
    color: var(--gray-900);
}

.slide-item--cover .slide-item__type {
    color: var(--gray-400);
}

.slide-item--cover .slide-item__text {
    color: var(--white);
    font-size: 1.125rem;
    font-weight: 600;
}

.slide-item--cta {
    background: var(--gray-50);
    border-style: dashed;
}

.slide-item__actions {
    display: flex;
    gap: 0.25rem;
}

.slide-item__btn {
    padding: 0.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.slide-item__btn:hover {
    background: var(--gray-100);
    color: var(--text);
}

.slide-item--cover .slide-item__btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

/* Slide Edit Area */
.slide-item__edit-area {
    margin-top: 0.75rem;
}

.slide-item__textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    font-family: inherit;
    font-size: 0.9375rem;
    line-height: 1.6;
    resize: vertical;
}

.slide-item--cover .slide-item__textarea {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.slide-item__edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Caption Area */
.caption-area {
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius-base);
}

.caption-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.caption-actions {
    display: flex;
    gap: 0.5rem;
}

.caption-length {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state[hidden] {
    display: none !important;
}

.empty-state svg {
    opacity: 0.5;
}

.empty-state p {
    max-width: 300px;
    line-height: 1.5;
}

/* History Section */
.history-section {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.history-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.history-search {
    position: relative;
    margin-bottom: 0.75rem;
}

.history-search__input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s ease;
}

.history-search__input:focus {
    outline: none;
    border-color: var(--primary);
}

.history-search__input::placeholder {
    color: var(--text-secondary);
}

.history-search__clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.history-search__clear:hover {
    background: var(--gray-100);
    color: var(--text);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.history-empty {
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-base);
    cursor: pointer;
    transition: all 0.15s ease;
}

.history-item:hover {
    border-color: var(--primary);
    background: var(--gray-50);
}

.history-item__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.history-item__content {
    flex: 1;
    min-width: 0;
}

.history-item__title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item__source {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.history-item__meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.history-item__delete {
    flex-shrink: 0;
    padding: 0.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all 0.15s ease;
}

.history-item:hover .history-item__delete {
    opacity: 1;
}

.history-item__delete:hover {
    background: var(--error);
    color: var(--white);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--gray-900);
    color: var(--white);
    border-radius: var(--radius-base);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toast-in 0.2s ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
}

.toast--success {
    background: var(--success);
}

.toast--error {
    background: var(--error);
}

/* Mobile Adjustments */
@media (max-width: 640px) {
    .scenarist__form,
    .scenarist__result {
        gap: 1rem;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .result-actions .btn {
        white-space: nowrap;
    }
}
