/* ================================================
   FIMF CLOUD - LAYOUT
   ================================================ */

/* APP SHELL */
.app { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
.sidebar {
  width: 260px; background: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  transition: width var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  z-index: 50; flex-shrink: 0;
}
.sidebar-header {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--sp-3);
}
.sidebar-logo {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: var(--fw-extrabold); font-size: var(--fs-lg);
  flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.sidebar-title { font-size: var(--fs-md); font-weight: var(--fw-bold); letter-spacing: -.01em; }
.sidebar-subtitle { font-size: var(--fs-xs); color: var(--text-muted); }
.sidebar-nav { flex: 1; padding: var(--sp-3) var(--sp-3); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-1); }
.nav-section { margin-top: var(--sp-3); }
.nav-section:first-child { margin-top: 0; }
.nav-section-title { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; padding: var(--sp-1) var(--sp-3); margin-bottom: var(--sp-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-md);
  font-size: var(--fs-sm); color: var(--text-secondary);
  transition: var(--tr-colors); position: relative; cursor: pointer;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-muted); color: var(--accent); font-weight: var(--fw-medium);
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item-badge {
  margin-left: auto; background: var(--accent); color: var(--text-inverse);
  padding: 1px 6px; border-radius: var(--radius-full); font-size: 10px; font-weight: var(--fw-bold);
}
.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
}
.sidebar-user {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2);
  border-radius: var(--radius-md); cursor: pointer; transition: var(--tr-colors);
}
.sidebar-user:hover { background: var(--surface-hover); }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: var(--fs-xs); color: var(--text-muted); text-transform: capitalize; }

/* MAIN CONTENT */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* TOPBAR */
.topbar {
  height: 56px; display: flex; align-items: center; padding: 0 var(--sp-5);
  background: var(--topbar-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--sp-3); flex-shrink: 0; z-index: 40;
}
.topbar-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }
.menu-toggle { display: none; }

/* CONTENT */
.content { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-5); gap: var(--sp-3); flex-wrap: wrap; }
.content-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); }

/* FILE MANAGER TOOLBAR */
.fm-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.fm-toolbar-actions { display: flex; gap: var(--sp-2); align-items: center; flex-shrink: 0; }
.fm-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border-radius: var(--radius-md); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-primary);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.fm-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.fm-btn svg { width: 14px; height: 14px; }
.fm-btn-primary { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }
.fm-btn-primary:hover { background: var(--accent-hover); }
.fm-btn-secondary { background: var(--bg-muted); }
.fm-btn-danger { color: var(--danger); }
.fm-btn-danger:hover { background: rgba(239,68,68,.1); border-color: var(--danger); }
.fm-sel-count { font-size: var(--fs-sm); color: var(--text-muted); padding: 0 8px; }

/* BREADCRUMB */
.fm-breadcrumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.fm-breadcrumb span { font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: all .1s; }
.fm-breadcrumb span:hover { background: var(--surface-hover); color: var(--text-primary); }
.fm-breadcrumb span.current { color: var(--text-primary); font-weight: var(--fw-medium); cursor: default; }
.fm-breadcrumb span.current:hover { background: none; }
.fm-breadcrumb .sep { color: var(--text-muted); cursor: default; padding: 0 2px; font-size: var(--fs-xs); }
.fm-breadcrumb .sep:hover { background: none; }

/* EMPTY STATE */
.fm-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--sp-12); color: var(--text-muted); }
.fm-empty svg { width: 64px; height: 64px; margin-bottom: var(--sp-4); opacity: .4; }
.fm-empty p { font-size: var(--fs-md); }

/* FILE GRID */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2); }
.file-card {
  display: flex; flex-direction: column; align-items: center; padding: var(--sp-3);
  border-radius: var(--radius-md); border: 1px solid transparent;
  cursor: default; transition: all .1s; position: relative; user-select: none;
}
.file-card:hover { background: var(--surface-hover); border-color: var(--border-subtle); }
.file-card.selected { background: var(--accent-muted); border-color: var(--accent); }
.file-card.dragging { opacity: .3; border-style: dashed; }
.file-card.drag-over { background: var(--accent-muted); border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.file-card.drop-before { border-top: 2px solid var(--accent); }
.file-card.drop-after { border-bottom: 2px solid var(--accent); }
.file-card-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: var(--sp-2);
}
.file-card-icon svg { width: 28px; height: 28px; }
.file-card-icon.folder { background: var(--warning-muted); color: var(--warning); }
.file-card-avatar {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: var(--fw-bold); font-size: var(--fs-md);
}
.file-card-avatar-sm {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: var(--fw-bold); font-size: 10px; flex-shrink: 0;
}
.file-card-icon.image { background: rgba(168, 85, 247, .12); color: #a855f7; }
.file-card-icon.video { background: rgba(239, 68, 68, .12); color: var(--danger); }
.file-card-icon.audio { background: rgba(236, 72, 153, .12); color: #ec4899; }
.file-card-icon.document { background: var(--info-muted); color: var(--info); }
.file-card-icon.archive { background: rgba(168, 162, 158, .12); color: #a8a29e; }
.file-card-icon.code { background: rgba(34, 197, 94, .12); color: #22c55e; }
.file-card-icon.other { background: var(--success-muted); color: var(--success); }
.file-card-name {
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%; text-align: center; margin-bottom: 2px;
}
.file-card-meta { font-size: 11px; color: var(--text-muted); }

/* FILE LIST */
.file-list { display: flex; flex-direction: column; }
.file-list-header {
  display: grid; grid-template-columns: 1fr 100px 120px;
  gap: var(--sp-3); padding: 6px 12px;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border-subtle);
}
.file-list-item {
  display: grid; grid-template-columns: 1fr 100px 120px;
  gap: var(--sp-3); padding: 8px 12px;
  border-radius: var(--radius-md); cursor: default;
  transition: background .1s; align-items: center; user-select: none;
}
.file-list-item:hover { background: var(--surface-hover); }
.file-list-item.selected { background: var(--accent-muted); }
.file-list-item.dragging { opacity: .3; }
.file-list-item.drag-over { background: var(--accent-muted); box-shadow: inset 0 0 0 2px var(--accent); }
.file-list-item.drop-before { border-top: 2px solid var(--accent); }
.file-list-item.drop-after { border-bottom: 2px solid var(--accent); }
.file-list-name { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); min-width: 0; }
.file-list-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-icon-sm { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-muted); }
.file-icon-sm svg { width: 16px; height: 16px; }
.file-list-size, .file-list-modified { font-size: var(--fs-sm); color: var(--text-secondary); }

/* BREADCRUMB */
.breadcrumb { display: flex; align-items: center; gap: var(--sp-1); flex-wrap: wrap; }
.breadcrumb-item { font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer; transition: var(--tr-colors); }
.breadcrumb-item:hover { color: var(--text-primary); }
.breadcrumb-item.current { color: var(--text-primary); font-weight: var(--fw-medium); cursor: default; }
.breadcrumb-sep { color: var(--text-muted); font-size: var(--fs-xs); }

/* CHECKBOXES */
.file-card-check, .file-list-check, .fm-check-all {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 2;
}
.file-card-check { position: absolute; top: 8px; left: 8px; }
.file-list-check { margin-right: 8px; flex-shrink: 0; }
.file-card-check input, .file-list-check input, .fm-check-all input {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent);
  position: relative; z-index: 2; margin: 0;
}
.file-card.selected .file-card-check input,
.file-list-item.selected .file-list-check input { accent-color: var(--accent); }
.fm-check-all { margin-right: 8px; }
.fm-check-all input { width: 16px; height: 16px; }
.file-cut { opacity: 0.35; }
.file-cut .file-card-icon { filter: grayscale(1); }

/* DRAG & DROP */
.fm-drop-active {
  outline: 2px dashed var(--accent) !important;
  outline-offset: -4px;
  background: var(--accent-muted) !important;
}
.fm-drop-hint {
  background: rgba(99, 102, 241, 0.25);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-md);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.3);
  pointer-events: none;
  z-index: 5;
}
.fm-drop-placeholder {
  background: rgba(99, 102, 241, 0.12);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-md);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.2);
  pointer-events: none;
  flex-shrink: 0;
  animation: placeholderPulse 1.5s ease-in-out infinite;
  transition: width 0.2s ease, height 0.2s ease;
}
@keyframes placeholderPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(99, 102, 241, 0.15); }
  50% { box-shadow: 0 0 24px rgba(99, 102, 241, 0.35); }
}
.fm-grid-dragging {
  position: relative;
}
.fm-grid-dragging > [data-name]:not(.dragging):not(.fm-drop-placeholder) {
  transition: transform 0.25s cubic-bezier(.25,.8,.25,1);
}
.fm-rubber-band {
  background: rgba(99, 102, 241, 0.08);
  border: 1.5px solid rgba(99, 102, 241, 0.5);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.1), 0 2px 8px rgba(0,0,0,0.1);
  transition: none;
  will-change: left, top, width, height;
}
.file-card.selected, .file-list-item.selected {
  border-color: var(--accent) !important;
  background: var(--accent-muted) !important;
}
.fm-drag-ghost {
  background: var(--bg-raised); border: 1px solid var(--accent);
  border-radius: var(--radius-md); padding: 8px 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45), 0 0 0 1px var(--accent); font-size: var(--fs-sm);
  display: flex; align-items: center; gap: 8px;
}
.fm-grid-dragging { user-select: none; }
.fm-grid-dragging > [data-name] { transition: transform 0.22s cubic-bezier(.25,.8,.25,1), opacity 0.18s ease; }
.file-card.dragging, .file-list-item.dragging {
  opacity: 0.25 !important;
  border-style: dashed !important;
  border-color: var(--accent) !important;
  box-shadow: none !important;
  pointer-events: none;
  transition: opacity 0.2s ease !important;
}
.file-card.dragging *, .file-list-item.dragging * { pointer-events: none; }
.file-card.drag-over, .file-list-item.drag-over {
  border-color: var(--accent) !important;
  background: var(--accent-muted) !important;
  box-shadow: 0 0 0 3px var(--accent), 0 0 20px rgba(99, 102, 241, 0.3) !important;
  transform: scale(1.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.file-card.drag-over[data-dir="true"], .file-list-item.drag-over[data-dir="true"] {
  background: rgba(99, 102, 241, 0.18) !important;
  box-shadow: 0 0 0 3px var(--accent), 0 0 24px rgba(99, 102, 241, 0.4), inset 0 0 12px rgba(99, 102, 241, 0.15) !important;
}
.file-card.drag-over[data-dir="true"]::after, .file-list-item.drag-over[data-dir="true"]::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white' stroke-width='3'%3E%3Cpath d='M5 12h14M12 5l7 7-7 7'/%3E%3C/svg%3E");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* STORAGE BAR */
.storage-info { display: flex; flex-direction: column; gap: var(--sp-2); }
.storage-info-row { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--text-secondary); }
.storage-info-row strong { color: var(--text-primary); font-weight: var(--fw-semibold); }

/* AUTH SCREENS */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-base); padding: var(--sp-4);
}
.auth-card {
  background: var(--bg-raised); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); padding: var(--sp-8);
  width: 100%; max-width: 400px; box-shadow: var(--shadow-xl);
}
.auth-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: var(--sp-8); }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-4); }

/* CHAT */
.chat-layout { display: flex; height: 100%; }
.chat-sidebar { width: 240px; border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column; }
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.chat-input-area { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--sp-2); }
.chat-input-area input { flex: 1; }
.message { display: flex; gap: var(--sp-3); padding: var(--sp-1) 0; animation: fadeUp var(--dur-fast) var(--ease); }
.message-content { flex: 1; min-width: 0; }
.message-header { display: flex; align-items: baseline; gap: var(--sp-2); margin-bottom: 2px; }
.message-author { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.message-time { font-size: var(--fs-xs); color: var(--text-muted); }
.message-text { font-size: var(--fs-sm); color: var(--text-secondary); word-break: break-word; }

/* GROUP LIST */
.group-card {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--radius-md);
  cursor: pointer; transition: var(--tr-colors);
}
.group-card:hover { background: var(--surface-hover); }
.group-card.active { background: var(--accent-muted); }
.group-icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--accent-muted); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.group-info { flex: 1; min-width: 0; }
.group-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-meta { font-size: var(--fs-xs); color: var(--text-muted); }

/* FRIENDS */
.friend-card {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}
.friend-card:hover { border-color: var(--border-default); }
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.friend-status { font-size: var(--fs-xs); color: var(--text-muted); }
.friend-actions { display: flex; gap: var(--sp-2); }

/* ADMIN */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-5); }
.stat-card {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-5); border-radius: var(--radius-lg);
  background: var(--bg-raised); border: 1px solid var(--border-subtle);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-info { flex: 1; }
.stat-value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1.2; }
.stat-label { font-size: var(--fs-xs); color: var(--text-muted); }

/* TABLE */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
  text-align: left; border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; background: var(--bg-raised); z-index: 1;
}
.data-table td {
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border-subtle);
}
.data-table tr:hover td { background: var(--surface-hover); }

/* RESPONSIVE */
@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); z-index: 100; }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; }
  .sidebar.open ~ .sidebar-overlay { display: block; }
  .menu-toggle { display: flex; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .file-list-header, .file-list-item { grid-template-columns: 1fr 80px 60px; }
  .file-list-modified { display: none; }
  .chat-sidebar { width: 200px; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .content { padding: var(--sp-3); }
  .topbar { padding: 0 var(--sp-3); }
  .chat-layout { flex-direction: column; }
  .chat-sidebar { width: 100%; height: auto; max-height: 200px; border-right: none; border-bottom: 1px solid var(--border-subtle); }
  .content-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 480px) {
  .auth-card { padding: var(--sp-5); }
  .file-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
  .stat-card { flex-direction: column; text-align: center; }
  .topbar-actions .btn span { display: none; }
}
