/* ===================================
   現場配置管理システム - スタイルシート
   =================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
}

/* ===================================
   ローディング画面
   =================================== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content i {
    font-size: 48px;
    margin-bottom: 16px;
}

.loading-content p {
    font-size: 18px;
    font-weight: 500;
}

/* ===================================
   ログイン画面
   =================================== */
.login-screen {
    min-height: 100vh;
    background: linear-gradient(135deg, #e0f2fe 0%, #bfdbfe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    padding: 40px;
    max-width: 400px;
    width: 100%;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header i {
    font-size: 56px;
    color: #2563eb;
    margin-bottom: 16px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.login-header p {
    color: #64748b;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.form-group input,
.form-group select {
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.error-message {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.form-group input.error {
    border-color: #dc2626;
}

.login-btn {
    padding: 14px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover:not(:disabled) {
    background: #1d4ed8;
}

.login-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* ===================================
   ヘッダー
   =================================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    border-bottom: 2px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header-icon {
    font-size: 24px;
    color: #16a34a;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: #e5e7eb;
}

.today-btn {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.today-btn:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.current-period {
    font-size: 14px;
    font-weight: 600;
    padding: 0 16px;
    color: #1f2937;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.zoom-level {
    font-size: 12px;
    min-width: 48px;
    text-align: center;
}

.icon-btn {
    padding: 6px 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: #1f2937;
}

.last-updated {
    font-size: 11px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
}

.master-btn {
    background: #4b5563;
}

.master-btn:hover {
    background: #374151;
}

.history-btn {
    background: #7c3aed;
}

.history-btn:hover {
    background: #6d28d9;
}

.export-btn {
    background: #16a34a;
}

.export-btn:hover {
    background: #15803d;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
}

.user-info i {
    color: #6b7280;
}

.logout-btn {
    padding: 8px 14px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 40px;
}

.logout-btn:hover {
    background: #b91c1c;
}

/* ===================================
   スケジュールコンテナ
   =================================== */
.schedule-container {
    overflow: auto;
    height: calc(100vh - 65px);
    transform-origin: top left;
}

.day-row {
    display: flex;
    border-bottom: 4px solid #6b7280;
}

.week-column {
    flex: 1;
    min-width: 650px;
    border-right: 4px solid #6b7280;
}

.week-column:last-child {
    border-right: none;
}

/* ===================================
   スケジュールテーブル
   =================================== */
.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid #d1d5db;
    padding: 2px 4px;
    vertical-align: middle;
}

.date-header {
    background: #f3f4f6;
    padding: 0 4px !important;
    font-weight: 700;
    font-size: 14px;
    border: 2px solid #9ca3af !important;
    height: 26px;
    line-height: 26px;
}

.date-header.weekend {
    background: #e5e7eb;
}

.date-header.today {
    background: #2563eb !important;
    color: white !important;
}

.column-header {
    background: #f3f4f6;
    font-weight: 600;
    text-align: center;
    font-size: 9px;
}

.site-row {
    height: 26px;
}

.site-row:hover {
    background: #fefce8;
}

.cell-no {
    width: 20px;
    text-align: center;
}

.cell-name {
    width: 108px;
}

.cell-address {
    width: 54px;
    cursor: pointer;
    text-align: center;
}

.cell-address:hover {
    background: #e5e7eb;
}

.cell-required {
    width: 32px;
    text-align: center;
}

.cell-required .cell-input {
    text-align: center;
}

.cell-workers {
    width: 108px;
    height: 22px;
    cursor: pointer;
}

.cell-workers:hover {
    background: #e0f2fe;
}

.cell-count {
    width: 32px;
    text-align: center;
    font-weight: 600;
}

.cell-count.count-short {
    color: #dc2626;
    font-weight: 700;
}

.cell-manager {
    width: 54px;
    text-align: center;
}

.cell-time {
    width: 72px;
    text-align: center;
}

.cell-type {
    width: 72px;
    text-align: center;
}

.cell-notes {
    width: 108px;
}

/* 入力フィールド */
.cell-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 2px;
    font-size: 9px;
    outline: none;
}

.cell-input:focus {
    background: white;
    box-shadow: inset 0 0 0 1px #3b82f6;
}

.cell-select {
    width: 100%;
    border: none;
    background: transparent;
    padding: 1px;
    font-size: 9px;
    outline: none;
    cursor: pointer;
}

.cell-select:focus {
    background: white;
    box-shadow: inset 0 0 0 1px #3b82f6;
}

.cell-textarea {
    width: 100%;
    border: none;
    background: transparent;
    padding: 2px;
    font-size: 9px;
    outline: none;
    resize: none;
    min-height: 22px;
    line-height: 1.2;
}

.cell-textarea:focus {
    background: white;
    box-shadow: inset 0 0 0 1px #3b82f6;
}

/* 作業員表示 */
.workers-display {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    font-size: 9px;
    font-weight: 700;
}

.worker-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.worker-name.duplicate {
    color: #dc2626;
}

.placeholder-text {
    color: #9ca3af;
    font-weight: 400;
}

/* 特別行（工場、休み） */
.special-row {
    background: #f9fafb;
}

.special-label {
    font-weight: 600;
    padding-left: 8px !important;
}

/* 合計行 */
.total-row {
    background: #eff6ff;
}

.total-row td {
    border: 2px solid #9ca3af !important;
}

.total-label {
    font-weight: 700;
    padding-left: 8px !important;
}

.total-count {
    font-weight: 700;
    font-size: 10px;
    color: #2563eb;
    text-align: center;
}

.total-count.total-warning {
    color: #dc2626 !important;
    font-weight: 900;
}

/* リンク */
.address-link {
    color: #2563eb;
    text-decoration: underline;
}

/* ===================================
   モーダル
   =================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-small {
    width: 400px;
}

.modal-large {
    width: 800px;
    max-width: 100%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #1f2937;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.save-btn {
    flex: 1;
    padding: 12px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.save-btn:hover {
    background: #1d4ed8;
}

.cancel-btn {
    padding: 12px 20px;
    background: #e5e7eb;
    color: #374151;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: #d1d5db;
}

/* ===================================
   マスター管理モーダル
   =================================== */
.master-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 12px;
}

.master-tab {
    padding: 10px 20px;
    background: #f3f4f6;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.master-tab.active {
    background: #2563eb;
    color: white;
}

.master-tab:hover:not(.active) {
    background: #e5e7eb;
}

.master-tab-content {
    display: none;
}

.master-tab-content.active {
    display: block;
}

.master-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.master-list-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.master-actions {
    display: flex;
    gap: 8px;
}

.master-actions input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    width: 180px;
}

.add-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.add-btn:hover {
    background: #15803d;
}

.master-list {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}

.master-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
}

.master-item:last-child {
    border-bottom: none;
}

.master-item:hover {
    background: #f9fafb;
}

.master-item-name {
    font-weight: 500;
}

.master-item-actions {
    display: flex;
    gap: 8px;
}

.edit-btn {
    padding: 6px 10px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.edit-btn:hover {
    background: #2563eb;
}

.delete-btn {
    padding: 6px 10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.delete-btn:hover {
    background: #dc2626;
}

/* ===================================
   ログイン履歴テーブル
   =================================== */
.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.history-table th {
    background: #f3f4f6;
    font-weight: 600;
    font-size: 13px;
}

.history-table tbody tr:hover {
    background: #f9fafb;
}

.empty-message {
    text-align: center;
    padding: 32px;
    color: #9ca3af;
}

/* ===================================
   選択モーダル共通
   =================================== */
.modal-compact {
    width: 360px;
    max-width: 95%;
    max-height: 80vh;
}

.modal-body-no-scroll {
    padding: 16px;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.modal-footer .save-btn {
    flex: 1;
}

.modal-footer .cancel-btn {
    padding: 10px 16px;
}

/* 選択グリッド（作業員・担当者） */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.selection-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.selection-item:hover {
    background: #e0f2fe;
    border-color: #93c5fd;
}

.selection-item.selected {
    background: #dbeafe;
    border-color: #3b82f6;
}

.selection-item input[type="checkbox"],
.selection-item input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2563eb;
}

.selection-item label {
    cursor: pointer;
    flex: 1;
    font-weight: 500;
}

/* 単一選択用（担当者） */
.selection-single .selection-item {
    justify-content: center;
    text-align: center;
}

.selection-single .selection-item:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

.selection-single .selection-item.selected {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

/* リスト形式（時間・種別） */
.selection-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.selection-list .selection-item {
    padding: 12px 16px;
    justify-content: center;
    text-align: center;
    font-size: 14px;
}

.selection-list .selection-item:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

.selection-list .selection-item.selected {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

/* 配置職人選択用（複数選択、タップで選択） */
.worker-item {
    justify-content: space-between;
    padding: 12px 14px;
}

.worker-item .worker-name {
    font-weight: 500;
    flex: 1;
}

.worker-item .check-icon {
    opacity: 0;
    color: #2563eb;
    transition: opacity 0.15s;
}

.worker-item.selected {
    background: #dbeafe;
    border-color: #3b82f6;
}

.worker-item.selected .check-icon {
    opacity: 1;
}

.worker-item.selected .worker-name {
    color: #1d4ed8;
    font-weight: 600;
}

/* クリッカブルセル用 */
.cell-clickable {
    cursor: pointer;
}

.cell-clickable:hover {
    background: #e0f2fe;
}

.cell-display {
    font-size: 9px;
    padding: 2px;
    min-height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell-display.placeholder {
    color: #9ca3af;
}

/* ===================================
   レスポンシブ対応
   =================================== */
@media (max-width: 1024px) {
    .header {
        flex-direction: column;
        gap: 12px;
    }
    
    .header-left,
    .header-right {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .worker-checkboxes {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-large {
        width: 100%;
    }
}


