/**
 * フロントエンド CSS
 * assets/css/frontend.css
 */

/* ============================================
   基本レイアウト
   ============================================ */
.psc-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "游ゴシック", YuGothic, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
}

.psc-container * {
    box-sizing: border-box;
}

/* ============================================
   プログレスバー
   ============================================ */
.psc-progress-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    position: relative;
    padding: 0 20px;
}

.psc-progress-bar::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: #e0e0e0;
    z-index: -1;
}

.psc-progress-step {
    text-align: center;
    position: relative;
    flex: 1;
    cursor: pointer;
}

.psc-progress-step .step-number {
    display: inline-block;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    background: #f0f0f0;
    color: #999;
    font-weight: bold;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.psc-progress-step.active .step-number {
    background: #2196F3;
    color: white;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.psc-progress-step.completed .step-number {
    background: #4CAF50;
    color: white;
}

.psc-progress-step.completed .step-number::after {
    content: '✓';
    position: absolute;
    font-size: 20px;
}

.psc-progress-step .step-label {
    display: block;
    font-size: 14px;
    color: #666;
    transition: color 0.3s ease;
}

.psc-progress-step.active .step-label,
.psc-progress-step.completed .step-label {
    color: #333;
    font-weight: 600;
}

/* ============================================
   フォーム要素
   ============================================ */
.psc-form-group {
    margin-bottom: 25px;
}

.psc-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.psc-input,
.psc-select,
.psc-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.psc-input:focus,
.psc-select:focus,
.psc-textarea:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

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

.psc-ai-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 768px) {
    .psc-ai-selector {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   ファイルアップロード
   ============================================ */
.psc-file-upload-area {
    margin-top: 10px;
}

.psc-dropzone {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.psc-dropzone:hover {
    border-color: #2196F3;
    background: #f0f8ff;
}

.psc-dropzone.dragging {
    border-color: #2196F3;
    background: #e3f2fd;
    transform: scale(1.02);
}

.psc-dropzone .upload-icon {
    color: #999;
    margin-bottom: 10px;
}

.psc-dropzone p {
    margin: 10px 0;
    color: #666;
}

.psc-dropzone .file-types {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
}

.psc-file-list {
    margin-top: 20px;
}

.psc-file-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.psc-file-item.uploading {
    background: #fff3cd;
    border-color: #ffc107;
}

.psc-file-item.completed {
    background: #d4edda;
    border-color: #28a745;
}

.psc-file-item.error {
    background: #f8d7da;
    border-color: #dc3545;
}

.psc-file-item .dashicons {
    margin-right: 10px;
    font-size: 20px;
}

.psc-file-item .file-name {
    flex: 1;
    margin-right: 10px;
}

.psc-file-item .delete-file-btn {
    padding: 5px 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.psc-spinner-small {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

/* ============================================
   特許入力
   ============================================ */
.psc-patent-input {
    display: flex;
    gap: 10px;
}

.psc-patent-input .psc-input {
    flex: 1;
}

.psc-reference-patents-list,
.psc-patent-pdf-list {
    margin-top: 15px;
}

.patent-item,
.patent-pdf-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.patent-item .patent-number {
    flex: 1;
    font-weight: 500;
}

.remove-patent-btn,
.remove-pdf-btn {
    padding: 4px 8px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.remove-patent-btn:hover,
.remove-pdf-btn:hover {
    background: #5a6268;
}

/* ============================================
   ボタン
   ============================================ */
.psc-btn-primary,
.psc-btn-secondary,
.psc-btn-success {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.psc-btn-primary {
    background: #2196F3;
    color: white;
}

.psc-btn-primary:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.psc-btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

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

.psc-btn-secondary:hover {
    background: #e0e0e0;
}

.psc-btn-success {
    background: #4CAF50;
    color: white;
}

.psc-btn-success:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.psc-form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

/* ============================================
   検索結果
   ============================================ */
.psc-search-status,
.psc-generation-status {
    text-align: center;
    padding: 40px 20px;
}

.psc-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196F3;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.psc-spinner-large {
    width: 80px;
    height: 80px;
    border-width: 4px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.psc-search-results {
    margin-top: 20px;
}

.psc-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.psc-results-header h3 {
    margin: 0;
    font-size: 20px;
}

.psc-results-actions {
    display: flex;
    gap: 10px;
}

/* ============================================
   テーブル
   ============================================ */
.psc-patents-table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
}

.psc-patents-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.psc-patents-table th,
.psc-patents-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.psc-patents-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.psc-patents-table .patent-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.view-patent-detail {
    padding: 6px 12px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.view-patent-detail:hover {
    background: #1976D2;
}

.psc-selected-count {
    margin-top: 15px;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 4px;
    font-weight: 600;
}

/* ============================================
   タブ
   ============================================ */
.psc-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 20px;
}

.psc-tab {
    padding: 12px 24px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    position: relative;
    color: #666;
    transition: all 0.3s ease;
}

.psc-tab:hover {
    color: #333;
    background: #f8f9fa;
}

.psc-tab.active {
    color: #2196F3;
    background: white;
}

.psc-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #2196F3;
}

.psc-tab-content {
    background: white;
    padding: 20px;
    border-radius: 0 0 8px 8px;
}

.psc-tab-pane {
    display: none;
}

.psc-tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ============================================
   ドキュメントビューア
   ============================================ */
.psc-document-viewer {
    padding: 20px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    line-height: 1.8;
}

.psc-document-viewer h3 {
    color: #2196F3;
    margin: 20px 0 10px;
    font-size: 18px;
}

.psc-document-viewer h4 {
    color: #333;
    margin: 15px 0 10px;
    font-size: 16px;
    font-weight: 600;
}

.psc-document-viewer p {
    margin: 10px 0;
}

/* ============================================
   プログレスバー（生成時）
   ============================================ */
.psc-progress-detail {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2196F3, #4CAF50);
    transition: width 0.5s ease;
}

.progress-text {
    display: block;
    text-align: center;
    margin-top: 10px;
    font-weight: 600;
    color: #666;
}

/* ============================================
   ダウンロードアクション
   ============================================ */
.psc-download-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    justify-content: center;
}

.psc-download-actions button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.psc-download-actions svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   修正インターフェース
   ============================================ */
.psc-revision-interface {
    margin-top: 20px;
}

.psc-current-version {
    margin-bottom: 30px;
}

.psc-current-version h3 {
    margin-bottom: 15px;
    color: #333;
}

.psc-modification-input {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.psc-modification-input h3 {
    margin-bottom: 15px;
    color: #333;
}

.psc-modification-options {
    margin: 15px 0;
}

.psc-modification-options label {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
}

.psc-modification-options input[type="checkbox"] {
    margin-right: 8px;
}

/* ============================================
   修正履歴
   ============================================ */
.psc-revision-history {
    margin-top: 30px;
}

.psc-history-list {
    margin-top: 15px;
}

.revision-item {
    padding: 15px;
    margin-bottom: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.revision-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.revision-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.revision-number {
    font-weight: 600;
    color: #2196F3;
}

.revision-date {
    color: #666;
    font-size: 14px;
}

.revision-request {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
}

.load-revision-btn {
    padding: 8px 16px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.load-revision-btn:hover {
    background: #1976D2;
}

/* ============================================
   モーダル
   ============================================ */
.psc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.psc-modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}

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

.psc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.psc-modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.psc-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.psc-modal-close:hover {
    color: #333;
}

.psc-modal-body {
    padding: 20px;
    max-height: calc(80vh - 70px);
    overflow-y: auto;
}

.patent-meta {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.patent-meta p {
    margin: 5px 0;
}

.patent-abstract,
.patent-claims {
    margin-top: 20px;
}

.patent-abstract h5,
.patent-claims h5 {
    margin-bottom: 10px;
    color: #2196F3;
}

/* ============================================
   ローディングオーバーレイ
   ============================================ */
.psc-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ============================================
   通知
   ============================================ */
.psc-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    animation: notificationSlideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
}

@keyframes notificationSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.psc-notification.success {
    background: #4CAF50;
}

.psc-notification.error {
    background: #f44336;
}

.psc-notification.warning {
    background: #ff9800;
}

.psc-notification.info {
    background: #2196F3;
}

.close-notification {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    margin-left: auto;
}

/* ============================================
   レスポンシブデザイン
   ============================================ */
@media (max-width: 768px) {
    .psc-container {
        padding: 10px;
    }
    
    .psc-progress-bar {
        flex-direction: column;
        align-items: center;
    }
    
    .psc-progress-bar::before {
        display: none;
    }
    
    .psc-progress-step {
        margin-bottom: 20px;
    }
    
    .psc-form-actions {
        flex-direction: column;
    }
    
    .psc-tabs {
        flex-wrap: wrap;
    }
    
    .psc-tab {
        flex: 1 0 50%;
    }
    
    .psc-patents-table {
        font-size: 14px;
    }
    
    .psc-patents-table th,
    .psc-patents-table td {
        padding: 8px;
    }
    
    .psc-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .psc-download-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .psc-patent-input {
        flex-direction: column;
    }
    
    .psc-results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .psc-results-actions {
        margin-top: 10px;
        width: 100%;
    }
    
    .psc-results-actions button {
        flex: 1;
        font-size: 14px;
    }
}

/* ============================================
   印刷用スタイル
   ============================================ */
@media print {
    .psc-progress-bar,
    .psc-form-actions,
    .psc-download-actions,
    .psc-tabs,
    .psc-modal,
    .psc-loading-overlay,
    .psc-notification {
        display: none !important;
    }
    
    .psc-document-viewer {
        max-height: none;
        border: none;
    }
    
    .psc-tab-pane {
        display: block !important;
        page-break-after: always;
    }
}
