/* ========================================
   統一ダークモードシステム
   MGFactory Corporate Website
   Created: 2025-09-24
======================================== */

/* === ライトモード変数定義 (デフォルト) === */
:root {
    /* === ライトモード背景色 === */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-accent: #f1f5f9;
    
    /* === ライトモードテキスト色 === */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-white: #ffffff;
    --text-muted: #64748b;
    
    /* === ライトモード境界線・装飾色 === */
    --neutral-gray-200: #e2e8f0;
    --neutral-gray-300: #cbd5e1;
    
    /* === ブランドカラー === */
    --primary-blue: #3b82f6;
    --primary-blue-light: #60a5fa;
    --primary-blue-dark: #2563eb;
    
    --secondary-teal: #14b8a6;
    --secondary-teal-light: #2dd4bf;
    
    /* === 状態カラー === */
    --success-green: #10b981;
    --warning-orange: #f59e0b;
    --error-red: #ef4444;
    
    /* === シャドウ効果 === */
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 15px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* === ダークモード変数定義 === */
[data-theme="dark"] {
    color-scheme: dark;
    
    /* === ダークモード背景色（濃い背景） === */
    --bg-primary: #0f172a !important;      /* 濃紺（メイン背景）*/
    --bg-secondary: #1e293b !important;    /* スレート（セカンド背景）*/
    --bg-accent: #334155 !important;       /* アクセント背景 */
    
    /* === ダークモードテキスト色（白系） === */
    --text-primary: #ffffff !important;    /* 純白（メインテキスト）*/
    --text-secondary: #e2e8f0 !important;  /* ライトグレー（サブテキスト）*/
    --text-white: #ffffff !important;      /* 白テキスト */
    --text-muted: #94a3b8 !important;      /* ミュートグレー */
    
    /* === ダークモード境界線・装飾色 === */
    --neutral-gray-200: #475569 !important; /* 境界線色 */
    --neutral-gray-300: #64748b !important; /* 濃い境界線 */
    
    /* === ブランドカラー（ダークモードで調整） === */
    --primary-blue: #3b82f6 !important;      /* 明るい企業ブルー */
    --primary-blue-light: #60a5fa !important; /* より明るいブルー */
    --primary-blue-dark: #2563eb !important;  /* 中間ブルー */
    
    --secondary-teal: #14b8a6 !important;     /* 明るいティール */
    --secondary-teal-light: #2dd4bf !important; /* より明るいティール */
    
    /* === 状態カラー（ダークモード対応） === */
    --success-green: #10b981 !important;
    --warning-orange: #f59e0b !important;
    --error-red: #ef4444 !important;
    
    /* === シャドウ効果（ダーク用） === */
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.6);
    --shadow-medium: 0 4px 15px rgba(0, 0, 0, 0.7);
    --shadow-heavy: 0 8px 25px rgba(0, 0, 0, 0.8);
}

/* === ダークモード統一パネルシステム === */
[data-theme="dark"] .panel-in-white-section {
    background: var(--bg-secondary) !important;  /* 濃いグレー */
    color: var(--text-primary) !important;       /* 白テキスト */
    border-color: var(--neutral-gray-200) !important;
}

[data-theme="dark"] .panel-in-gray-section {
    background: var(--bg-primary) !important;    /* 最も濃い背景 */
    color: var(--text-primary) !important;       /* 白テキスト */
    border-color: var(--neutral-gray-200) !important;
}

[data-theme="dark"] .sub-panel-in-gray-section {
    background: var(--bg-secondary) !important;  /* 濃いグレー */
    color: var(--text-secondary) !important;     /* ライトグレーテキスト */
    border-color: var(--neutral-gray-200) !important;
}

[data-theme="dark"] .sub-panel-in-white-section {
    background: var(--bg-primary) !important;    /* 最も濃い背景 */
    color: var(--text-secondary) !important;     /* ライトグレーテキスト */
    border-color: var(--neutral-gray-200) !important;
}

/* === ダークモードセクション背景 === */
[data-theme="dark"] .about-section,
[data-theme="dark"] .qolms-platform-section,
[data-theme="dark"] .integration-systems-section,
[data-theme="dark"] .future-vision-section,
[data-theme="dark"] .contact-section {
    background: var(--bg-primary) !important;    /* 濃い背景 */
}

[data-theme="dark"] .business-section,
[data-theme="dark"] .achievements-section,
[data-theme="dark"] .support-messages-section,
[data-theme="dark"] .company-section {
    background: var(--bg-secondary) !important;  /* より濃い背景 */
}

/* === ダークモードテキスト色統一 === */
[data-theme="dark"] h1, 
[data-theme="dark"] h2, 
[data-theme="dark"] h3, 
[data-theme="dark"] h4, 
[data-theme="dark"] h5, 
[data-theme="dark"] h6 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] p {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .section-title {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .section-subtitle {
    color: var(--secondary-teal) !important;
}

/* === ダークモード - ボタン === */
[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-light) 100%) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .btn-secondary {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--primary-blue-light) !important;
    border-color: var(--primary-blue) !important;
}

[data-theme="dark"] .btn-secondary:hover {
    background: var(--primary-blue) !important;
    color: var(--text-primary) !important;
}

/* === ダークモード - ナビゲーションヘッダー === */
[data-theme="dark"] .navbar {
    background: rgba(15, 23, 42, 0.9) !important; /* 濃いダーク背景 */
    backdrop-filter: blur(15px) !important;
    border-bottom: 1px solid var(--neutral-gray-300) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .nav-container {
    background: transparent !important;
}

[data-theme="dark"] .logo-text,
[data-theme="dark"] .logo-text:visited {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .logo-text:hover,
[data-theme="dark"] .logo-text:focus {
    color: var(--primary-blue-light) !important;
}

[data-theme="dark"] .nav-link,
[data-theme="dark"] .nav-link:visited {
    color: var(--text-secondary) !important;
    border-bottom-color: transparent !important;
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link:focus,
[data-theme="dark"] .nav-link:active {
    color: var(--primary-blue-light) !important;
    border-bottom-color: var(--primary-blue-light) !important;
}

[data-theme="dark"] .hamburger .bar {
    background-color: var(--text-primary) !important;
}

[data-theme="dark"] .hamburger:hover .bar,
[data-theme="dark"] .hamburger.active .bar {
    background-color: var(--primary-blue-light) !important;
}

/* モバイルメニューのダークモード */
[data-theme="dark"] .nav-menu {
    background: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: blur(15px) !important;
}

[data-theme="dark"] .nav-menu.active {
    background: rgba(15, 23, 42, 0.95) !important;
}

/* === ダークモード切り替えトグル === */
.theme-toggle {
    position: fixed !important;
    top: 80px !important; /* PC・モバイル共にヘッダー高さを回避 */
    right: 20px !important;
    z-index: 9999 !important;
    background: #f8fafc !important;
    border: 2px solid #3b82f6 !important;
    border-radius: 50px !important;
    padding: 8px 16px !important;
    color: #1e293b !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    display: block !important;
    width: auto !important;
    height: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

/* ダークモード時のトグルボタン */
[data-theme="dark"] .theme-toggle {
    background: var(--bg-secondary);
    border-color: var(--primary-blue);
    color: var(--text-primary);
}

/* === モバイル対応 === */
@media (max-width: 768px) {
    .theme-toggle {
        right: 15px !important; /* モバイル時は右マージンを小さく */
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    /* モバイルメニューが開いている時は透明にして非操作に */
    body.nav-open .theme-toggle {
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.3s ease !important;
    }
}

.theme-toggle:hover {
    background: #3b82f6; /* ライトモード用固定ホバー色 */
    color: #ffffff; /* 固定白色 */
    transform: scale(1.05);
}

/* ダークモード時のホバー効果 */
[data-theme="dark"] .theme-toggle:hover {
    background: var(--primary-blue);
    color: var(--text-white);
    transform: scale(1.05);
}

.theme-toggle i {
    margin-right: 6px;
}