/* EA Cockpit PWA - Common CSS (Cyber HUD Elite for Mobile) */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: #0a0a0f;
    color: #e8e8ec;
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

body {
    padding-bottom: 70px;  /* bottom nav 用 */
}

/* ===== ヘッダー ===== */
.portal-header {
    background: linear-gradient(180deg, #1a1a25 0%, #0a0a0f 100%);
    border-bottom: 2px solid #d4af37;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.portal-header h1 {
    color: #d4af37;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.portal-header h1 img {
    width: 28px;
    height: 28px;
}
.portal-header .user-name {
    color: #b4bac8;
    font-size: 12px;
}

/* ===== メイン ===== */
.portal-main {
    padding: 16px;
    max-width: 720px;
    margin: 0 auto;
}

.portal-main h2 {
    color: #d4af37;
    font-size: 18px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2a2a3a;
}

.portal-main h3 {
    color: #d4d8e2;
    font-size: 14px;
    margin: 14px 0 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== カード ===== */
.card {
    background: #14141d;
    border: 1px solid #2a2a3a;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.card-metric {
    background: linear-gradient(180deg, #1a1a25 0%, #14141d 100%);
    border: 1px solid #2a2a3a;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}
.card-metric .label {
    color: #b4bac8;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.card-metric .value {
    color: #d4af37;
    font-size: 24px;
    font-weight: 700;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.card-metric .sub {
    color: #b4bac8;
    font-size: 11px;
    margin-top: 4px;
}

.card-metric.profit-up .value { color: #6ee7a3; }
.card-metric.profit-down .value { color: #e76e6e; }

/* ===== EA一覧 (リスト形式) ===== */
.ea-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ea-item {
    background: #14141d;
    border: 1px solid #2a2a3a;
    border-radius: 8px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ea-item .ea-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ea-item .ea-name {
    color: #d4af37;
    font-weight: 600;
    font-size: 14px;
}
.ea-item .ea-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #c6ccd8;
}
.ea-item .ea-stat {
    display: flex;
    flex-direction: column;
}
.ea-item .ea-stat-label {
    color: #9aa2b4;
    font-size: 10px;
    text-transform: uppercase;
}
.ea-item .ea-stat-value {
    color: #e8e8ec;
    font-variant-numeric: tabular-nums;
}

/* ===== Badge ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-online   { background: #1b4d2b; color: #6ee7a3; }
.badge-offline  { background: #4d3a1b; color: #e7c46e; }
.badge-paused   { background: #4d1b3a; color: #e76ec4; }
.badge-error    { background: #4d1b1b; color: #e76e6e; }

/* ===== ボタン ===== */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;  /* タップ領域 */
    text-align: center;
}
.btn-primary {
    background: #d4af37;
    color: #0a0a0f;
}
.btn-primary:hover, .btn-primary:active {
    background: #e7c558;
}
.btn-secondary {
    background: #2a2a3a;
    color: #e8e8ec;
    border-color: #444;
}
.btn-secondary:hover { background: #3a3a4a; }
.btn-block { width: 100%; }
.btn-large { padding: 14px 24px; font-size: 15px; }

/* ===== フォーム ===== */
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    color: #c6ccd8;
    font-size: 12px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
input[type=text], input[type=password], input[type=number], select, textarea {
    width: 100%;
    background: #0a0a0f;
    border: 1px solid #2a2a3a;
    color: #e8e8ec;
    padding: 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    min-height: 44px;  /* タップ領域 */
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #d4af37;
}

/* ===== ボトムナビゲーション ===== */
.bottom-nav {
    position: fixed;
    transform: translateZ(0);
    will-change: transform;
    bottom: 0;
    left: 0;
    right: 0;
    background: #14141d;
    border-top: 1px solid #2a2a3a;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 100;
}
.bottom-nav a {
    flex: 1;
    text-align: center;
    color: #b4bac8;
    text-decoration: none;
    font-size: 11px;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.bottom-nav a.active {
    color: #d4af37;
}
.bottom-nav .icon {
    font-size: 22px;
    line-height: 1;
}

/* ===== Flash ===== */
.flash {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13px;
}
.flash-info    { background: #1b3a4d; color: #6ec4e7; border: 1px solid #2c5570; }
.flash-success { background: #1b4d2b; color: #6ee7a3; border: 1px solid #2c7044; }
.flash-error   { background: #4d1b1b; color: #e76e6e; border: 1px solid #702c2c; }

/* ===== ログイン画面専用 ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.login-logo {
    margin-bottom: 30px;
    text-align: center;
}
.login-logo img {
    width: 120px;
    height: 120px;
    margin-bottom: 16px;
}
.login-logo h1 {
    color: #d4af37;
    font-size: 28px;
    letter-spacing: 2px;
}
.login-card {
    background: #14141d;
    border: 1px solid #2a2a3a;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
}
.login-help {
    color: #9aa2b4;
    font-size: 11px;
    text-align: center;
    margin-top: 16px;
}

/* ===== ユーティリティ ===== */
.mono { font-family: 'Consolas', 'Menlo', monospace; font-size: 12px; }
.muted { color: #b4bac8; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-up { color: #6ee7a3; }
.text-down { color: #e76e6e; }
.mt-2 { margin-top: 14px; }
.mb-2 { margin-bottom: 14px; }
.hidden { display: none; }

/* スマホ最適化: 横向き時 */
@media (orientation: landscape) and (max-height: 500px) {
    .login-logo { margin-bottom: 14px; }
    .login-logo img { width: 80px; height: 80px; }
    .login-logo h1 { font-size: 22px; }
}

/* タブレット以上: 2列レイアウト */
@media (min-width: 600px) {
    .card-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== Donut Chart Styles (Phase 1.4 Update) ===== */
/* ========================================================
   EA Cockpit - ドーナッツ円グラフ (Cockpit Main)
   portal.css に追加するスタイル
   ======================================================== */

/* --- メインドーナッツコンテナ --- */
.cockpit-main {
    background: linear-gradient(180deg, #14141d 0%, #0e0e16 100%);
    border: 1px solid #2a2a3a;
    border-radius: 12px;
    padding: 20px 16px 16px;
    margin-bottom: 14px;
    position: relative;
    overflow: hidden;
}

/* HUD風のアクセント (四隅の薄いL字) */
.cockpit-main::before,
.cockpit-main::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid #d4af37;
    opacity: 0.35;
    pointer-events: none;
}
.cockpit-main::before {
    top: 8px; left: 8px;
    border-right: none;
    border-bottom: none;
}
.cockpit-main::after {
    bottom: 8px; right: 8px;
    border-left: none;
    border-top: none;
}

/* --- ドーナッツラッパー --- */
.donut-wrapper {
    position: relative;
    width: 100%;
    max-width: 340px;
    margin: 0 auto 20px;
    aspect-ratio: 1;
}

.donut-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* --- ドーナッツ中央 (Equity表示) --- */
.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 60%;
    pointer-events: none;  /* Chart.js のホバーを邪魔しない */
}

.donut-center-label {
    color: #b4bac8;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.donut-center-value {
    color: #d4af37;
    font-size: 28px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    line-height: 1.1;
    margin-bottom: 2px;
    text-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.donut-center-sub {
    color: #9aa2b4;
    font-size: 9px;
    margin-bottom: 8px;
}

.donut-center-today {
    font-size: 13px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.donut-center-today.profit-up {
    background: rgba(110, 231, 163, 0.15);
    color: #6ee7a3;
    border: 1px solid rgba(110, 231, 163, 0.3);
}

.donut-center-today.profit-down {
    background: rgba(231, 110, 110, 0.15);
    color: #e76e6e;
    border: 1px solid rgba(231, 110, 110, 0.3);
}

/* --- 凡例 (Donut Legend) --- */
.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 4px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s;
}

.legend-row:hover {
    background: rgba(212, 175, 55, 0.05);
}

.legend-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.legend-name {
    color: #e8e8ec;
    font-size: 13px;
    font-weight: 500;
    flex: 1;
}

.legend-value {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.legend-value.profit-up   { color: #6ee7a3; }
.legend-value.profit-down { color: #e76e6e; }

/* --- 小型メトリクス3枚レイアウト --- */
.card-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}

.card-grid-3 .card-metric {
    padding: 10px;
}

.card-grid-3 .card-metric .label {
    font-size: 10px;
}

.card-grid-3 .card-metric .value {
    font-size: 18px;
}

.card-grid-3 .card-metric .sub {
    font-size: 9px;
}

/* --- プロフィット表示の色 (テキスト用) --- */
.profit-up-text   { color: #6ee7a3 !important; }
.profit-down-text { color: #e76e6e !important; }

/* --- 大画面 (タブレット以上) --- */
@media (min-width: 600px) {
    .cockpit-main {
        padding: 28px 24px 20px;
    }
    .donut-wrapper {
        max-width: 400px;
    }
    .donut-center-value {
        font-size: 34px;
    }
    .donut-center-today {
        font-size: 15px;
    }
}

/* --- 小型スマホ (iPhone SE等) --- */
@media (max-width: 380px) {
    .donut-center-value {
        font-size: 22px;
    }
    .donut-center-today {
        font-size: 11px;
        padding: 2px 8px;
    }
    .donut-center-label {
        font-size: 9px;
    }
}

/* ===== トグル切替ボタン (累積/今日) ===== */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #2a2a3a;
    border-radius: 24px;
    padding: 4px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.mode-btn {
    background: transparent;
    color: #b4bac8;
    border: none;
    padding: 8px 24px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    min-width: 80px;
}

.mode-btn:hover {
    color: #d4d8e2;
}

.mode-btn.active {
    background: linear-gradient(135deg, #d4af37 0%, #b8902a 100%);
    color: #0a0a0f;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4);
}

/* ===== 凡例 (1値表示版、ゆとり持って) ===== */
.legend-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s;
}

.legend-row:hover {
    background: rgba(212, 175, 55, 0.05);
}

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.legend-name {
    color: #e8e8ec;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

.legend-value {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

.legend-value.profit-up   { color: #6ee7a3; }
.legend-value.profit-down { color: #e76e6e; }

/* スマホ最適化 */
@media (max-width: 380px) {
    .mode-btn {
        padding: 7px 18px;
        min-width: 70px;
        font-size: 12px;
    }
    .legend-name {
        font-size: 13px;
    }
    .legend-value {
        font-size: 14px;
    }
}
