/* =====================================================
   shared-box.css
   共通共有フォルダーボックス専用スタイル
   （全工場⇔富井で見合える共有スペース）
===================================================== */

/* ========== 開閉ボタン（ヘッダー用） ========== */
/* 表示切り替えメモ: */
/* 表示する場合は display:none の行をコメントアウトまたは削除 */
/* 非表示にする場合は display:none を有効化 */

/* ヘッダーの中央ナビボタン群（追加工番・月間工程表・週間予定表・バックナンバー）
   を100px左に移動して、共有フォルダーボタンのスペースを確保 */
.header-nav-buttons {
  transform: translateX(-100px);
}

.btn-open-sharedbox {
  position: fixed;
  top: 15px;
  right: 15px;  /* 報告欄ボタンに重ねて配置（報告欄はそのまま残す） */
  z-index: 999;  /* モーダル(1000)より下に置き、モーダルの✕ボタンを押せるようにする */
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 140px;
  height: 50px;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-open-sharedbox:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.5);
  background: linear-gradient(135deg, #10b981, #059669);
}

.btn-open-sharedbox span:not(.sharedbox-badge) {
  font-size: 15px;
}

/* アイコン部分を他のナビボタンと同サイズに */
.btn-open-sharedbox .sharedbox-icon {
  font-size: 22px !important;
  line-height: 1;
}

.btn-open-sharedbox .sharedbox-label {
  font-size: 15px !important;
  font-weight: 700;
}

/* アイコン部分を大きく */
.btn-open-sharedbox::before {
  content: '';
  display: none;
}

.btn-open-sharedbox .sharedbox-badge {
  background: #fbbf24;
  color: #78350f;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* ========== パネル本体（右側スライドイン） ========== */
.sharedbox-panel {
  position: fixed;
  top: 0;
  right: -620px;
  width: 600px;
  max-width: 95vw;
  height: 100vh;
  background: #ffffff;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sharedbox-panel.open {
  right: 0;
}

/* ========== ヘッダー ========== */
.sharedbox-header {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sharedbox-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sharedbox-header-sub {
  font-size: 11px;
  opacity: 0.9;
  margin-top: 3px;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}

.sharedbox-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.sharedbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ========== ツールバー（アップロード/更新） ========== */
.sharedbox-toolbar {
  padding: 12px 16px;
  background: #f0fdf4;
  border-bottom: 1px solid #d1fae5;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.sharedbox-upload-btn {
  flex: 1;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.sharedbox-upload-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.sharedbox-refresh-btn {
  background: #fff;
  border: 1px solid #d1fae5;
  color: #059669;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.sharedbox-refresh-btn:hover {
  background: #f0fdf4;
  border-color: #059669;
}

.sharedbox-refresh-btn.spinning {
  animation: sharedbox-spin 1s linear;
}

@keyframes sharedbox-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ========== ドロップゾーン ========== */
.sharedbox-dropzone {
  margin: 12px 16px;
  padding: 20px;
  border: 2px dashed #a7f3d0;
  border-radius: 10px;
  text-align: center;
  color: #065f46;
  font-size: 13px;
  background: #f0fdf4;
  transition: all 0.2s;
  cursor: pointer;
  flex-shrink: 0;
}

.sharedbox-dropzone:hover {
  background: #d1fae5;
  border-color: #10b981;
}

.sharedbox-dropzone.dragging {
  background: #a7f3d0;
  border-color: #059669;
  border-style: solid;
  transform: scale(1.02);
}

.sharedbox-dropzone-icon {
  font-size: 26px;
  display: block;
  margin-bottom: 6px;
}

/* ========== 投稿者名入力 ========== */
.sharedbox-sender-row {
  padding: 0 16px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.sharedbox-sender-row label {
  font-size: 12px;
  color: #065f46;
  font-weight: 600;
  white-space: nowrap;
}

.sharedbox-sender-row input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d1fae5;
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
}

.sharedbox-sender-row input:focus {
  outline: none;
  border-color: #10b981;
}

/* ========== ファイルリスト（本棚エリア） ========== */
.sharedbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: linear-gradient(180deg, #fafbfc 0%, #f3f4f6 100%);
  scroll-behavior: smooth;
}

.sharedbox-list::-webkit-scrollbar {
  width: 8px;
}

.sharedbox-list::-webkit-scrollbar-track {
  background: transparent;
}

.sharedbox-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
  border: 2px solid #fafbfc;
}

.sharedbox-list::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ========== 検索バー ========== */
.sharedbox-search-row {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  align-items: center;
}

.sharedbox-search-input {
  flex: 1;
  padding: 7px 12px 7px 32px;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  font-size: 12px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 10px center;
  transition: all 0.15s;
}

.sharedbox-search-input:focus {
  outline: none;
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.sharedbox-filter-btn {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #6b7280;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.sharedbox-filter-btn:hover {
  border-color: #059669;
  color: #059669;
}

.sharedbox-filter-btn.active {
  background: #059669;
  border-color: #059669;
  color: #fff;
}

.sharedbox-count {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
  font-weight: 600;
}

/* ========== 空表示 ========== */
.sharedbox-empty {
  text-align: center;
  padding: 80px 20px;
  color: #9ca3af;
  font-size: 13px;
}

.sharedbox-empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.35;
}

/* ========== 棚セクション ========== */
.sharedbox-shelf {
  padding: 0 16px 24px;
}

.sharedbox-shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px 10px;
  position: sticky;
  top: 49px;
  background: linear-gradient(180deg, rgba(250, 251, 252, 0.98) 85%, transparent 100%);
  backdrop-filter: blur(6px);
  z-index: 5;
}

.sharedbox-shelf-title {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sharedbox-shelf-title::before {
  content: '';
  width: 4px;
  height: 14px;
  background: #059669;
  border-radius: 2px;
}

.sharedbox-shelf-count {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 600;
}

/* ========== 格子レイアウト（3列） ========== */
.sharedbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  /* 下部の「棚板」ライン */
  padding-bottom: 14px;
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, transparent 0%, #d1d5db 20%, #d1d5db 80%, transparent 100%) 1;
}

/* ========== ファイルカード（本） ========== */
.sharedbox-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: default;
  /* 本の影 */
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 0 0 1px rgba(0, 0, 0, 0.02);
}

.sharedbox-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.08),
    0 2px 6px rgba(5, 150, 105, 0.1);
  border-color: #a7f3d0;
}

.sharedbox-card.new-upload {
  animation: sharedbox-card-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-color: #10b981;
}

.sharedbox-card.new-upload::before {
  content: 'NEW';
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  z-index: 3;
  animation: sharedbox-pulse 1.5s ease-in-out infinite;
}

@keyframes sharedbox-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes sharedbox-card-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== サムネイル領域（本の表紙） ========== */
.sharedbox-card-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
}

.sharedbox-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.sharedbox-card-thumb:hover img {
  transform: scale(1.06);
}

.sharedbox-card-thumb .thumb-icon {
  font-size: 38px;
  opacity: 0.85;
}

/* ファイルタイプ別の表紙背景 */
.sharedbox-card-thumb.type-pdf {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}
.sharedbox-card-thumb.type-pdf .thumb-icon { color: #dc2626; }

.sharedbox-card-thumb.type-excel {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
}
.sharedbox-card-thumb.type-excel .thumb-icon { color: #059669; }

.sharedbox-card-thumb.type-word {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}
.sharedbox-card-thumb.type-word .thumb-icon { color: #2563eb; }

.sharedbox-card-thumb.type-ppt {
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
}
.sharedbox-card-thumb.type-ppt .thumb-icon { color: #d97706; }

.sharedbox-card-thumb.type-zip {
  background: linear-gradient(135deg, #f5f3ff 0%, #ddd6fe 100%);
}
.sharedbox-card-thumb.type-zip .thumb-icon { color: #7c3aed; }

.sharedbox-card-thumb.type-other {
  background: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
}
.sharedbox-card-thumb.type-other .thumb-icon { color: #6b7280; }

.sharedbox-card-thumb.type-image {
  background: #f3f4f6;
}

/* ホバー時のオーバーレイ（クリック可能なサムネイル） */
.sharedbox-card-thumb.clickable::after {
  content: '🔍 拡大';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
}

.sharedbox-card-thumb.clickable:hover::after {
  opacity: 1;
}

/* ファイル形式バッジ（右下） */
.sharedbox-type-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.95);
  color: #374151;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.sharedbox-type-badge.online {
  background: rgba(5, 150, 105, 0.95);
  color: #fff;
}

/* ========== カード本体（タイトル・メタ） ========== */
.sharedbox-card-body {
  padding: 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sharedbox-card-name {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-all;
  margin-bottom: 6px;
  min-height: 32px;
}

.sharedbox-card-meta {
  font-size: 10px;
  color: #9ca3af;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sharedbox-card-sender {
  color: #059669;
  font-weight: 600;
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sharedbox-card-date {
  font-size: 10px;
  color: #9ca3af;
}

.sharedbox-card-comment {
  font-size: 10px;
  color: #6b7280;
  margin-top: 6px;
  padding: 5px 7px;
  background: #fef3c7;
  border-radius: 5px;
  border-left: 2px solid #f59e0b;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ========== アクションボタン（下部） ========== */
.sharedbox-card-actions {
  display: flex;
  gap: 4px;
  padding: 0 10px 10px;
  justify-content: space-between;
}

.sharedbox-action-btn {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #4b5563;
  padding: 5px 0;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  text-align: center;
  white-space: nowrap;
}

.sharedbox-action-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.sharedbox-action-btn.primary {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #059669;
  color: #fff;
}

.sharedbox-action-btn.primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(5, 150, 105, 0.3);
}

.sharedbox-action-btn.danger {
  background: #fff;
  border-color: #fecaca;
  color: #dc2626;
  flex: 0 0 32px;
}

.sharedbox-action-btn.danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

/* ========== Online(Google Viewer)バッジ - 旧版用の互換 ========== */
.sharedbox-online-badge {
  display: none; /* 新デザインでは type-badge に統合 */
}

/* ========== レスポンシブ（モバイル） ========== */
@media (max-width: 600px) {
  .sharedbox-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .sharedbox-card-name {
    font-size: 11px;
  }
}

/* ========== アップロード進捗 ========== */
.sharedbox-progress {
  display: none;
  padding: 10px 16px;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  font-size: 12px;
  color: #1e40af;
  flex-shrink: 0;
}

.sharedbox-progress.active {
  display: block;
}

.sharedbox-progress-bar {
  height: 4px;
  background: #dbeafe;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.sharedbox-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  width: 0%;
  transition: width 0.3s;
}

/* ========== プレビュー用モーダル ========== */
.sharedbox-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.88);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: sharedbox-modal-fade 0.2s ease;
}

@keyframes sharedbox-modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sharedbox-preview-modal.active {
  display: flex;
}

.sharedbox-preview-content {
  background: #fff;
  border-radius: 12px;
  width: 95vw;
  height: 92vh;
  max-width: 1400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: sharedbox-modal-slide 0.25s ease;
}

@keyframes sharedbox-modal-slide {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.sharedbox-preview-header {
  padding: 12px 18px;
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

#sharedboxPreviewTitle {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 10px;
}

.sharedbox-preview-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.sharedbox-preview-download {
  background: #10b981;
  border: 1px solid #059669;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.sharedbox-preview-download:hover {
  background: #059669;
  transform: translateY(-1px);
}

.sharedbox-preview-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.sharedbox-preview-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sharedbox-preview-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1f2937;
  position: relative;
}

/* 画像プレビュー */
.sharedbox-preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

/* iframe (PDF/Office) */
.sharedbox-preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ローディング表示 */
.sharedbox-preview-loading {
  color: #fff;
  text-align: center;
  font-size: 14px;
  padding: 40px;
}

.sharedbox-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: sharedbox-spin-loader 0.8s linear infinite;
  margin: 0 auto 20px;
}

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

/* Google Viewer 表示中の注記 */
.sharedbox-preview-note {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 185, 129, 0.95);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  animation: sharedbox-note-in 0.4s ease;
}

@keyframes sharedbox-note-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== オーバーレイ ========== */
.sharedbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 999;
  display: none;
}

.sharedbox-overlay.active {
  display: block;
}

/* ========== レスポンシブ ========== */
@media (max-width: 768px) {
  .btn-open-sharedbox {
    right: 10px;
    top: auto;
    bottom: 80px;
    padding: 8px 14px;
    font-size: 12px;
  }
  
  .sharedbox-panel {
    width: 100vw;
    right: -100vw;
  }
}