/* =====================================================
   CS管理画面 スタイルシート
   ===================================================== */

/* --- リセット＆ベース --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Meiryo", sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

/* --- ヘッダー --- */
.header {
    background: #1a1a2e;
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}

.header-user {
    color: #c8c8d8;
}

.header-role {
    background: rgba(255,255,255,0.12);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 4px;
}

.header-link {
    color: #a0a0c0;
    text-decoration: none;
    transition: color 0.2s;
}

.header-link:hover {
    color: #fff;
}

.header-link-logout {
    color: #ff8080;
}

.header-link-logout:hover {
    color: #ff4040;
}

/* --- メイン --- */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 24px 40px;
}

/* --- ステータスカード --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border-left: 4px solid #ddd;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-unresolved { border-left-color: #e74c3c; }
.stat-check { border-left-color: #f39c12; }
.stat-unapproved { border-left-color: #9b59b6; }
.stat-total { border-left-color: #3498db; }

.stat-number {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.2;
}

.stat-unresolved .stat-number { color: #e74c3c; }
.stat-check .stat-number { color: #f39c12; }
.stat-unapproved .stat-number { color: #9b59b6; }
.stat-total .stat-number { color: #3498db; }

.stat-label {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    font-weight: 500;
}

/* --- フィルターバー --- */
.filter-bar {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    display: flex;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-buttons {
    display: flex;
    gap: 0;
}

.filter-btn {
    padding: 7px 14px;
    border: 1px solid #d0d0d8;
    background: #fff;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.filter-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.filter-btn:last-child {
    border-radius: 0 6px 6px 0;
}

.filter-btn:not(:first-child) {
    border-left: none;
}

.filter-btn:hover {
    background: #f0f0f8;
}

.filter-btn.active {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.filter-btn.active + .filter-btn {
    border-left-color: #1a1a2e;
}

.filter-select {
    padding: 7px 12px;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #333;
    background: #fff;
    cursor: pointer;
    min-width: 140px;
}

.filter-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}

.filter-search {
    flex: 1;
    min-width: 200px;
}

.filter-input {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #333;
}

.filter-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}

.filter-input::placeholder {
    color: #aaa;
}

.btn-refresh {
    padding: 7px 12px;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    background: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.btn-refresh:hover {
    background: #f0f0f8;
    border-color: #3498db;
}

.btn-refresh:active {
    transform: rotate(180deg);
}

/* --- テーブル --- */
.table-wrapper {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    overflow: hidden;
}

.ticket-table {
    width: 100%;
    border-collapse: collapse;
}

.ticket-table thead {
    background: #f7f8fa;
}

.ticket-table th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    border-bottom: 2px solid #e8e8f0;
    white-space: nowrap;
    position: sticky;
    top: 56px;
    background: #f7f8fa;
    z-index: 10;
}

.ticket-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f4;
    font-size: 13px;
    vertical-align: middle;
}

.ticket-row {
    cursor: pointer;
    transition: background 0.1s;
}

.ticket-row:hover {
    background: #f5f7ff;
}

.ticket-row:active {
    background: #ebefff;
}

/* 列幅 */
.col-date { width: 90px; white-space: nowrap; color: #666; font-size: 12px; }
.col-customer { width: 100px; font-weight: 600; }
.col-category { width: 100px; font-size: 12px; color: #666; }
.col-product { width: 130px; font-size: 12px; }
.col-summary { min-width: 200px; }
.col-approval, .col-sent, .col-check { width: 70px; text-align: center; }
.col-status { width: 80px; text-align: center; }

/* 要約を1行に省略 */
td.col-summary {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- バッジ --- */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-empty {
    color: #ccc;
    background: none;
}

.badge-unresolved {
    background: #ffeaea;
    color: #c0392b;
}

.badge-resolved {
    background: #e8f8f0;
    color: #27ae60;
}

.badge-check {
    background: #fff4e0;
    color: #e67e22;
}

.badge-approved {
    background: #eee8ff;
    color: #8e44ad;
}

.badge-sent {
    background: #e0f0ff;
    color: #2980b9;
}

.badge-confirmed {
    background: #e8f8f0;
    color: #27ae60;
}

.badge-default {
    background: #f0f0f4;
    color: #666;
}

/* --- ローディング＆空＆エラー --- */
.loading-cell, .empty-cell, .error-cell {
    text-align: center;
    padding: 40px 12px !important;
    color: #888;
    font-size: 14px;
}

.loading-cell::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-cell {
    color: #e74c3c;
    background: #fff5f5;
}

/* --- ページング --- */
.paging-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
}

.paging-btn {
    padding: 7px 16px;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.paging-btn:hover:not(:disabled) {
    background: #f0f0f8;
    border-color: #3498db;
}

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

.paging-info {
    font-size: 13px;
    color: #666;
}

/* --- レスポンシブ --- */
@media (max-width: 1024px) {
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-search {
        min-width: unset;
    }
    .col-category, .col-product {
        display: none;
    }
}

@media (max-width: 640px) {
    .header {
        padding: 0 12px;
        height: 48px;
    }
    .header-title {
        font-size: 15px;
    }
    .main {
        padding: 12px;
    }
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .stat-card {
        padding: 12px;
    }
    .stat-number {
        font-size: 22px;
    }
    .col-approval, .col-check {
        display: none;
    }
    td.col-summary {
        max-width: 180px;
    }
}

/* --- ログイン画面（既存のスタイルを維持） --- */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 32px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 22px;
    color: #1a1a2e;
}

.login-container input {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1px solid #d0d0d8;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.login-container button:hover {
    background: #2a2a4e;
}
