/* TechShare - 共通スタイル */

/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基本設定 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* カラーパレット */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #4fc3f7;
    --success-color: #76c475;
    --warning-color: #ffa726;
    --error-color: #f44336;
    --text-color: #333;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --background-color: #f8f9fa;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ヘッダー */
.header {
    background: var(--primary-gradient);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    text-decoration: none;
    color: white;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.nav-menu a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-menu {
    position: relative;
}

.user-menu-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s;
}

.user-menu-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    color: #333;
    min-width: 150px;
    box-shadow: var(--shadow);
    border-radius: 5px;
    overflow: hidden;
    display: none;
}

.user-menu-dropdown.show {
    display: block;
}

.user-menu-dropdown a {
    display: block;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    transition: background-color 0.3s;
}

.user-menu-dropdown a:hover {
    background-color: #f8f9fa;
}

/* メインコンテンツ */
.main-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* メインレイアウト（サイドバー付き） */
.main-layout {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

.content-area {
    min-width: 0; /* グリッドのオーバーフロー防止 */
}

/* サイドバー */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section {
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.sidebar-title {
    color: var(--text-color);
    padding: 12px 0;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 8px;
}

.ranking-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-item:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

.ranking-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    margin-right: 12px;
    flex-shrink: 0;
}

.ranking-content {
    flex: 1;
    min-width: 0;
}

.ranking-name {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-name a {
    color: inherit;
    text-decoration: none;
}

.ranking-name a:hover {
    color: var(--primary-color);
}

.ranking-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* 外部リンク */
.external-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.external-link {
    border-bottom: 1px solid var(--border-color);
}

.external-link:last-child {
    border-bottom: none;
}

.external-link a {
    display: flex;
    align-items: center;
    padding: 12px 0;
    text-decoration: none;
    color: var(--text-color);
    transition: background-color 0.2s;
}

.external-link a:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

.external-link-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.external-link-text {
    font-size: 14px;
    font-weight: 500;
}

/* サイドバー記事スタイル */
.sidebar-article {
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s;
}

.sidebar-article:last-child {
    border-bottom: none;
}

.sidebar-article:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

.sidebar-article-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.sidebar-article-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    margin: 0 0 6px 0;
    color: var(--text-color);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sidebar-article-link:hover .sidebar-article-title {
    color: var(--primary-color);
}

.sidebar-article-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

/* コンパクトな検索フィルター */
.search-filter-compact {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-filter-compact .form-group {
    margin-bottom: 0;
}

.search-filter-compact .d-flex {
    display: flex;
    align-items: center;
}

.search-filter-compact .gap-2 {
    gap: 0.5rem;
}

/* 記事グリッドレイアウト */
#articles-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-top: 0;
}

/* コンパクトな記事カード */
.article-card-compact {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    height: fit-content;
}

.article-card-compact:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.article-card-compact-body {
    padding: 16px;
}

.article-title-compact {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 8px 0;
    color: var(--text-color);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.article-meta-compact {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
}

.article-excerpt-compact {
    font-size: 14px;
    line-height: 1.5;
    color: #666;
    margin-bottom: 12px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    min-height: 4.5em; /* 3行分の高さを確保 */
}

.article-tags-compact {
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px; /* タグエリアの最小高さを確保 */
}

.tag-compact {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.tag-compact:hover {
    background: var(--primary-color);
    color: white;
}

.article-stats-compact {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

/* ローディングとエラー表示 */
#articles-container .loading,
#articles-container .alert {
    grid-column: 1 / -1; /* グリッド全体にわたって表示 */
    text-align: center;
    padding: 2rem;
}

/* レスポンシブ対応：記事グリッド */
@media (max-width: 1024px) {
    #articles-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 640px) {
    #articles-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .search-filter-compact {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .search-filter-compact .d-flex {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .search-filter-compact .gap-2 {
        gap: 0.5rem;
    }
    
    .search-filter-compact select {
        flex: 1;
        min-width: 120px;
    }
    
    .search-filter-compact button {
        white-space: nowrap;
    }
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

/* カード */
.card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #f8f9fa;
}

/* フォーム */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control.error {
    border-color: var(--error-color);
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
}

/* ボタン */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* 記事カード */
.article-card {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: transform 0.3s, box-shadow 0.3s;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.article-card-body {
    padding: 1.5rem;
}

.article-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
}

.article-title:hover {
    color: var(--primary-color);
}

.article-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.article-excerpt {
    color: var(--text-color);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    background: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background-color 0.3s;
}

.tag:hover {
    background: var(--primary-color);
    color: white;
}

.article-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* アラート */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-left-color: var(--success-color);
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border-left-color: var(--error-color);
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left-color: var(--warning-color);
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left-color: var(--secondary-color);
}

/* ローディング */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ページネーション */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0;
}

.pagination a,
.pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s;
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination .current {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* フッター */
.footer {
    background: #343a40;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.footer-links a {
    color: #adb5bd;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: white;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .header {
        padding: 0.5rem 0; /* ヘッダーの高さを半分に */
    }
    
    .header-container {
        flex-direction: row; /* 横並びを維持 */
        gap: 0.5rem;
        padding: 0 0.5rem;
    }
    
    .logo {
        font-size: 1.2rem; /* ロゴサイズを小さく */
    }
    
    .nav-menu {
        flex-direction: row; /* 横並びを維持 */
        gap: 0.5rem;
        font-size: 0.9rem; /* フォントサイズを小さく */
    }
    
    .nav-menu a {
        padding: 0.3rem 0.6rem; /* パディングを小さく */
    }
    
    .user-menu-button {
        padding: 0.3rem 0.6rem; /* パディングを小さく */
        font-size: 0.9rem;
    }
    
    .container {
        padding: 1rem;
    }
    
    .main-container {
        margin: 1rem auto;
        padding: 0 0.5rem;
    }
    
    .article-card-body {
        padding: 1rem;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ユーティリティクラス */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-error { color: var(--error-color); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.d-block { display: block; }
.d-none { display: none; }

.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* ハイライト表示 */
.highlight {
    background-color: #fff3cd;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
}

/* アニメーション */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

/* エディター */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    height: 500px;
}

.editor-textarea {
    resize: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
}

.editor-preview {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1rem;
    overflow-y: auto;
    background: white;
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
        margin: 1rem auto;
    }
    
    .sidebar {
        order: 1; /* サイドバーを下に表示 */
        background: #f8f9fa;
        border-radius: 8px;
        padding: 1rem;
        margin-top: 1rem;
    }
    
    .sidebar-section {
        margin-bottom: 1.5rem;
    }
    
    .sidebar-title {
        font-size: 14px;
        padding: 8px 0;
        margin-bottom: 12px;
    }
    
    .ranking-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .ranking-item {
        padding: 8px;
        background: white;
        border-radius: 6px;
        text-align: center;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .ranking-number {
        width: 18px;
        height: 18px;
        font-size: 10px;
        margin: 0 auto 4px auto;
    }
    
    .ranking-name {
        font-size: 12px;
        margin-bottom: 2px;
    }
    
    .ranking-meta {
        font-size: 10px;
    }
    
    .external-links {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .external-link {
        border: none;
    }
    
    .external-link a {
        padding: 8px;
        background: white;
        border-radius: 6px;
        text-align: center;
        flex-direction: column;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .external-link-icon {
        width: 20px;
        height: 20px;
        margin: 0 auto 4px auto;
    }
    
    .external-link-text {
        font-size: 11px;
    }
    
    .sidebar-article {
        padding: 8px;
        background: white;
        border-radius: 6px;
        margin-bottom: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .sidebar-article-title {
        font-size: 12px;
    }
    
    .sidebar-article-meta {
        font-size: 10px;
    }
    
    .editor-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .editor-textarea {
        height: 300px;
    }
    
    .editor-preview {
        height: 300px;
    }
}

/* 記事コンテンツ表示用スタイル */
.article-content {
    line-height: 1.8;
    font-size: 16px;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.article-content img:hover {
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    margin: 30px 0 15px 0;
    line-height: 1.4;
}

.article-content h1 {
    font-size: 2em;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.article-content h2 {
    font-size: 1.6em;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 8px;
}

.article-content h3 {
    font-size: 1.3em;
}

.article-content p {
    margin: 16px 0;
}

.article-content ul,
.article-content ol {
    margin: 16px 0;
    padding-left: 30px;
}

.article-content li {
    margin: 8px 0;
}

.article-content code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.article-content pre {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 20px 0;
}

.article-content pre code {
    background: none;
    padding: 0;
}

.article-content blockquote {
    border-left: 4px solid var(--primary-color);
    margin: 20px 0;
    padding: 10px 20px;
    background: #f8f9fa;
    font-style: italic;
}

.article-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.article-content a:hover {
    text-decoration: underline;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.article-content th,
.article-content td {
    border: 1px solid #e9ecef;
    padding: 12px;
    text-align: left;
}

.article-content th {
    background: #f8f9fa;
    font-weight: 600;
}
