/**
 * レスポンシブスタイル
 * モバイルファースト
 */

/* ========================================
   スマートフォン（デフォルト）
   0 - 767px
   ======================================== */
@media (max-width: 767px) {

    /* スマホでの自動ズーム防止 - 入力フィールドのフォントサイズを16px以上に */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* タッチ時の不要なハイライトを無効化 */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* インタラクティブ要素のみ軽いハイライト */
    a,
    button,
    input,
    select,
    textarea {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
    }

    .container {
        padding: 0 var(--spacing-sm);
    }

    .card {
        padding: var(--spacing-md);
        border-radius: 8px;
    }

    .btn {
        padding: 12px 16px;
        /* Larger hit area */
        width: 100%;
        margin-bottom: 8px;
    }

    .header-content {
        padding: 0 var(--spacing-md);
    }

    .page-title {
        font-size: 20px;
        margin: 16px 0;
    }

    .batch-table,
    .batch-table tbody,
    .batch-table tr,
    .batch-table td {
        display: block;
        width: 100%;
    }

    .batch-table thead {
        display: none;
    }

    .batch-table tr {
        background: #fff;
        border: 1px solid var(--color-border-gray);
        border-radius: var(--border-radius);
        margin-bottom: 16px;
        padding: 16px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .batch-table td {
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid var(--color-light-gray);
        display: flex;
        align-items: center;
        text-align: right;
    }

    .batch-table td:last-child {
        border-bottom: none;
        justify-content: center;
        padding-top: 16px;
    }

    .batch-table td[data-label]::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--color-text-gray);
        font-size: 12px;
        width: 60px;
        text-align: left;
        flex-shrink: 0;
        margin-right: 8px;
    }

    .batch-table input,
    .batch-table select {
        flex: 1;
        text-align: left;
        border: 1px solid var(--color-border-gray);
        border-radius: 4px;
        padding: 0 8px;
        background: #fafafa;
        height: 40px;
        /* Larger touch target */
    }

    /* 日付入力のタップエリアを明確化 */
    .batch-table .col-date {
        border: 1px solid #9ca3af;
        /* 枠線を少し濃くして強調 */
        background-color: #fff;
    }

    .batch-table .text-right input {
        text-align: right;
    }

    .btn-remove {
        background-color: #fee2e2;
        color: var(--color-error);
        font-size: 14px;
        padding: 8px;
        border-radius: 4px;
        width: 100%;
        font-weight: bold;
    }

    /* 取引一覧のテーブルをカード形式に */
    .table-responsive .table {
        display: block;
    }

    .table-responsive .table thead {
        display: none;
    }

    .table-responsive .table tbody {
        display: block;
    }

    .table-responsive .table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid var(--color-border-gray);
        border-radius: var(--border-radius);
        margin-bottom: 16px;
        padding: 16px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        position: relative;
    }

    .table-responsive .table tbody td {
        display: block;
        padding: 8px 0;
        border: none;
        text-align: left !important;
    }

    /* 日付を右上に配置 */
    .table-responsive .table tbody tr td:first-child {
        position: absolute;
        top: 16px;
        right: 16px;
        padding: 4px 8px;
        background: var(--color-light-gray);
        border-radius: 4px;
        font-size: 12px;
        font-weight: 600;
        color: var(--color-text-gray);
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
    }

    /* 要修正バッジのスタイル調整 */
    .table-responsive .table tbody tr td:first-child .badge {
        margin-left: 0 !important;
        margin-top: 4px;
    }

    /* 部門・科目・支払先・摘要 */
    .table-responsive .table tbody tr td:nth-child(2),
    .table-responsive .table tbody tr td:nth-child(3),
    .table-responsive .table tbody tr td:nth-child(4),
    .table-responsive .table tbody tr td:nth-child(5) {
        padding: 6px 0;
        border-bottom: 1px solid var(--color-light-gray);
    }

    .table-responsive .table tbody tr td:nth-child(2)::before {
        content: '部門: ';
        font-weight: 600;
        color: var(--color-text-gray);
        font-size: 12px;
    }

    .table-responsive .table tbody tr td:nth-child(3)::before {
        content: '科目: ';
        font-weight: 600;
        color: var(--color-text-gray);
        font-size: 12px;
    }

    .table-responsive .table tbody tr td:nth-child(4)::before {
        content: '支払先: ';
        font-weight: 600;
        color: var(--color-text-gray);
        font-size: 12px;
    }

    .table-responsive .table tbody tr td:nth-child(5)::before {
        content: '摘要: ';
        font-weight: 600;
        color: var(--color-text-gray);
        font-size: 12px;
    }

    /* 金額を大きく強調 */
    .table-responsive .table tbody tr td:nth-child(6) {
        font-size: 24px;
        font-weight: 700;
        padding: 12px 0;
        margin-top: 8px;
        text-align: left !important;
    }

    /* 詳細ボタンを大きく */
    .table-responsive .table tbody tr td:nth-child(7) {
        padding-top: 12px;
        margin-top: 8px;
        border-top: 1px solid var(--color-light-gray);
    }

    .table-responsive .table tbody tr td:nth-child(7) button {
        width: 100%;
        height: 44px;
        font-size: 16px;
    }

    /* フィルターを縦並びに */
    .filters {
        flex-direction: column;
        gap: 12px !important;
    }

    .filter-group {
        width: 100% !important;
        min-width: auto !important;
    }

    .filters button {
        width: 100%;
    }

    /* ページタイトルとボタンを縦並びに */
    .main-content .container>div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px;
    }

    .main-content .container>div[style*="justify-content: space-between"]>div {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .main-content .container>div[style*="justify-content: space-between"]>div button {
        width: 100%;
    }
}

/* ========================================
   タブレット
   768px - 1023px
   ======================================== */
@media (min-width: 768px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-buttons {
        flex-wrap: nowrap;
    }

    .login-container {
        padding: var(--spacing-lg);
    }
}

/* ========================================
   PC
   1024px+
   ======================================== */
@media (min-width: 1024px) {
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .header-content {
        padding: 0 var(--spacing-lg);
    }

    .container {
        padding: 0 var(--spacing-lg);
    }
}

/* ========================================
   印刷用スタイル
   ======================================== */
@media print {

    .header,
    .btn,
    .action-buttons {
        display: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--color-border-gray);
    }

    body {
        background-color: var(--color-white);
    }
}