/* ══════════════════════════════════════════════
   HR Dashboard — Document Management Styles
   ══════════════════════════════════════════════ */

/* ── Category Tabs ── */
.doc-category-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid #e5e7eb;
}

.doc-tab-btn {
  padding: 10px 24px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.doc-tab-btn:hover {
  color: #374151;
}

.doc-tab-btn.active {
  color: #2563eb;
}

.doc-tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #2563eb;
  border-radius: 2px 2px 0 0;
}

/* ── Toolbar ── */
.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.doc-search-wrapper {
  position: relative;
  flex: 1;
  min-width: 220px;
}

.doc-search-wrapper::before {
  content: "\1F50D";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0.5;
}

.doc-search {
  width: 100%;
  padding: 10px 14px 10px 36px;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.doc-search::placeholder {
  color: #94a3b8;
}

.doc-search:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.doc-btn-upload {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.doc-btn-upload:hover {
  background: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.doc-btn-upload:active {
  background: #1d4ed8;
  transform: scale(0.97);
}

/* ── Document Grid ── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ── Document Card ── */
.doc-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 22px 20px 18px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 2px 12px rgba(0, 0, 0, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.06);
}

.doc-card-icon {
  font-size: 2rem;
  line-height: 1;
}

.doc-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}

/* ── Category Badges ── */
.doc-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: fit-content;
}

.doc-badge--policy {
  background: #dbeafe;
  color: #1d4ed8;
}

.doc-badge--contract {
  background: #ede9fe;
  color: #6d28d9;
}

.doc-badge--legal {
  background: #ffedd5;
  color: #c2410c;
}

/* ── Card Meta ── */
.doc-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82rem;
  color: #64748b;
}

.doc-card-date,
.doc-card-size {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Card Actions ── */
.doc-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.doc-action-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.doc-action-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.doc-action-btn:active {
  transform: scale(0.92);
}

.doc-action-btn--view:hover {
  background: #eff6ff;
  border-color: #3b82f6;
}

.doc-action-btn--download:hover {
  background: #ecfdf5;
  border-color: #10b981;
}

.doc-action-btn--delete:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

/* ── Empty State ── */
.doc-empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.doc-empty-state span {
  display: block;
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.doc-empty-state p {
  margin: 0;
  color: #94a3b8;
}

/* ══════════════════════════════════════════════
   Modal Overlay (shared between upload & viewer)
   ══════════════════════════════════════════════ */
.doc-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: docModalFadeIn 0.2s ease-out;
}

@keyframes docModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes docModalSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Modal Card ── */
.doc-modal {
  position: relative;
  width: 100%;
  max-height: 90vh;
  margin: 1rem;
  padding: 0;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  overflow-y: auto;
  animation: docModalSlideIn 0.25s ease-out;
}

.doc-upload-modal {
  max-width: 520px;
}

.doc-viewer-modal {
  max-width: 800px;
}

.doc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.doc-modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.doc-modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-size: 1.15rem;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.doc-modal-close:hover {
  background: #f1f5f9;
  color: var(--text-primary);
}

.doc-modal-body {
  padding: 24px;
}

/* ══════════════════════════════════════════════
   Upload Modal — Drag-and-Drop Zone
   ══════════════════════════════════════════════ */
.doc-upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.doc-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.doc-dropzone:hover,
.doc-dropzone--active {
  border-color: #3b82f6;
  background: #eff6ff;
}

.doc-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.doc-dropzone-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.doc-dropzone-text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}

.doc-dropzone-hint {
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
}

.doc-selected-file {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: #3b82f6;
  min-height: 1.2rem;
}

/* ── Form Groups ── */
.doc-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.doc-form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

.doc-form-group input,
.doc-form-group select {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  box-sizing: border-box;
}

.doc-form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.doc-form-group input:focus,
.doc-form-group select:focus {
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* ── Upload Progress Bar ── */
.doc-progress-wrapper {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.doc-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  border-radius: 3px;
  transition: width 0.1s ease;
}

.doc-progress-bar--animating {
  animation: docProgressFill 2s ease forwards;
}

@keyframes docProgressFill {
  0%   { width: 0%; }
  20%  { width: 25%; }
  50%  { width: 55%; }
  75%  { width: 80%; }
  100% { width: 100%; }
}

/* ── Submit Button ── */
.doc-btn-submit {
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  background: #16a34a;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  align-self: flex-end;
}

.doc-btn-submit:hover {
  background: #15803d;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

.doc-btn-submit:active {
  background: #166534;
  transform: scale(0.97);
}

/* ══════════════════════════════════════════════
   Document Viewer Modal — Split Layout
   ══════════════════════════════════════════════ */
.doc-viewer-body {
  display: flex;
  min-height: 400px;
}

.doc-viewer-content {
  flex: 1;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border-color);
}

.doc-viewer-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
  max-width: 400px;
}

.doc-viewer-placeholder-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 16px;
  opacity: 0.5;
}

.doc-viewer-placeholder p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #94a3b8;
}

.doc-viewer-sidebar {
  width: 240px;
  padding: 24px;
  background: #f8fafc;
  flex-shrink: 0;
  border-radius: 0 0 16px 0;
}

.doc-viewer-sidebar h3 {
  margin: 0 0 18px 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-viewer-meta {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.doc-viewer-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-viewer-meta-item .meta-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
}

.doc-viewer-meta-item .meta-value {
  font-size: 0.9rem;
  color: #334155;
  font-weight: 500;
}

/* ══════════════════════════════════════════════
   Toast Notifications
   ══════════════════════════════════════════════ */
.doc-toast {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #ffffff;
  z-index: 10000;
  transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.doc-toast--success {
  background: #16a34a;
}

.doc-toast--error {
  background: #dc2626;
}

.doc-toast--visible {
  top: 24px;
}

/* ══════════════════════════════════════════════
   Dark Mode Overrides
   ══════════════════════════════════════════════ */
body.theme-dark .doc-card {
  background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), 0 2px 12px rgba(0, 0, 0, 0.15);
}

body.theme-dark .doc-card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

body.theme-dark .doc-card-title {
  color: var(--text-primary);
}

body.theme-dark .doc-card-actions {
  border-top-color: #475569;
}

body.theme-dark .doc-tab-btn {
  color: #94a3b8;
}

body.theme-dark .doc-tab-btn:hover {
  color: #e2e8f0;
}

body.theme-dark .doc-tab-btn.active {
  color: #60a5fa;
}

body.theme-dark .doc-tab-btn.active::after {
  background: #60a5fa;
}

body.theme-dark .doc-category-tabs {
  border-bottom-color: #475569;
}

body.theme-dark .doc-modal {
  background: var(--card-bg);
}

body.theme-dark .doc-modal-header {
  border-bottom-color: #475569;
}

body.theme-dark .doc-dropzone {
  border-color: #475569;
  background: #1e293b;
}

body.theme-dark .doc-dropzone:hover,
body.theme-dark .doc-dropzone--active {
  border-color: #60a5fa;
  background: #1e3a5f;
}

body.theme-dark .doc-dropzone-text {
  color: var(--text-primary);
}

body.theme-dark .doc-viewer-content {
  border-right-color: #475569;
}

body.theme-dark .doc-viewer-sidebar {
  background: #1e293b;
}

body.theme-dark .doc-viewer-sidebar h3 {
  color: #e2e8f0;
}

body.theme-dark .doc-viewer-meta-item .meta-value {
  color: #e2e8f0;
}

body.theme-dark .doc-badge--policy {
  background: #1e3a5f;
  color: #93c5fd;
}

body.theme-dark .doc-badge--contract {
  background: #2e1065;
  color: #c4b5fd;
}

body.theme-dark .doc-badge--legal {
  background: #431407;
  color: #fdba74;
}

/* ══════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .doc-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .doc-search-wrapper {
    min-width: auto;
  }

  .doc-btn-upload {
    width: 100%;
    text-align: center;
  }

  .doc-grid {
    grid-template-columns: 1fr;
  }

  .doc-viewer-body {
    flex-direction: column;
  }

  .doc-viewer-content {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    min-height: 200px;
  }

  .doc-viewer-sidebar {
    width: 100%;
    border-radius: 0 0 16px 16px;
  }

  .doc-modal {
    margin: 0.5rem;
    max-height: 95vh;
  }

  .doc-tab-btn {
    padding: 8px 16px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .doc-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .doc-card {
    padding: 16px;
  }

  .doc-category-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
