/* 全体の基本設定 */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --background-color: #f4f6f8;
    --text-color: #212529;
    --border-radius: 8px;
    --box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 2rem;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.main-container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- サイトヘッダーのスタイル --- */
.site-header { text-align: center; margin-bottom: 2rem; }
.site-header .aws-logo { height: 60px; margin-bottom: 1rem; }
.site-header h1 { font-size: 2.2rem; color: var(--dark-color); margin: 0; font-weight: 700; }
.site-header p { font-size: 1.1rem; color: var(--secondary-color); margin-top: 0.5rem; }

/* --- SSO専用ログインエリアのスタイル --- */
#loginArea {
    width: 100%;
    max-width: 500px;
    padding: 3rem;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    text-align: center;
}

#ssoLoginButton {
    display: inline-block;
    width: 80%;
    max-width: 320px;
    padding: 1rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

#ssoLoginButton:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.3);
}

/* --- アプリ本体のスタイル --- */
#appContainer, #logContainer {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
}
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}
.app-header h1 { margin: 0; font-size: 1.6rem; }
.header-buttons button {
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: bold;
    border-radius: 8px;
    margin-left: 15px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 2px solid transparent;
}
#refreshButton {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
#refreshButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
}
#logoutButton {
    background-color: transparent;
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}
#logoutButton:hover {
    background-color: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
}

/* --- インスタンス数のサマリー表示のスタイル --- */
#instanceSummary {
    text-align: center;
    margin: 0 0 1.5rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: bold;
}

/* --- メッセージエリアのスタイル --- */
#loadingMessage, #errorMessage {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
}
#loadingMessage {
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
}
#errorMessage {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
}

/* --- EC2一覧テーブルのスタイル --- */
.table-wrapper { overflow-x: auto; }
#ec2InstanceTable {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
    margin-top: 1.5rem;
}
#ec2InstanceTable th, #ec2InstanceTable td {
    border-bottom: 1px solid #dee2e6;
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
    font-size: 0.95rem;
}
#ec2InstanceTable thead th {
    background-color: var(--light-color);
    font-weight: bold;
    color: var(--dark-color);
}
#ec2InstanceTable tbody tr:hover { background-color: #f1f8ff; }
#ec2InstanceTable td:first-child { font-weight: bold; }
#ec2InstanceTable td small { color: #6c757d; font-size: 0.9em; }

/* --- 状態バッジのスタイル --- */
.status-badge {
    display: inline-block;
    padding: 0.5em 0.9em;
    font-size: 0.9em;
    font-weight: bold;
    line-height: 1;
    text-align: center;
    border-radius: 50px;
}
.status-running { color: #1a5e3a; background-color: #d1fae5; }
.status-stopped { color: #991b1b; background-color: #fee2e2; }
.status-pending, .status-stopping { color: #92400e; background-color: #fef3c7; }

/* --- テーブル内ボタンのスタイル --- */
#ec2InstanceTable button {
    padding: 8px 16px;
    font-size: 0.95rem;
    border: none;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#ec2InstanceTable button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.btn-start { background: linear-gradient(45deg, #28a745, #22c55e); }
.btn-stop { background: linear-gradient(45deg, #dc3545, #ef4444); }

/* --- ログ表示用のテーブルのスタイル --- */
#logTable {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    margin-top: 1.5rem;
}
#logTable th, #logTable td {
    border-bottom: 1px solid #dee2e6;
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
    font-size: 0.9rem;
}
#logTable thead th {
    background-color: #f8f9fa;
    font-weight: bold;
}
#logTable tbody tr:hover {
    background-color: #f8f9fa;
}

/* --- 操作ログ画面用のボタンのスタイル --- */
#showLogsButton, #backToEc2Button {
    background-color: transparent;
    color: var(--secondary-color);
    border-color: var(--secondary-color);
}
#showLogsButton:hover, #backToEc2Button:hover {
    background-color: var(--secondary-color);
    color: white;
}

/* --- スマホなど小さい画面用の調整 --- */
@media (max-width: 768px) {
    body { padding: 1rem; }
    .app-header { flex-direction: column; align-items: flex-start; }
    .header-buttons { margin-top: 1rem; margin-left: 0 !important; }
}