/* ========================================
   Decision Assist DCRM カスタムスタイル
   Meta × Salesforce風 クリーンUI
   ======================================== */

/* ----- カラーパレット ----- */
:root {
    --primary: #1877f2;
    --primary-dark: #166fe5;
    --primary-light: #e7f3ff;
    --bg-gray: #f0f2f5;
    --card-bg: #ffffff;
    --text-dark: #050505;
    --text-secondary: #65676b;
    --border-color: #e4e6eb;
    --success: #42b72a;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* ラブ度カラー */
    --love-red: #dc2626;
    --like-blue: #60a5fa;
    --caution-yellow: #fbbf24;
    --ng-black: #1f2937;
}

/* ----- リセット & ベース ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    font-size: 15px;
    line-height: 1.6;
}

/* ----- レイアウト ----- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* サイドバー */
.sidebar {
    width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    padding-bottom: 80px; /* ユーザー情報のスペースを確保 */
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

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

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

.nav-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    padding: 8px 24px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 24px;
    color: var(--text-dark);
    text-decoration: none;
    transition: background 0.15s ease;
    font-size: 15px;
}

.nav-item:hover {
    background: var(--bg-gray);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    border-right: 3px solid var(--primary);
}

.nav-item i {
    width: 24px;
    margin-right: 12px;
    text-align: center;
}

/* サイドバーユーザー情報 */
.sidebar-user-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--card-bg);
}

.user-menu-sidebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.user-menu-sidebar:hover {
    background: var(--bg-gray);
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ユーザードロップダウンメニュー */
.user-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 200;
}

.user-dropdown-menu.hidden {
    display: none;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-dark);
    text-decoration: none;
    transition: background 0.15s;
    font-size: 14px;
}

.user-menu-item:hover {
    background: var(--bg-gray);
}

.user-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.user-menu-item.logout {
    color: var(--danger);
}

.user-menu-item.logout i {
    color: var(--danger);
}

.user-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}


/* メインコンテンツ */
.main-content {
    margin-left: 280px;
    flex: 1;
    min-height: 100vh;
}

/* ヘッダー */
.app-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
}

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

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s;
}

.user-menu:hover {
    background: var(--bg-gray);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* コンテンツエリア */
.content-area {
    padding: 32px;
    max-width: 1400px;
}

/* ----- カード ----- */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.08);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-dark);
}

.card-body {
    padding: 20px;
}

/* ----- ボタン ----- */
.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-gray);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: #e4e6eb;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 17px;
}

/* ----- タグ ----- */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    gap: 4px;
}

.tag-blue {
    background: #dbeafe;
    color: #1e40af;
}

.tag-green {
    background: #dcfce7;
    color: #166534;
}

.tag-yellow {
    background: #fef3c7;
    color: #92400e;
}

.tag-red {
    background: #fee2e2;
    color: #991b1b;
}

.tag-gray {
    background: #f3f4f6;
    color: #374151;
}

.tag-purple {
    background: #ede9fe;
    color: #6b21a8;
}

/* ----- ラブ度バッジ ----- */
.love-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
}

.love-badge.love {
    color: var(--love-red);
}

.love-badge.like {
    color: var(--like-blue);
}

.love-badge.caution {
    color: var(--caution-yellow);
}

.love-badge.ng {
    color: var(--ng-black);
}

/* ----- 予算ランクバッジ ----- */
.budget-rank {
    display: inline-block;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
}

.budget-rank.rank-s {
    color: #fbbf24;
}

.budget-rank.rank-a {
    color: #166534;
}

.budget-rank.rank-b {
    color: #059669;
}

.budget-rank.rank-c {
    color: #fbbf24;
}

.budget-rank.rank-d {
    color: #f97316;
}

.budget-rank.rank-e {
    color: #dc2626;
}

/* ----- テーブル ----- */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-gray);
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

tr:hover {
    background: var(--bg-gray);
}

/* ----- 担当者管理テーブル改善版 ----- */
.contacts-table-improved {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.contacts-table-improved thead {
    background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
    border-bottom: 2px solid #e5e7eb;
}

.contacts-table-improved th {
    padding: 12px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    text-align: left;
    vertical-align: middle;
    line-height: 1.3;
    border-right: 1px solid #e5e7eb;
}

.contacts-table-improved th:last-child {
    border-right: none;
}

.contacts-table-improved tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.15s ease;
}

.contacts-table-improved tbody tr:hover {
    background-color: #f0f9ff;
}

.contacts-table-improved td {
    padding: 8px;
    vertical-align: middle;
    border-right: 1px solid #f3f4f6;
}

.contacts-table-improved td:last-child {
    border-right: none;
}

/* ----- フォーム ----- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* ----- モーダル ----- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--card-bg);
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.2s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.modal-close:hover {
    background: var(--bg-gray);
}

.modal-body {
    padding: 24px;
}

/* ----- アニメーション ----- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

.animate-slide-in {
    animation: slideIn 0.3s ease;
}

/* ----- タブボタン ----- */
.tab-btn {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover {
    color: #1877f2;
    background: #f0f2f5;
}

.tab-btn.active {
    color: #1877f2;
    border-bottom-color: #1877f2;
    background: #e7f3ff;
}

/* ----- ユーティリティ ----- */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }
.p-4 { padding: 32px; }

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 16px;
}

.gap-3 {
    gap: 24px;
}

.hidden {
    display: none !important;
}

/* ----- グリッド ----- */
.grid {
    display: grid;
    gap: 16px;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ----- レスポンシブ ----- */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .content-area {
        padding: 16px;
    }
    
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* ----- テキスト省略 ----- */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
    
    .app-header {
        padding: 12px 16px;
    }
    
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    .card-body {
        padding: 16px;
    }
}

/* ----- 印刷用スタイル ----- */
@media print {
    .sidebar,
    .app-header,
    .btn,
    .user-menu {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}
