/* リセット&基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* アプリケーションコンテナ */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
}

.logo i {
    font-size: 24px;
}

.header-nav {
    display: flex;
    gap: 30px;
}

.nav-item {
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background-color 0.2s;
    position: relative;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.2);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info {
    font-size: 14px;
}

.settings-btn,
.help-btn {
    background: none;
    border: none;
    color: white;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.settings-btn:hover,
.help-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* メインコンテナ */
.main-container {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 60px);
}

/* サイドバー */
.sidebar {
    width: 250px;
    background: #2c3e50;
    color: white;
    overflow-y: auto;
}

.sidebar-nav {
    padding: 20px 0;
}

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

.nav-header {
    padding: 0 20px 10px;
    font-size: 12px;
    text-transform: uppercase;
    color: #95a5a6;
    font-weight: 600;
    letter-spacing: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background-color: #34495e;
    border-left-color: #3498db;
}

.nav-link.active {
    background-color: #34495e;
    border-left-color: #e74c3c;
    color: #fff;
}

.nav-link i {
    width: 16px;
    text-align: center;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    padding: 30px;
    background: #fff;
    overflow-y: auto;
}

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

.content-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.content-header h1 {
    font-size: 28px;
    color: #2c3e50;
    font-weight: 300;
    margin: 0;
}

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

/* フォームコンテナ */
.form-container {
    max-width: 800px;
}

.form-section {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.section-header h2 {
    font-size: 20px;
    color: #2c3e50;
    font-weight: 500;
}

.required {
    background: #e74c3c;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: #495057;
    font-size: 14px;
}

.form-control {
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    min-height: 50px;
    transition: all 0.2s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-control[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
}

.input-group {
    display: flex;
    align-items: center;
    position: relative;
}

.input-suffix {
    position: absolute;
    right: 16px;
    color: #6c757d;
    font-size: 14px;
    pointer-events: none;
}

.input-group .form-control {
    padding-right: 50px;
}

.contract-type-toggle {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.contract-type-toggle input[type="radio"] {
    margin-right: 8px;
}

.contract-type-toggle label {
    cursor: pointer;
    font-weight: 500;
}

/* ボタン */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

/* フォームアクション */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding-top: 30px;
    border-top: 1px solid #eee;
    margin-top: 30px;
}

/* プレビューパネル */
.preview-panel {
    width: 400px;
    background: #fff;
    border-left: 2px solid #eee;
    display: none;
    flex-direction: column;
}

.preview-panel.active {
    display: flex;
}

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

.preview-header h3 {
    font-size: 18px;
    color: #2c3e50;
}

.close-preview {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6c757d;
}

.preview-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.contract-document {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.document-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #2c3e50;
}

.document-header h2 {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 15px;
}

.contract-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
}

.document-body {
    line-height: 1.8;
}

.document-body p {
    margin-bottom: 10px;
    font-size: 14px;
}

.contract-terms {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.contract-terms h4 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.preview-actions {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #f8f9fa;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .preview-panel {
        width: 100%;
        border-left: none;
        border-top: 2px solid #eee;
    }
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .content-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

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

    .header-nav {
        display: none;
    }

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

/* アニメーション */
.form-section {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ツールチップ */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* スクロールバーカスタム */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ========== 新しいページ用スタイル ========== */

/* 検索コンテナ */
.search-container {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.search-form .search-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 20px;
    align-items: end;
}

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

.search-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: #495057;
    font-size: 14px;
}

/* リストコンテナ */
.list-container {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.list-header {
    background: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.list-stats {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #495057;
}

.stat-item i {
    font-size: 16px;
}

/* テーブル */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    background: #f8f9fa;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

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

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

/* ステータスバッジ */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-draft {
    background: #fff3cd;
    color: #856404;
}

.status-terminated {
    background: #f8d7da;
    color: #721c24;
}

.status-pending {
    background: #cce5ff;
    color: #004085;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

/* アクションボタン */
.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-action {
    background: none;
    border: 1px solid #dee2e6;
    color: #6c757d;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover:not(:disabled) {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

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

/* ページネーション */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.pagination-btn {
    background: #fff;
    border: 1px solid #dee2e6;
    color: #6c757d;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(:disabled) {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

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

.pagination-info {
    font-size: 14px;
    color: #6c757d;
}

/* テンプレートグリッド */
.template-container {
    margin-top: 20px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

.template-card {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s;
    cursor: pointer;
}

.template-card:hover {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px 10px;
}

.template-status {
    flex: 1;
}

.template-actions {
    display: flex;
    gap: 8px;
}

.template-content {
    padding: 0 20px 15px;
}

.template-icon {
    text-align: center;
    margin-bottom: 15px;
}

.template-icon i {
    font-size: 48px;
    color: #007bff;
}

.template-card h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #2c3e50;
}

.template-description {
    color: #6c757d;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 15px;
}

.template-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}

.template-footer {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

/* モーダル */
.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;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6c757d;
    padding: 5px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

/* 統計カード */
.stats-container {
    margin-bottom: 25px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-icon i {
    font-size: 32px;
}

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1;
}

.stat-label {
    font-size: 14px;
    color: #6c757d;
    margin-top: 5px;
}

.contract-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

/* レスポンシブ対応の追加 */
@media (max-width: 768px) {
    .search-form .search-row {
        grid-template-columns: 1fr;
    }

    .list-stats {
        flex-direction: column;
        gap: 15px;
    }

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

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

    .table {
        font-size: 12px;
    }

    .table th,
    .table td {
        padding: 10px 8px;
    }
}

/* ========== テンプレート編集ページ用スタイル ========== */

/* コンテンツヘッダーの左側レイアウト */
.content-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.content-header-left h1 {
    margin: 0;
}

/* テンプレート選択タブ */
.template-selector {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    margin-bottom: 25px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.selector-tabs {
    display: flex;
}

.tab-btn {
    flex: 1;
    background: #f8f9fa;
    border: none;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    font-weight: 500;
    color: #6c757d;
    border-right: 1px solid #e9ecef;
}

.tab-btn:last-child {
    border-right: none;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.tab-btn.active {
    background: #007bff;
    color: white;
}

.tab-btn i {
    font-size: 20px;
}

/* テンプレート編集コンテナ */
.template-edit-container {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    max-width: 100%;
    overflow: hidden;
}

/* テンプレート項目 */
.template-item {
    border-bottom: 1px solid #e9ecef;
    transition: all 0.2s;
}

.template-item:last-child {
    border-bottom: none;
}

.template-item.disabled {
    opacity: 0.6;
    background: #f8f9fa;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 25px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    gap: 15px;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-info h3 {
    margin: 0;
    font-size: 16px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    word-break: break-word;
}

.editable-mark {
    background: #28a745;
    color: white;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 50%;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.item-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
    margin-top: 5px;
    display: inline-block;
}

.item-status.fixed {
    background: #6c757d;
    color: white;
}

.item-status.editable {
    background: #28a745;
    color: white;
}

.item-controls {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* トグルスイッチ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-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: #007bff;
}

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

/* 項目コンテンツ */
.item-content {
    padding: 20px 25px;
}

.item-content textarea {
    resize: vertical;
    min-height: 120px;
    width: 100%;
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
}

.item-content textarea[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

/* 情報テキスト */
.info-text {
    color: #6c757d;
    font-size: 14px;
    font-style: italic;
}

/* 中程度の画面サイズ対応 */
@media (max-width: 1024px) {
    .item-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .item-info h3 {
        font-size: 15px;
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .content-header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .selector-tabs {
        flex-direction: column;
    }

    .tab-btn {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }

    .tab-btn:last-child {
        border-bottom: none;
    }

    .item-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px 20px 10px;
    }

    .item-info {
        width: 100%;
    }

    .item-info h3 {
        font-size: 14px;
        line-height: 1.4;
    }

    .item-controls {
        align-self: flex-end;
        width: auto;
    }

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