/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: #f0f4f8;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* サイドバー */
.sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 20px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    background: #1e90ff;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.2);
}

.sidebar-content {
    padding: 30px 20px;
}

.api-section {
    margin-bottom: 30px;
}

.api-section h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 600;
}

.api-section h4 i {
    margin-right: 8px;
    color: #1e90ff;
}

.api-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 20px;
}

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

.api-key-input {
    position: relative;
    display: flex;
}

.api-key-input input {
    flex: 1;
    padding: 12px 40px 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.api-key-input input:focus {
    outline: none;
    border-color: #1e90ff;
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.toggle-visibility {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: color 0.3s ease;
}

.toggle-visibility:hover {
    color: #1e90ff;
}

.api-links {
    margin-bottom: 20px;
}

.api-link {
    display: inline-flex;
    align-items: center;
    color: #1e90ff;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 12px;
    border: 1px solid #1e90ff;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.api-link:hover {
    background: #1e90ff;
    color: white;
}

.api-link i {
    margin-right: 6px;
}

.api-toggle {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    margin-right: 12px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #1e90ff;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.toggle-label {
    font-size: 0.9rem;
    color: #333;
}

.api-status {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: #666;
}

.api-status i {
    margin-right: 8px;
}

.status-active {
    color: #28a745;
}

.status-inactive {
    color: #dc3545;
}

.help-section h4 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

.help-list {
    list-style: none;
    padding: 0;
}

.help-list li {
    padding: 6px 0;
    font-size: 0.85rem;
    color: #666;
    border-bottom: 1px solid #f0f0f0;
}

.help-list li:before {
    content: "💡";
    margin-right: 8px;
}

/* サイドバーオーバーレイ */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* メインコンテンツ */
.main-content {
    position: relative;
    transition: transform 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* サイドバートグルボタン */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #1e90ff;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

/* ヘッダー */
.header {
    text-align: center;
    margin-bottom: 40px;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #1e90ff;
}

.header .subtitle {
    font-size: 1.1rem;
    color: #666;
    font-weight: 400;
    margin-bottom: 20px;
}

.header .author {
    font-size: 0.9rem;
    color: #999;
    font-weight: 300;
}

.header .description {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-left: 4px solid #1e90ff;
    border-radius: 8px;
    text-align: left;
}

.header .description h3 {
    font-size: 1rem;
    color: #333;
    margin-bottom: 10px;
    font-weight: 600;
}

.header .description p {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

/* タブコンテナ */
.tab-container {
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tabs {
    display: flex;
    background: #f8f9fa;
}

.tab-button {
    flex: 1;
    padding: 18px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:hover {
    background: #e9ecef;
    color: #333;
}

.tab-button.active {
    background: white;
    color: #1e90ff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #1e90ff;
}

.tab-button i {
    margin-right: 8px;
}

/* タブコンテンツ */
.tab-content {
    display: none;
    padding: 40px;
    background: white;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.tab-content.active {
    display: block;
}

.tab-content h2 {
    margin-bottom: 25px;
    color: #333;
    font-weight: 600;
    font-size: 1.4rem;
}

.tab-content h2 i {
    margin-right: 10px;
    color: #1e90ff;
}

/* 論文入力セクション */
.paper-input-section {
    /* 基本スタイルは既存の.url-sectionを継承 */
}

.input-method-tabs {
    display: flex;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 25px;
    gap: 4px;
    flex-wrap: wrap;
}

.method-tab {
    flex: 1;
    min-width: 120px;
    padding: 12px 15px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-align: center;
}

.method-tab:hover {
    background: #e9ecef;
    color: #333;
}

.method-tab.active {
    background: white;
    color: #1e90ff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.method-tab i {
    margin-right: 6px;
}

.input-method-content {
    display: none;
}

.input-method-content.active {
    display: block;
}

.input-help {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

/* DOI入力の特別スタイル */
#doi-text, #url-doi-text {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* フォーム要素 */
.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.input-group input,
.input-group select {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #1e90ff;
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.input-group select {
    min-width: 140px;
    cursor: pointer;
}

/* ボタン */
.btn-primary,
.btn-secondary {
    padding: 15px 25px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 48px;
}

.btn-primary {
    background: #1e90ff;
    color: white;
}

.btn-primary:hover {
    background: #1874d9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 144, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(30, 144, 255, 0.3);
}

.btn-primary:focus {
    outline: 3px solid rgba(30, 144, 255, 0.3);
    outline-offset: 2px;
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn-secondary:focus {
    outline: 3px solid rgba(30, 144, 255, 0.3);
    outline-offset: 2px;
}

.btn-primary i,
.btn-secondary i {
    margin-right: 8px;
}

/* 検索結果 */
.search-results {
    margin-top: 20px;
}

.search-item {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-item:hover {
    border-color: #1e90ff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.search-item.selected {
    border-color: #1e90ff;
    background: rgba(30, 144, 255, 0.1);
}

.search-item h3 {
    color: #333;
    margin-bottom: 8px;
    font-weight: 600;
}

.search-item p {
    color: #666;
    margin-bottom: 5px;
}

.search-item .isbn {
    font-family: monospace;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* 結果セクション */
.result-section {
    margin-top: 40px;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.result-section h2 {
    margin-bottom: 25px;
    color: #333;
    font-weight: 600;
    font-size: 1.4rem;
}

.result-section h2 i {
    margin-right: 10px;
    color: #28a745;
}

.result-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.citation-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.citation-result {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap;
    word-break: break-all;
}

/* エラーセクション */
.error-section {
    margin-top: 20px;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.error-message {
    display: flex;
    align-items: center;
    color: #dc3545;
    font-weight: 500;
    font-size: 1.1rem;
}

.error-message i {
    margin-right: 12px;
    font-size: 1.3rem;
}

/* ローディング */
.loading {
    text-align: center;
    padding: 20px;
    color: #1e90ff;
    font-weight: 500;
}

.loading i {
    margin-right: 10px;
    font-size: 1.2rem;
}

/* 手動入力フォーム */
.manual-form {
    margin-top: 30px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 30px;
    animation: slideDown 0.3s ease;
}

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

.manual-input-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.3rem;
}

.manual-input-section h3 i {
    margin-right: 10px;
    color: #1e90ff;
}

.help-text {
    color: #666;
    margin-bottom: 25px;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* URL表示 */
.url-display {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
}

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

.url-box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px;
    font-family: monospace;
    font-size: 0.9rem;
    color: #666;
    word-break: break-all;
}

/* フォームグリッド */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

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

.form-group input {
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #1e90ff;
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.field-help {
    margin-top: 5px;
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
}

.required {
    color: #dc3545;
}

/* 入力のコツ */
.input-tips {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.input-tips h4 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

.input-tips h4 i {
    margin-right: 8px;
    color: #ffc107;
}

.input-tips ul {
    list-style: none;
    padding: 0;
}

.input-tips li {
    padding: 4px 0;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.input-tips li:before {
    content: "•";
    color: #1e90ff;
    margin-right: 8px;
}

/* フォームアクション */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* AI補助バッジ */
.ai-assist-badge {
    background: #1e90ff;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: 10px;
    font-weight: 500;
}

.ai-assist-badge i {
    margin-right: 4px;
}

/* 編集ボタンのスタイル */
.btn-edit {
    background: #ffc107;
    color: #333;
    border: 2px solid #ffc107;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 48px;
}

.btn-edit:hover {
    background: #e0a800;
    border-color: #e0a800;
    transform: translateY(-2px);
}

.btn-edit:active {
    transform: translateY(0);
}

.btn-edit:focus {
    outline: 3px solid rgba(255, 193, 7, 0.3);
    outline-offset: 2px;
}

.btn-edit i {
    margin-right: 8px;
}

/* 編集セクション */
.edit-section {
    margin-top: 40px;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* 自動抽出後の編集フォーム */
.edit-form-section {
    margin-top: 30px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.edit-form-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
    font-size: 1.2rem;
}

.edit-form-section h3 i {
    margin-right: 8px;
    color: #ffc107;
}

.edit-section h2 {
    margin-bottom: 25px;
    color: #333;
    font-weight: 600;
    font-size: 1.4rem;
}

.edit-section h2 i {
    margin-right: 10px;
    color: #ffc107;
}

.edit-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.citation-edit {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    line-height: 1.8;
    color: #333;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.3s ease;
}

.citation-edit:focus {
    outline: none;
    border-color: #1e90ff;
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

.edit-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* コピーボタンの成功状態 */
.copied {
    background: #28a745 !important;
    color: white !important;
}

/* 引用形式ルール */
.protocol-section {
    background: #fff;
    border-radius: 20px;
    margin-top: 25px; /* Added this line */
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.protocol-section summary {
    padding: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
}

.protocol-section summary:hover {
    background: #f8f9fa;
}

.protocol-section summary i {
    margin-right: 12px;
    color: #1e90ff;
}

.protocol-section[open] summary {
    border-bottom: 1px solid #e9ecef;
}

.protocol-content {
    padding: 20px 30px 30px 30px;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.7;
}

.protocol-content p {
    margin-bottom: 15px;
}

.protocol-content p:last-child {
    margin-bottom: 0;
}

.protocol-content strong {
    font-weight: 600;
    color: #333;
    display: inline-block;
    margin-bottom: 5px;
}

/* 隠す用のクラス */
.hidden {
    display: none !important;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 30px 20px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .header .description {
        margin-top: 20px;
        padding: 15px;
    }

    .tab-content {
        padding: 25px 20px;
    }

    .input-group {
        flex-direction: column;
    }

    .input-group input,
    .input-group select {
        margin-bottom: 10px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions button {
        flex: 1;
        min-width: 100%;
    }

    .sidebar {
        width: 100%;
        right: -100%;
    }

    .input-method-tabs {
        flex-direction: column;
    }

    .method-tab {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 20px 15px;
    }

    .header h1 {
        font-size: 1.6rem;
    }

    .header .subtitle {
        font-size: 1rem;
    }

    .header .description h3 {
        font-size: 0.95rem;
    }

    .header .description p {
        font-size: 0.85rem;
    }

    .tab-content {
        padding: 20px 15px;
    }

    .result-section,
    .edit-section {
        padding: 25px 20px;
    }

    .citation-result,
    .citation-edit {
        font-size: 0.9rem;
        padding: 15px;
    }

    .citation-actions,
    .edit-actions {
        justify-content: stretch;
    }

    .citation-actions button,
    .edit-actions button {
        flex: 1;
        min-width: 100%;
    }
}
