/* GeoWork 共通CSS */

/* Material Design 3 カラー定義 */
:root {
    /* Primary */
    --md-primary: #1976d2;
    --md-primary-variant: #004ba0;
    --md-on-primary: #ffffff;

    /* Secondary */
    --md-secondary: #03a9f4;
    --md-secondary-variant: #0288d1;
    --md-on-secondary: #ffffff;

    /* Background */
    --md-background: #ffffff;
    --md-surface: #ffffff;
    --md-surface-variant: #f5f5f5;

    /* Error */
    --md-error: #ba1a1a;
    --md-on-error: #ffffff;

    /* Text */
    --md-on-background: #000000;
    --md-on-surface: #000000;
    --md-on-surface-variant: #49454f;

    /* Outline */
    --md-outline: #79747e;
    --md-outline-variant: #cac4d0;
}

/* ベーススタイル */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--md-background);
    color: var(--md-on-background);
    line-height: 1.6;
}

/* ナビゲーション */
.navbar-brand {
    font-weight: 600;
    font-size: 1.5rem;
}

.navbar .material-symbols-outlined {
    font-size: 1.2rem;
}

/* navbarのユーザー表示領域を調整 */
.navbar .nav-link {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
}

/* navbarのコンテナ幅を調整 */
.navbar .container-fluid {
    max-width: 100%;
    padding-right: 1rem;
}

/* navbarの全疑似要素を強制無効化 */
.navbar *::after,
.navbar *::before {
    content: none !important;
    display: none !important;
}

/* カードスタイル */
.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
}

.card-header {
    background-color: var(--md-surface-variant);
    border-bottom: 1px solid var(--md-outline-variant);
    font-weight: 600;
}

/* ボタンスタイル */
.btn {
    font-weight: 500;
    border-radius: 8px;
    padding: 8px 16px;
    min-width: 64px;
    transition: all 0.2s ease;
}

.btn .material-symbols-outlined {
    font-size: 1.1rem;
    vertical-align: middle;
}

.btn-primary {
    background-color: var(--md-primary);
    border-color: var(--md-primary);
}

.btn-primary:hover {
    background-color: var(--md-primary-variant);
    border-color: var(--md-primary-variant);
}

.btn-secondary {
    background-color: var(--md-secondary);
    border-color: var(--md-secondary);
}

.btn-outline-primary {
    color: var(--md-primary);
    border-color: var(--md-primary);
}

.btn-outline-primary:hover {
    background-color: var(--md-primary);
    border-color: var(--md-primary);
}

/* フォームスタイル */
.form-control, .form-select {
    border: 2px solid var(--md-outline-variant);
    border-radius: 8px;
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 0.2rem rgba(25, 118, 210, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--md-on-surface);
}

/* input-group-text - 左側用（アイコン+入力欄） */
.input-group-text:first-child {
    background-color: var(--md-surface-variant);
    border: 2px solid var(--md-outline-variant);
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

/* input-group-text - 右側用（入力欄+テキスト） */
.input-group-text:last-child {
    background-color: var(--md-surface-variant);
    border: 2px solid var(--md-outline-variant);
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

/* form-control - 左側にinput-group-textがある場合 */
.input-group .form-control {
    border-radius: 0 8px 8px 0;
}

/* form-control - 右側にinput-group-textがある場合 */
.input-group-text + .form-control {
    border-radius: 8px 0 0 8px;
}

/* アラートスタイル */
.alert {
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
}

.alert .material-symbols-outlined {
    font-size: 1.2rem;
    vertical-align: middle;
}

/* テーブルスタイル */
.table {
    border-radius: 8px;
    overflow: hidden;
}

.table th {
    background-color: var(--md-surface-variant);
    font-weight: 600;
    border: none;
    padding: 12px 16px;
}

.table td {
    padding: 12px 16px;
    vertical-align: middle;
    border-color: var(--md-outline-variant);
}

/* 打刻状況テーブルのワードラップ制御 */
.table td:nth-child(1), /* 社員名 */
.table td:nth-child(2), /* 日時 */
.table td:nth-child(4) { /* メモ */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px; /* 社員名 */
}

.table td:nth-child(2) {
    max-width: 180px; /* 日時 */
}

.table td:nth-child(4) {
    max-width: 200px; /* メモ */
}

/* テーブルコンテナの横スクロール対応 */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    min-width: 600px; /* テーブルの最小幅 */
}

/* Material Icons調整 */
.material-symbols-outlined {
    vertical-align: middle;
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24;
}

/* 状態バッジ調整 */
.badge {
    font-weight: 500;
    min-width: 80px;
    height: auto;
    white-space: nowrap;
}

/* ステータスバッジ専用スタイル */
.status-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px;
    padding: 4px 8px !important;
    font-size: 12px !important;
    border-radius: 12px !important;
    min-width: 90px;
}

.badge-icon {
    font-size: 14px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.badge-text {
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

/* テーブル内のバッジ調整 */
.table .badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.table .status-badge {
    min-width: 100px;
}

/* ページヘッダー */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--md-outline-variant);
}

.page-title {
    font-size: 2rem;
    font-weight: 600;
    color: var(--md-primary);
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .btn {
        padding: 10px 16px;
    }

    .form-control, .form-select {
        padding: 10px 14px;
    }
}

/* ローディングアニメーション */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* 状態インジケーター */
.status-badge {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-working {
    background-color: #e8f5e8;
    color: #2e7d32;
}

.status-off {
    background-color: #f5f5f5;
    color: #616161;
}

.status-break {
    background-color: #fff3e0;
    color: #f57c00;
}

.status-warning {
    background-color: #fff8e1;
    color: #f9a825;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% { opacity: 0.5; }
}

/* 地図コンテナ */
#map {
    height: 500px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--md-outline-variant);
}

/* サーバー情報表示（IPアドレス）を非表示 */
body > div[style*="position: fixed"][style*="top: 5px"][style*="right: 5px"] {
    display: none !important;
}

/* 打刻ボタン */
.dakoku-btn {
    padding: 1.5rem 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.dakoku-btn .material-symbols-outlined {
    font-size: 2rem;
    line-height: 1;
}

.dakoku-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dakoku-btn:disabled {
    opacity: 0.6;
    transform: none;
    box-shadow: none;
}

.dakoku-btn:disabled .material-symbols-outlined {
    filter: grayscale(1);
}

/* モバイル向け打刻画面調整 */
@media (max-width: 767.98px) {
    /* 打刻カード全体のサイズ調整 */
    .col-lg-8, .col-xl-6 {
        max-width: 100%;
        padding: 0 1rem;
    }

    /* 打刻ボタンをさらに小さく */
    .dakoku-btn {
        min-height: 65px;  /* 120px → 80px → 65px */
        padding: 0.75rem 0.25rem;
        font-size: 0.75rem;  /* 1.1rem → 0.9rem → 0.75rem */
    }

    .dakoku-btn .material-symbols-outlined {
        font-size: 1.2rem;  /* 2rem → 1.5rem → 1.2rem */
    }

    /* 時刻表示をさらに小さく */
    .display-4 {
        font-size: 2rem !important;  /* デフォルトの約3.5rem → 2.5rem → 2rem */
    }

    /* ボタン配置調整 */
    .col-6.col-md-3 {
        flex: 0 0 calc(50% - 0.3rem); /* gapの分を引く */
        max-width: calc(50% - 0.3rem);
        padding: 0.15rem;
    }

    /* メモ欄調整 */
    #stamp-memo {
        font-size: 0.85rem;
    }

    /* 打刻状況テーブルの文字サイズ調整 */
    .table {
        font-size: 0.75rem;
    }

    .table th {
        font-size: 0.75rem;
        padding: 8px 12px;
    }

    .table td {
        font-size: 0.75rem;
        padding: 8px 12px;
    }

    /* バッジの文字サイズ調整 */
    .table .badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .table .status-badge {
        font-size: 0.65rem;
        padding: 3px 8px;
        min-width: 70px;
    }

    /* Material Iconsサイズ調整 */
    .table .material-symbols-outlined {
        font-size: 1rem;
    }

    /* 携帯向けテーブルサイズ最適化 */
    .table {
        min-width: 380px !important; /* 600px → 380px */
    }

    /* セル最大幅の再調整 */
    .table td:nth-child(1) { /* 社員名 */
        max-width: 100px; /* 150px → 100px */
    }

    .table td:nth-child(2) { /* 日時 */
        max-width: 140px; /* 180px → 140px */
    }

    .table td:nth-child(4) { /* メモ */
        max-width: 120px; /* 200px → 120px */
    }

    /* 状態バッジのサイズ調整 */
    .table .status-badge {
        min-width: 60px; /* 70px → 60px */
        padding: 2px 6px; /* 3px 8px → 2px 6px */
    }

    /* 縦の間隔を詰める */
    .table th,
    .table td {
        padding: 6px 8px; /* 8px 12px → 6px 8px */
    }
}

/* 超小さい画面（iPhone SEとか）向け */
@media (max-width: 500px) {
    .dakoku-btn {
        min-height: 55px;  /* 70px → 55px */
        font-size: 0.7rem;  /* 0.8rem → 0.7rem */
        padding: 0.5rem 0.2rem;
    }

    .dakoku-btn .material-symbols-outlined {
        font-size: 1rem;  /* 1.2rem → 1rem */
    }

    .display-4 {
        font-size: 1.5rem !important;  /* 2rem → 1.5rem */
    }

    /* 2x2配置を維持しつつパディングを減らす */
    .row.g-3.mb-4 {
        gap: 0.15rem; /* 0.25rem → 0.15rem でさらに詰める */
    }

    /* ボタンの左右パディングをさらに詰めて改行防止 */
    .col-6.col-md-3 {
        flex: 0 0 calc(50% - 0.2rem) !important; /* gapの分を引く */
        max-width: calc(50% - 0.2rem) !important;
        padding: 0.1rem !important;
    }
}