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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
header {
    text-align: center;
    margin-bottom: 2rem;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* メインコンテンツ */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* カード共通スタイル */
.form-card, .data-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    padding: 2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.form-card:hover, .data-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

/* 入力セクション */
.input-section h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* シンプル版では不要 */

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.required {
    color: #e53e3e;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2c3e50;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.help-text {
    font-size: 0.875rem;
    color: #718096;
    margin-top: 0.25rem;
}

/* ボタンスタイル */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-danger {
    background: #e53e3e;
    color: white;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

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

.btn-edit {
    background: #3182ce;
    color: white;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    margin-right: 0.5rem;
}

.btn-edit:hover {
    background: #2c5282;
}

.btn-export {
    background: #38a169;
    color: white;
}

.btn-export:hover {
    background: #2f855a;
}

.btn-google {
    background: #4285f4;
    color: white;
}

.btn-google:hover {
    background: #3367d6;
}

.btn-import {
    background: #9f7aea;
    color: white;
}

.btn-import:hover {
    background: #805ad5;
}

/* アクションボタンエリア */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* データ表示セクション */
.data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.data-header h2 {
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.total-count, .total-amount {
    background: #f7fafc;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    color: #2d3748;
    border: 1px solid #e2e8f0;
}

.total-amount {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    color: white;
    border: none;
}

/* テーブルスタイル */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    min-width: 800px;
}

.data-table th {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
    max-width: 150px;
    word-wrap: break-word;
}

.data-table tbody tr:hover {
    background: #f7fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* セルの幅調整（6項目版：名前・続柄・金額・日付・住所・電話＋操作） */
.data-table th:nth-child(1),
.data-table td:nth-child(1) { /* 名前 */
    width: 15%;
    min-width: 90px;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) { /* 続柄 */
    width: 12%;
    text-align: center;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) { /* 金額 */
    width: 12%;
    text-align: right;
    font-weight: 600;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) { /* 日付 */
    width: 12%;
    text-align: center;
}

.data-table th:nth-child(5),
.data-table td:nth-child(5) { /* 住所 */
    width: 20%;
    max-width: 150px;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table th:nth-child(6),
.data-table td:nth-child(6) { /* 電話 */
    width: 15%;
    text-align: center;
}

.data-table th:nth-child(7),
.data-table td:nth-child(7) { /* 操作 */
    width: 14%;
    min-width: 140px;
}

/* ローディングと空データメッセージ */
.loading, .no-data {
    text-align: center;
    padding: 3rem 1rem;
    color: #718096;
}

.loading i {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.no-data i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #cbd5e0;
}

.no-data p {
    font-size: 1.1rem;
    line-height: 1.6;
}

/* モーダルスタイル */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 3% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close, .close-google {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.close:hover, .close-google:hover {
    background-color: rgba(255,255,255,0.2);
}

.modal-content form,
.modal-body {
    padding: 2rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.modal-buttons .btn {
    width: auto;
}

/* Google Sheets設定 */
.google-sheets-setup {
    max-width: 100%;
}

.setup-steps {
    background: #f7fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid #4285f4;
}

.setup-steps li {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* フッター */
footer {
    text-align: center;
    padding: 1rem;
    color: white;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* レスポンシブデザイン */
@media (max-width: 1024px) {
    .container {
        padding: 1rem;
    }
    
    main {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .action-buttons {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .form-card, .data-card {
        padding: 1.5rem;
    }
    
    /* シンプル版では不要 */
    
    .data-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .summary {
        justify-content: space-between;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .data-table {
        font-size: 0.8rem;
        min-width: 1000px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
    }
    
    .modal-content form,
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    header {
        margin-bottom: 1rem;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    .form-card, .data-card {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
    }
    
    .data-table {
        font-size: 0.75rem;
    }
}

/* プリント用スタイル */
@media print {
    body {
        background: white;
    }
    
    .container {
        max-width: none;
        padding: 1rem;
    }
    
    header {
        color: black;
    }
    
    main {
        display: block;
    }
    
    .form-card {
        display: none;
    }
    
    .action-buttons {
        display: none;
    }
    
    .data-table th,
    .data-table td {
        border: 1px solid #ccc;
        padding: 0.5rem;
    }
    
    .btn {
        display: none;
    }
}