/* ========================================
   リセット & 基本設定
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
    line-height: 1.6;
}

/* ========================================
   コンテナ
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ========================================
   ヘッダー
   ======================================== */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* ========================================
   カード
   ======================================== */
.card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========================================
   フォーム
   ======================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

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

.required {
    color: #e74c3c;
}

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

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ========================================
   ボタン
   ======================================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

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

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.btn-danger {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

.btn-edit {
    background: #3498db;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-edit:hover {
    background: #2980b9;
}

.btn-outline {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

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

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

/* ========================================
   フィルターセクション
   ======================================== */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.export-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

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

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr {
    transition: background 0.2s;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ========================================
   商品別集約表示
   ======================================== */
.product-group {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.product-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.product-group-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #667eea;
}

.product-group-count {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.product-group table {
    margin-top: 10px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

/* ========================================
   ステータスメッセージ
   ======================================== */
.loading,
.no-data {
    text-align: center;
    padding: 40px;
    font-size: 1.1rem;
    color: #7f8c8d;
}

.loading i,
.no-data i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

/* ========================================
   表示切替
   ======================================== */
.view-toggle {
    margin-bottom: 20px;
    display: flex;
    justify-content: flex-end;
}

/* ========================================
   レスポンシブ対応
   ======================================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .card {
        padding: 15px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .export-actions {
        flex-direction: column;
    }
    
    .product-group-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .card h2 {
        font-size: 1.2rem;
    }
    
    /* テーブルをカード形式に変換 */
    table, thead, tbody, th, td, tr {
        display: block;
    }
    
    thead tr {
        display: none;
    }
    
    tr {
        margin-bottom: 15px;
        border: 2px solid #e0e0e0;
        border-radius: 8px;
        padding: 10px;
    }
    
    td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #e0e0e0;
    }
    
    td:last-child {
        border-bottom: none;
    }
    
    td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        font-weight: 600;
        color: #667eea;
    }
    
    .action-buttons {
        padding-left: 0;
    }
}

/* ========================================
   アニメーション
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.5s ease;
}

/* ========================================
   印刷対応
   ======================================== */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .form-section,
    .filter-section,
    .action-buttons,
    .view-toggle,
    .export-actions {
        display: none;
    }
    
    .card {
        box-shadow: none;
        page-break-inside: avoid;
    }
}
