/* Document Manager v2.1 - Frontend（テーブル型 / シンプル・ミニマル / 青系 / レスポンシブ） */

:root {
    --dm-blue:       #2563eb;
    --dm-blue-light: #eff6ff;
    --dm-blue-mid:   #bfdbfe;
    --dm-border:     #e2e8f0;
    --dm-text:       #1e293b;
    --dm-muted:      #64748b;
    --dm-bg:         #f8fafc;
    --dm-white:      #ffffff;
    --dm-radius:     8px;
}

.dm-wrap {
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Meiryo', sans-serif;
    color: var(--dm-text);
    font-size: 14px;
}

/* タブ */
.dm-header { margin-bottom: 16px; }
.dm-tabs { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.dm-tabs::-webkit-scrollbar { display: none; }
.dm-tab {
    padding: 8px 16px; border: none; background: none; font-size: 13px; font-weight: 500;
    color: var(--dm-muted); cursor: pointer; border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s; display: inline-flex; align-items: center; gap: 6px;
    white-space: nowrap; flex-shrink: 0;
}
.dm-tab:hover { color: var(--dm-blue); }
.dm-tab.active { color: var(--dm-blue); border-bottom-color: var(--dm-blue); font-weight: 600; }
.dm-tab-count { font-size: 11px; background: var(--dm-blue-light); color: var(--dm-blue); padding: 1px 7px; border-radius: 20px; font-weight: 600; }
.dm-tab.active .dm-tab-count { background: var(--dm-blue); color: #fff; }

/* テーブル */
.dm-table-wrap { border: 1px solid var(--dm-border); border-radius: var(--dm-radius); overflow: hidden; background: var(--dm-white); }
.dm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dm-table thead tr { background: var(--dm-bg); border-bottom: 1px solid var(--dm-border); }
.dm-table th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600; color: var(--dm-muted); letter-spacing: .04em; white-space: nowrap; }
.dm-table td { padding: 13px 16px; border-bottom: 1px solid var(--dm-border); vertical-align: middle; }
.dm-row:last-child td { border-bottom: none; }
.dm-row:hover td { background: var(--dm-blue-light); }
.dm-row.dm-hidden { display: none; }
.dm-row-title { font-weight: 600; color: var(--dm-text); }
.dm-row-note  { color: var(--dm-muted); font-size: 13px; max-width: 200px; }
.dm-row-date  { color: var(--dm-muted); font-size: 13px; white-space: nowrap; }
.dm-row-actions { white-space: nowrap; text-align: right; }

/* 書類種別バッジ */
.dm-badge { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.dm-badge-estimate { background: #dbeafe; color: #1d4ed8; }
.dm-badge-contract { background: #dcfce7; color: #166534; }
.dm-badge-invoice  { background: #fef9c3; color: #854d0e; }
.dm-badge-other    { background: #f1f5f9; color: #475569; }

/* ファイル形式バッジ */
.dm-ext-badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 10px; font-weight: 700; margin-left: 6px; vertical-align: middle; }
.dm-ext-pdf  { background: #fee2e2; color: #dc2626; }
.dm-ext-xlsx, .dm-ext-xls { background: #dcfce7; color: #166534; }
.dm-ext-csv  { background: #e0f2fe; color: #0369a1; }
.dm-ext-zip  { background: #f3e8ff; color: #7c3aed; }

/* ボタン */
.dm-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 12px; border-radius: 6px; font-size: 12px;
    font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all .15s;
}
.dm-btn-preview { background: var(--dm-white); color: var(--dm-blue); border-color: var(--dm-blue-mid); margin-right: 6px; }
.dm-btn-preview:hover { background: var(--dm-blue-light); border-color: var(--dm-blue); }
.dm-btn-download { background: var(--dm-blue); color: #fff; border-color: var(--dm-blue); }
.dm-btn-download:hover { background: #1d4ed8; }
.dm-no-file { font-size: 12px; color: #94a3b8; }

/* 空 / ログイン */
.dm-empty { padding: 48px 20px; text-align: center; color: var(--dm-muted); border: 1px solid var(--dm-border); border-radius: var(--dm-radius); background: var(--dm-white); }
.dm-login-notice { padding: 40px 20px; text-align: center; border: 1px solid var(--dm-border); border-radius: var(--dm-radius); background: var(--dm-white); color: var(--dm-muted); }
.dm-login-notice a { color: var(--dm-blue); text-decoration: underline; }

/* モーダル */
.dm-modal { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; }
.dm-overlay { position: absolute; inset: 0; background: rgba(15,23,42,.6); backdrop-filter: blur(3px); }
.dm-modal-box { position: relative; z-index: 1; background: var(--dm-white); border-radius: 12px; width: min(92vw, 860px); height: 88vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dm-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--dm-border); background: var(--dm-bg); flex-shrink: 0; }
.dm-modal-head h3 { font-size: 14px; font-weight: 600; color: var(--dm-text); margin: 0; }
.dm-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--dm-muted); padding: 4px 8px; border-radius: 4px; line-height: 1; }
.dm-close:hover { background: #fee2e2; color: #dc2626; }
.dm-modal-body { flex: 1; overflow: hidden; position: relative; }
#dm-pdf-frame { width: 100%; height: 100%; border: none; display: block; }
.dm-loader { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--dm-muted); font-size: 13px; }
.dm-spinner { width: 32px; height: 32px; border: 3px solid var(--dm-border); border-top-color: var(--dm-blue); border-radius: 50%; animation: dm-spin .7s linear infinite; }
@keyframes dm-spin { to { transform: rotate(360deg); } }
.dm-modal-foot { padding: 12px 20px; border-top: 1px solid var(--dm-border); background: var(--dm-bg); display: flex; justify-content: flex-end; flex-shrink: 0; }
.dm-btn-dl-modal { background: var(--dm-blue); color: #fff; border-color: var(--dm-blue); padding: 8px 18px; font-size: 13px; border-radius: 6px; flex: none; }
.dm-btn-dl-modal:hover { background: #1d4ed8; }

/* ════════════ レスポンシブ：タブレット（768px以下） ════════════ */
@media (max-width: 768px) {
    .dm-col-note { display: none; }
    .dm-table th, .dm-table td { padding: 11px 12px; }
    .dm-btn { padding: 5px 10px; font-size: 11px; }
    .dm-btn-preview { margin-right: 4px; }
}

/* ════════════ レスポンシブ：スマートフォン（480px以下） ════════════ */
@media (max-width: 480px) {

    /* テーブル → カード変換 */
    .dm-table-wrap { border: none; border-radius: 0; background: transparent; }
    .dm-table, .dm-table thead, .dm-table tbody, .dm-table th, .dm-table td, .dm-table tr { display: block; }
    .dm-table thead { display: none; }

    .dm-row {
        background: var(--dm-white);
        border: 1px solid var(--dm-border);
        border-radius: var(--dm-radius);
        margin-bottom: 10px;
        padding: 14px;
    }
    .dm-row:hover td { background: transparent; }
    .dm-row:hover { background: var(--dm-blue-light); }

    .dm-table td { border: none; padding: 0; margin-bottom: 6px; }
    .dm-table td:last-child { margin-bottom: 0; }

    /* 備考を復活させる */
    .dm-col-note { display: block !important; }

    .dm-row-title { font-size: 15px; }
    .dm-row-note  { max-width: 100%; font-size: 12px; }
    .dm-row-date  { font-size: 12px; }

    /* ボタンエリア */
    .dm-row-actions {
        text-align: left;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--dm-border);
        display: flex;
        gap: 8px;
    }
    .dm-btn { flex: 1; justify-content: center; padding: 8px 10px; font-size: 12px; }
    .dm-btn-preview { margin-right: 0; }

    /* モーダルフルスクリーン */
    .dm-modal-box { width: 100vw; height: 100dvh; border-radius: 0; }
}
