/**
 * 3D ArtDesk - Task Panel CSS
 * VERSIUNE CORECTATĂ - clasele corecte din JS
 */

/* === TASK PANEL BASE === */
.task-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.3s, opacity 0.3s;
}

.task-panel.open {
  visibility: visible;
  opacity: 1;
  transition: visibility 0s, opacity 0.3s;
}

/* === OVERLAY === */
.task-panel .panel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* === PANEL CONTAINER === */
.task-panel .panel-container {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 600px;
  max-width: 100vw;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.task-panel.open .panel-container {
  transform: translateX(0);
}

/* === PANEL HEADER === */
.task-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  background: #fafbfc;
  flex-shrink: 0;
}

.task-panel .panel-title-row {
  flex: 1;
  min-width: 0;
}

.task-panel .panel-task-title {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  word-break: break-word;
  line-height: 1.3;
}

.task-panel .panel-status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: #667eea;
}

.task-panel .panel-actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  flex-shrink: 0;
}

.task-panel .btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.task-panel .btn-icon:hover {
  background: #eee;
}

/* === PANEL TABS === */
.task-panel .panel-tabs {
  display: flex;
  border-bottom: 1px solid #eee;
  background: #fff;
  padding: 0 12px;
  overflow-x: auto;
  flex-shrink: 0;
}

.task-panel .panel-tab {
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-panel .panel-tab:hover {
  color: #333;
  background: #f5f5f5;
}

.task-panel .panel-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  font-weight: 600;
}

.task-panel .panel-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

.task-panel .panel-tab-badge:empty {
  display: none;
}

/* === PANEL CONTENT === */
.task-panel .panel-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* === LOADING STATE === */
.task-panel .panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #999;
  font-size: 14px;
  gap: 12px;
}

.task-panel .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #eee;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.task-panel .panel-error {
  padding: 40px 20px;
  text-align: center;
  color: #e74c3c;
}

/* === CHAT TAB === */
.task-panel .panel-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.task-panel .chat-search {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.task-panel .chat-search input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #f9f9f9;
}

.task-panel .chat-search input:focus {
  outline: none;
  border-color: #667eea;
  background: #fff;
}

/* === CHAT MESSAGES CONTAINER === */
.task-panel .chat-messages,
.task-panel #panelChatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
}

.task-panel .chat-empty {
  text-align: center;
  color: #999;
  padding: 60px 20px;
  font-size: 15px;
}

/* === CHAT MESSAGE - CLASELE CORECTE DIN JS === */
.task-panel .chat-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  align-items: flex-start;
}

/* Mesajele proprii - aliniate la dreapta */
.task-panel .chat-message.own {
  margin-left: auto;
  flex-direction: row-reverse;
}

/* Avatar - clasa din JS: msg-avatar */
.task-panel .chat-message .msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

.task-panel .chat-message .msg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.task-panel .chat-message.own .msg-avatar {
  background: linear-gradient(135deg, #11998e, #38ef7d);
}

/* Message body - clasa din JS: msg-body */
.task-panel .chat-message .msg-body {
  padding: 10px 14px;
  background: #fff;
  border-radius: 16px;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  max-width: 100%;
  min-width: 100px;
}

.task-panel .chat-message.own .msg-body {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
}

/* Message header - clasa din JS: msg-header */
.task-panel .chat-message .msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 12px;
}

/* Author name - clasa din JS: msg-author */
.task-panel .chat-message .msg-author {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.task-panel .chat-message.own .msg-author {
  color: rgba(255,255,255,0.9);
}

/* Time - clasa din JS: msg-time */
.task-panel .chat-message .msg-time {
  font-size: 11px;
  color: #999;
}

.task-panel .chat-message.own .msg-time {
  color: rgba(255,255,255,0.7);
}

/* Message content - clasa din JS: msg-content */
.task-panel .chat-message .msg-content {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.task-panel .chat-message .msg-content p {
  margin: 0 0 8px 0;
}

.task-panel .chat-message .msg-content p:last-child {
  margin-bottom: 0;
}

.task-panel .chat-message .msg-content img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
  display: block;
  cursor: pointer;
}

.task-panel .chat-message .msg-content a {
  color: #667eea;
  text-decoration: underline;
}

.task-panel .chat-message.own .msg-content a {
  color: #fff;
}

/* Mentions în mesaje */
.task-panel .chat-message .msg-content .mention,
.task-panel .chat-message .msg-content [data-mention],
.task-panel .chat-message .msg-content span[style*="color: rgb(102, 126, 234)"] {
  background: rgba(102, 126, 234, 0.15);
  color: #667eea !important;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.task-panel .chat-message.own .msg-content .mention,
.task-panel .chat-message.own .msg-content [data-mention],
.task-panel .chat-message.own .msg-content span[style*="color: rgb(102, 126, 234)"] {
  background: rgba(255,255,255,0.25);
  color: #fff !important;
}

/* Files în mesaje - clasa din JS: msg-files */
.task-panel .chat-message .msg-files {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-panel .chat-message .msg-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  font-size: 12px;
  color: #555;
  text-decoration: none;
  transition: background 0.2s;
}

.task-panel .chat-message .msg-file:hover {
  background: rgba(0,0,0,0.1);
}

.task-panel .chat-message.own .msg-file {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.task-panel .chat-message.own .msg-file:hover {
  background: rgba(255,255,255,0.3);
}

/* === CHAT INPUT AREA === */
.task-panel .chat-input-area {
  border-top: 1px solid #eee;
  padding: 12px 16px 16px;
  background: #fff;
  flex-shrink: 0;
}

.task-panel .chat-editor,
.task-panel #panelChatEditor {
  min-height: 50px;
  max-height: 150px;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #f9f9f9;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.5;
}

.task-panel .chat-editor:focus,
.task-panel #panelChatEditor:focus {
  outline: none;
  border-color: #667eea;
  background: #fff;
}

.task-panel .chat-editor:empty:before,
.task-panel #panelChatEditor:empty:before {
  content: attr(placeholder);
  color: #999;
}

.task-panel .chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 12px;
}

.task-panel .chat-toolbar {
  display: flex;
  gap: 4px;
}

.task-panel .chat-toolbar button {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.2s;
}

.task-panel .chat-toolbar button:hover {
  background: #f0f0f0;
}

.task-panel .chat-hint {
  font-size: 12px;
  color: #999;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
}

.task-panel .chat-hint span:first-child {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-panel .btn-send {
  padding: 10px 24px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.task-panel .btn-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.task-panel .btn-send:active {
  transform: translateY(0);
}

/* === DETAILS TAB === */
.task-panel .panel-details {
  padding: 20px;
  overflow-y: auto;
}

.task-panel .detail-section {
  margin-bottom: 24px;
}

.task-panel .detail-section h4 {
  margin: 0 0 12px 0;
  font-size: 12px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.task-panel .detail-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  align-items: flex-start;
}

.task-panel .detail-row:last-child {
  border-bottom: none;
}

.task-panel .detail-label {
  width: 120px;
  font-size: 13px;
  color: #666;
  flex-shrink: 0;
}

.task-panel .detail-value {
  flex: 1;
  font-size: 14px;
  color: #333;
}

.task-panel .detail-value a {
  color: #667eea;
  text-decoration: none;
}

.task-panel .detail-value a:hover {
  text-decoration: underline;
}

/* Description */
.task-panel .task-description {
  background: #f9f9f9;
  border-radius: 8px;
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.task-panel .task-description:empty::before {
  content: 'Fără descriere';
  color: #999;
  font-style: italic;
}

/* === FILES TAB === */
.task-panel .panel-files {
  padding: 16px;
  overflow-y: auto;
}

.task-panel .files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.task-panel .files-header span {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.task-panel .files-header .btn {
  padding: 8px 14px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.task-panel .files-header .btn:hover {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
}

/* Files list layout */
.task-panel .files-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* File item - row style */
.task-panel .file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(145deg, #ffffff, #fafafa);
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  transition: all 0.2s;
}

.task-panel .file-item:hover {
  border-color: #667eea;
  background: linear-gradient(145deg, #f8f9ff, #fff);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
  transform: translateX(4px);
}

.task-panel .file-item .file-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.task-panel .file-item .file-info {
  flex: 1;
  min-width: 0;
}

.task-panel .file-item .file-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  text-decoration: none;
  margin-bottom: 2px;
  word-break: break-word;
}

.task-panel .file-item .file-name:hover {
  color: #667eea;
}

.task-panel .file-item .file-meta {
  font-size: 12px;
  color: #999;
}

.task-panel .file-item .file-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.task-panel .file-item:hover .file-actions {
  opacity: 1;
}

.task-panel .file-item .file-actions .btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: #f0f0f0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.2s;
}

.task-panel .file-item .file-actions .btn-icon:hover {
  background: #667eea;
  color: #fff;
}

.task-panel .file-item .file-actions .btn-danger:hover {
  background: #e74c3c;
}

/* Files empty state */
.task-panel .files-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 14px;
}

/* === GRID LAYOUT (alternativ) === */
.task-panel .files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.task-panel .file-card {
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(145deg, #ffffff, #f5f5f5);
}

.task-panel .file-card:hover {
  border-color: #667eea;
  background: linear-gradient(145deg, #f8f9ff, #fff);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.15);
}

.task-panel .file-card .file-icon {
  font-size: 42px;
  margin-bottom: 12px;
  display: block;
}

.task-panel .file-card .file-name {
  font-size: 13px;
  color: #333;
  word-break: break-word;
  margin-bottom: 6px;
  font-weight: 500;
  line-height: 1.3;
}

.task-panel .file-card .file-size {
  font-size: 11px;
  color: #999;
}

/* === HISTORY TAB === */
.task-panel .panel-history {
  padding: 16px;
  overflow-y: auto;
}

.task-panel .history-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid #f0f0f0;
}

.task-panel .history-item:last-child {
  border-bottom: none;
}

.task-panel .history-icon {
  width: 36px;
  height: 36px;
  background: #f5f5f5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.task-panel .history-body {
  flex: 1;
}

.task-panel .history-user {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.task-panel .history-action {
  color: #666;
  font-size: 14px;
}

.task-panel .history-change {
  margin-top: 6px;
  font-size: 13px;
  color: #666;
  background: #f9f9f9;
  padding: 8px 12px;
  border-radius: 6px;
}

.task-panel .history-change .old {
  text-decoration: line-through;
  color: #e74c3c;
}

.task-panel .history-change .new {
  color: #27ae60;
  font-weight: 500;
}

.task-panel .history-time {
  display: block;
  font-size: 12px;
  color: #999;
  margin-top: 6px;
}

.task-panel .history-empty {
  text-align: center;
  color: #999;
  padding: 60px 20px;
  font-size: 15px;
}

/* === UPLOAD AREA === */
.task-panel .upload-area {
  border: 2px dashed #ddd;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  color: #999;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 16px;
}

.task-panel .upload-area:hover {
  border-color: #667eea;
  background: #f8f9ff;
  color: #667eea;
}

.task-panel .upload-area.dragover {
  border-color: #667eea;
  background: #f0f4ff;
}

/* === BODY WHEN PANEL OPEN === */
body.panel-open {
  overflow: hidden;
}

/* === DRAFT INDICATOR === */
.draft-indicator {
  color: #f39c12;
  margin-left: 4px;
  font-size: 12px;
}

/* === MOBILE === */
@media (max-width: 640px) {
  .task-panel .panel-container {
    width: 100vw;
  }
  
  .task-panel .chat-message {
    max-width: 90%;
  }
  
  .task-panel .panel-header {
    padding: 12px 16px;
  }
  
  .task-panel .panel-task-title {
    font-size: 16px;
  }
}

/* === SCROLLBAR STYLING === */
.task-panel .chat-messages::-webkit-scrollbar,
.task-panel #panelChatMessages::-webkit-scrollbar,
.task-panel .panel-details::-webkit-scrollbar,
.task-panel .panel-files::-webkit-scrollbar,
.task-panel .panel-history::-webkit-scrollbar {
  width: 6px;
}

.task-panel .chat-messages::-webkit-scrollbar-track,
.task-panel #panelChatMessages::-webkit-scrollbar-track,
.task-panel .panel-details::-webkit-scrollbar-track,
.task-panel .panel-files::-webkit-scrollbar-track,
.task-panel .panel-history::-webkit-scrollbar-track {
  background: transparent;
}

.task-panel .chat-messages::-webkit-scrollbar-thumb,
.task-panel #panelChatMessages::-webkit-scrollbar-thumb,
.task-panel .panel-details::-webkit-scrollbar-thumb,
.task-panel .panel-files::-webkit-scrollbar-thumb,
.task-panel .panel-history::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

.task-panel .chat-messages::-webkit-scrollbar-thumb:hover,
.task-panel #panelChatMessages::-webkit-scrollbar-thumb:hover,
.task-panel .panel-details::-webkit-scrollbar-thumb:hover,
.task-panel .panel-files::-webkit-scrollbar-thumb:hover,
.task-panel .panel-history::-webkit-scrollbar-thumb:hover {
  background: #ccc;
}

/* === Imagini clickable === */
.chat-img-clickable {
  cursor: pointer;
  transition: opacity 0.2s;
}

.chat-img-clickable:hover {
  opacity: 0.9;
}