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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'メイリオ', Meiryo, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* ヘッダー */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
}

/* メインコンテンツ */
main {
    padding: 30px;
}

/* フォームセクション */
.add-stock-section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.add-stock-section h2 {
    margin-bottom: 10px;
    color: #667eea;
    font-size: 1.5rem;
}

.form-description {
    color: #6c757d;
    font-size: 0.95rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

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

.form-grid-simple {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.form-group input {
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.input-hint {
    margin-top: 5px;
    font-size: 0.8rem;
    color: #6c757d;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid #f5c6cb;
    font-size: 0.9rem;
}

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

/* ボタン */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-edit {
    background: #28a745;
    color: white;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-edit:hover {
    background: #218838;
}

.btn-delete {
    background: #dc3545;
    color: white;
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-refresh {
    background: #17a2b8;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-refresh:hover {
    background: #138496;
}

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

.btn-loading {
    display: inline-block;
}

/* ポートフォリオセクション */
.portfolio-section h2 {
    margin-bottom: 15px;
    color: #667eea;
    font-size: 1.5rem;
}

.portfolio-actions {
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-end;
}

/* サマリーカード */
.portfolio-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.summary-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.summary-card.highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.summary-card.highlight .summary-label,
.summary-card.highlight .summary-value {
    color: white;
}

.summary-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.table-responsive {
    overflow-x: auto;
}

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

thead {
    background: #f8f9fa;
}

th {
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #dee2e6;
    font-size: 0.9rem;
}

td {
    padding: 15px 10px;
    border-bottom: 1px solid #e9ecef;
}

tbody tr {
    transition: background-color 0.2s;
}

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

.total-row {
    background: #e7f3ff !important;
    font-size: 1.1rem;
}

.total-row td {
    border-top: 3px solid #667eea;
    padding: 20px 10px;
}

/* 操作ボタン */
.action-buttons {
    display: flex;
    gap: 8px;
}

/* 空の状態 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.8;
}

/* フッター */
footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
    border-top: 1px solid #e9ecef;
}

footer p {
    margin: 5px 0;
}

.api-notice {
    font-size: 0.85rem;
    color: #868e96;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 20px;
    }

    .add-stock-section {
        padding: 20px;
    }

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

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

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

    .summary-value {
        font-size: 1.6rem;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 10px 5px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .btn-edit, .btn-delete {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.2rem;
    }

    .add-stock-section h2,
    .portfolio-section h2 {
        font-size: 1.2rem;
    }

    .summary-value {
        font-size: 1.4rem;
    }

    .summary-label {
        font-size: 0.8rem;
    }

    table {
        font-size: 0.75rem;
    }

    th, td {
        padding: 8px 4px;
    }

    .action-buttons {
        flex-direction: column;
        gap: 4px;
    }

    .btn-edit, .btn-delete {
        width: 100%;
    }
}

/* 数値の右寄せ */
td:nth-child(1),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5),
td:nth-child(6),
td:nth-child(7) {
    text-align: right;
}

th:nth-child(1),
th:nth-child(3),
th:nth-child(4),
th:nth-child(5),
th:nth-child(6),
th:nth-child(7) {
    text-align: right;
}
