/* home.css — Styles de la page d'accueil */
.home-container {
  min-height: 100vh;
  background: #f8f9fa;
  font-family: 'Google Sans', 'Roboto', sans-serif;
}

/* Header */
.home-header {
  background: white;
  border-bottom: 1px solid #e0e0e0;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.home-header .logo {
  font-size: 22px;
  font-weight: 600;
  color: #1a73e8;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-header .search-bar {
  flex: 1;
  max-width: 500px;
  padding: 10px 20px;
  border-radius: 24px;
  border: 1px solid #ddd;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8f9fa;
}

.home-header .search-bar:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
  background: white;
}

.home-header.search-active .search-bar {
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Search counter */
.search-counter {
  position: absolute;
  right: 540px;
  top: 22px;
  font-size: 12px;
  color: #5f6368;
  background: #e8f0fe;
  padding: 2px 8px;
  border-radius: 12px;
}

/* Actions buttons */
.home-header .actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.btn-new {
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-new:hover {
  background: #1557b0;
  box-shadow: 0 2px 6px rgba(26, 115, 232, 0.3);
}

.btn-secondary {
  background: white;
  color: #1a73e8;
  border: 1px solid #dadce0;
}

.btn-secondary:hover {
  background: #f8f9fa;
  border-color: #1a73e8;
}

/* Controls bar (sort, filter, view toggle) */
.home-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
}

.view-toggle {
  display: flex;
  border: 1px solid #dadce0;
  border-radius: 6px;
  overflow: hidden;
}

.view-btn {
  border: none;
  background: white;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.2s;
  color: #5f6368;
}

.view-btn:hover {
  background: #f1f3f4;
}

.view-btn.active {
  background: #e8f0fe;
  color: #1a73e8;
}

.sort-select,
.filter-select {
  border: 1px solid #dadce0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  background: white;
  color: #3c4043;
  cursor: pointer;
  outline: none;
}

.sort-select:focus,
.filter-select:focus {
  border-color: #1a73e8;
}

/* Grid layout */
.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

/* List layout */
.documents-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

/* Card styles — Grid mode */
.folder-card,
.document-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  border: 1px solid #f0f0f0;
  position: relative;
  user-select: none;
}

.folder-card:hover,
.document-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.folder-card:active,
.document-card:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Folder card */
.folder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 120px;
  justify-content: center;
  background: #fefefe;
}

.folder-card .material-icons {
  font-size: 48px;
  color: #5f6368;
  margin-bottom: 8px;
  transition: color 0.2s;
}

.folder-card:hover .material-icons {
  color: #1a73e8;
}

.folder-card.open {
  background: #e8f0fe;
  border-color: #1a73e8;
}

.folder-card.open .material-icons {
  color: #1a73e8;
}

.folder-info {
  text-align: center;
}

.folder-name {
  font-weight: 500;
  font-size: 14px;
  color: #202124;
  margin-bottom: 2px;
}

.folder-meta {
  font-size: 12px;
  color: #5f6368;
}

/* Document card — Grid mode */
.document-card {
  display: flex;
  flex-direction: column;
  min-height: 160px;
}

.doc-preview {
  font-size: 12px;
  color: #5f6368;
  line-height: 1.4;
  flex: 1;
  overflow: hidden;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.doc-info {
  border-top: 1px solid #f0f0f0;
  padding-top: 8px;
}

.doc-title {
  font-weight: 500;
  font-size: 14px;
  color: #202124;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta {
  font-size: 12px;
  color: #5f6368;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.doc-folder-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #e8f0fe;
  color: #1a73e8;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Document card in list mode */
.documents-list .document-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
  min-height: auto;
  border-radius: 8px;
}

.documents-list .doc-preview {
  flex: 1;
  margin-bottom: 0;
  margin-right: 16px;
  -webkit-line-clamp: 1;
}

.documents-list .doc-info {
  border-top: none;
  padding-top: 0;
  min-width: 200px;
  text-align: right;
}

/* Document card in folder */
.document-card.in-folder {
  margin: 4px 0;
  min-height: auto;
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid #e8eaed;
}

.document-card.in-folder .doc-preview {
  -webkit-line-clamp: 2;
  margin-bottom: 6px;
}

/* Folder content */
.folder-content {
  grid-column: 1 / -1;
  padding: 8px 0 0 0;
  animation: slideDown 0.2s ease;
}

.folder-content .document-card {
  margin-bottom: 8px;
}

.folder-empty {
  text-align: center;
  color: #999;
  font-size: 13px;
  padding: 20px;
  font-style: italic;
}

/* Inline edit */
.inline-edit-input {
  border: 2px solid #1a73e8;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  width: 100%;
  background: white;
}

.inline-edit-input:focus {
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #5f6368;
}

.empty-state h2 {
  font-size: 20px;
  font-weight: 500;
  color: #202124;
  margin: 16px 0 8px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 24px;
}

.btn-create-first {
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 24px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.btn-create-first:hover {
  background: #1557b0;
}

/* Drag & Drop */
.drag-placeholder {
  background: #e8f0fe;
  border: 2px dashed #1a73e8;
  border-radius: 12px;
  min-height: 160px;
  transition: all 0.2s;
}

.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.drop-target {
  border-color: #1a73e8 !important;
  background: #e8f0fe !important;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.3) !important;
}

.drop-success {
  animation: dropSuccess 0.6s ease;
}

@keyframes dropSuccess {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); background: #e8f0fe; }
  100% { transform: scale(1); }
}

/* Search highlight */
mark.search-highlight {
  background: #fdd663;
  color: inherit;
  padding: 1px 2px;
  border-radius: 2px;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  min-width: 200px;
  padding: 6px 0;
  z-index: 10000;
  animation: contextMenuEnter 0.15s ease;
  font-size: 13px;
}

.context-menu-enter {
  animation: contextMenuEnter 0.15s ease;
}

.context-menu-exit {
  animation: contextMenuExit 0.15s ease forwards;
}

@keyframes contextMenuEnter {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes contextMenuExit {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.95); }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
  color: #3c4043;
  position: relative;
}

.context-menu-item:hover {
  background: #f1f3f4;
}

.context-menu-item.danger {
  color: #d93025;
}

.context-menu-item.danger:hover {
  background: #fce8e6;
}

.context-menu-icon {
  font-size: 18px;
  color: #5f6368;
}

.context-menu-item.danger .context-menu-icon {
  color: #d93025;
}

.context-menu-label {
  flex: 1;
}

.context-menu-arrow {
  font-size: 16px;
  color: #999;
}

.context-menu-separator {
  height: 1px;
  background: #e0e0e0;
  margin: 4px 0;
}

/* Context submenu */
.context-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  min-width: 180px;
  padding: 6px 0;
  z-index: 10001;
}

.context-menu-item:hover .context-submenu {
  display: block;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .home-header {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .home-header .search-bar {
    max-width: 100%;
    order: 3;
    margin: 8px 0 0 0;
  }

  .home-controls {
    order: 4;
    width: 100%;
    margin-top: 8px;
    margin-right: 0;
    flex-wrap: wrap;
  }

  .documents-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    padding: 12px;
    gap: 10px;
  }

  .folder-card .material-icons {
    font-size: 36px;
  }

  .document-card {
    min-height: 130px;
    padding: 12px;
  }
}

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

  .home-header .actions {
    flex-wrap: wrap;
  }

  .btn-new {
    padding: 8px 14px;
    font-size: 13px;
  }
}
