/* ============================================================================
   APROGSYS Project Manager - Dark Theme
   ============================================================================ */

:root {
  --bg: #1e1e24;
  --bg-card: #27272f;
  --bg-light: #2f2f38;
  --bg-hover: #38383f;
  --bg-input: #1a1a20;
  --border: #3c3c46;
  --border-light: #4e4e58;
  --text: #d4d4dc;
  --text-muted: #9090a0;
  --text-bright: #f0f0f5;
  --accent: #e8a44a;
  --accent-hover: #d4943e;
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.13);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.13);
  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.13);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.10);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.13);
  --orange: #fb923c;
  --orange-bg: rgba(251, 146, 60, 0.13);
  --pink: #f472b6;
  --cyan: #22d3ee;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body, #root {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 5px rgba(232, 164, 74, 0.3); }
  50% { box-shadow: 0 0 20px rgba(232, 164, 74, 0.5); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animate-fade { animation: fadeIn 0.4s ease-out; }
.animate-scale { animation: fadeInScale 0.3s ease-out; }

/* ============================================================================
   LOGIN PAGE
   ============================================================================ */
.login-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1e24 0%, #2a2a32 50%, #1e1e24 100%);
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
  position: relative;
  overflow: hidden;
}

.login-bg-orbs {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-bg-orbs .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}
.login-bg-orbs .orb:nth-child(1) { width: 400px; height: 400px; background: var(--accent); top: -100px; right: -100px; opacity: 0.1; }
.login-bg-orbs .orb:nth-child(2) { width: 300px; height: 300px; background: var(--purple); bottom: -50px; left: -50px; opacity: 0.08; }
.login-bg-orbs .orb:nth-child(3) { width: 200px; height: 200px; background: var(--green); top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0.06; }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 420px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: fadeInScale 0.5s ease-out;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.login-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 20px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input {
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  transition: var(--transition);
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 164, 74, 0.15);
}

.login-error {
  background: var(--red-bg);
  border: 1px solid rgba(239, 71, 111, 0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  animation: fadeIn 0.3s ease;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c8862e);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232, 164, 74, 0.3);
}

.btn-success {
  background: linear-gradient(135deg, var(--green), #05b88a);
  color: white;
}
.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(6, 214, 160, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--red), #d63660);
  color: white;
}
.btn-danger:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(239, 71, 111, 0.3); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-light); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ============================================================================
   HEADER / NAVBAR
   ============================================================================ */
.app-header {
  height: 60px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-brand {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
}
.header-breadcrumb .sep { color: var(--border-light); }
.header-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}
.header-breadcrumb a:hover { color: var(--accent); }
.header-breadcrumb .current { color: var(--text); font-weight: 600; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-light);
  border-radius: 20px;
  font-size: 13px;
}
.header-user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--orange));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: white;
}

/* ============================================================================
   PROJECT LIST
   ============================================================================ */
.projects-page {
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 32px;
}

.projects-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.projects-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-bright);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  animation: fadeIn 0.4s ease-out;
  animation-fill-mode: both;
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--orange), var(--green));
  opacity: 0;
  transition: var(--transition);
}
.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}
.project-card:hover::before { opacity: 1; }

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.project-card-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
}

.project-card-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-done { background: var(--green-bg); color: var(--green); }
.stat-active { background: rgba(232, 164, 74, 0.13); color: var(--accent); }
.stat-blocked { background: var(--red-bg); color: var(--red); }
.stat-wait { background: rgba(136, 136, 170, 0.15); color: var(--text-muted); }

.project-card-progress {
  height: 6px;
  background: var(--bg-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.project-card-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.project-card-actions {
  display: flex;
  gap: 4px;
}
.project-card-actions button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.project-card-actions button:hover { color: var(--text); background: var(--bg-hover); }

/* ============================================================================
   GRAFCET VIEW
   ============================================================================ */
.grafcet-layout {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
  transition: var(--transition);
}
.sidebar.collapsed { width: 0; padding: 0; overflow: hidden; }

.sidebar-toggle {
  position: absolute;
  left: 260px;
  top: 70px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: none;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 0 8px 8px 0;
  z-index: 50;
  transition: var(--transition);
}
.sidebar.collapsed + .sidebar-toggle,
.sidebar.collapsed ~ .sidebar-toggle { left: 0; }

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Mini GRAFCET in sidebar */
.mini-grafcet {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-phase {
  padding: 10px 12px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.mini-phase:hover { background: var(--bg-hover); }
.mini-phase.active { border-left-color: var(--accent); }

.mini-phase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.mini-phase-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.mini-phase-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.mini-phase-bar {
  height: 3px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.mini-phase-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.mini-transition {
  width: 2px;
  height: 8px;
  background: var(--border);
  margin: 0 auto;
}

/* Phase containers */
.phase-container {
  margin-bottom: 24px;
  animation: fadeIn 0.4s ease-out;
  animation-fill-mode: both;
}

.phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}
.phase-header:hover { filter: brightness(1.1); }

.phase-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.phase-header-left .phase-chevron { transition: transform 0.3s ease; }
.phase-header-left .phase-chevron.open { transform: rotate(90deg); }

.phase-name {
  font-weight: 700;
  font-size: 14px;
  color: white;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.phase-fullname {
  font-size: 12px;
  opacity: 0.8;
  margin-left: 8px;
  color: rgba(255,255,255,0.7);
}

.phase-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.phase-stats {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  font-weight: 600;
}
.phase-actions { display: flex; gap: 4px; }
.phase-actions button {
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: var(--transition);
}
.phase-actions button:hover { background: rgba(255,255,255,0.2); color: white; }

.phase-body {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px;
  background: var(--bg-card);
}

.phase-steps {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

/* GRAFCET Steps */
.grafcet-transition {
  width: 2px;
  height: 16px;
  margin: 0 auto;
  flex-shrink: 0;
}

.grafcet-etape {
  width: 100%;
  animation: fadeIn 0.3s ease-out;
}

.etape-bloc {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-light);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.etape-bloc:hover { border-color: var(--border-light); background: var(--bg-hover); }

.etape-bloc.status-done { border-color: var(--green); }
.etape-bloc.status-active { border-color: var(--accent); animation: pulseGlow 2s ease infinite; }
.etape-bloc.status-blocked { border-color: var(--red); }
.etape-bloc.status-quote { border-color: var(--yellow); }
.etape-bloc.status-validation { border-color: var(--purple); }

.etape-drag { cursor: grab; color: var(--border-light); padding: 4px; }
.etape-drag:active { cursor: grabbing; }

.etape-status-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.status-wait .etape-status-icon { background: rgba(136,136,170,0.2); color: var(--text-muted); }
.status-done .etape-status-icon { background: var(--green-bg); color: var(--green); }
.status-active .etape-status-icon { background: rgba(232, 164, 74, 0.15); color: var(--accent); }
.status-blocked .etape-status-icon { background: var(--red-bg); color: var(--red); }
.status-quote .etape-status-icon { background: var(--yellow-bg); color: var(--yellow); }
.status-validation .etape-status-icon { background: var(--purple-bg); color: var(--purple); }

.etape-info { flex: 1; min-width: 0; }
.etape-abbr {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-bright);
}
.etape-name {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.etape-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}
.etape-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 3px;
}

.etape-expand-icon {
  color: var(--text-muted);
  transition: transform 0.3s ease;
}
.etape-expand-icon.open { transform: rotate(180deg); }

/* Step details panel */
.etape-details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 20px;
  animation: fadeIn 0.3s ease-out;
}

.etape-details-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.detail-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 4px;
}
.detail-field .value {
  font-size: 13px;
  color: var(--text);
}

.status-select {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.status-select:focus { border-color: var(--accent); }

/* Comments */
.comments-section, .attachments-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  cursor: pointer;
}
.section-title h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title .count {
  background: var(--bg-light);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
}

.comment-item {
  padding: 10px 12px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  animation: fadeIn 0.3s ease;
}
.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.comment-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}
.comment-date {
  font-size: 11px;
  color: var(--text-muted);
}
.comment-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 11px;
  transition: var(--transition);
}
.comment-delete:hover { color: var(--red); }

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.comment-form textarea {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  resize: vertical;
  min-height: 36px;
  outline: none;
  font-family: inherit;
}
.comment-form textarea:focus { border-color: var(--accent); }

/* Attachments */
.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.attachment-icon { font-size: 18px; flex-shrink: 0; }
.attachment-info { flex: 1; min-width: 0; }
.attachment-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-size {
  font-size: 11px;
  color: var(--text-muted);
}
.attachment-actions { display: flex; gap: 4px; }
.attachment-actions button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.attachment-actions button:hover { color: var(--text); background: var(--bg-hover); }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
}
.upload-zone:hover { border-color: var(--accent); background: rgba(232, 164, 74, 0.05); }

.upload-progress {
  padding: 14px 16px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  animation: fadeIn 0.3s ease;
}
.upload-progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.upload-progress-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}
.upload-progress-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}
.upload-progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 4px;
  transition: width 0.2s ease;
}
.upload-progress-size {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(232, 164, 74, 0.12);
  border-style: solid;
  transform: scale(1.01);
}
.upload-zone.drag-over p { color: var(--accent); font-weight: 600; }
.upload-zone p { font-size: 13px; color: var(--text-muted); }

/* ============================================================================
   ADMIN PANEL
   ============================================================================ */
.admin-page {
  height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 32px;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.admin-tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-light);
  position: sticky;
  top: 0;
}
.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.admin-table tr:hover td { background: var(--bg-hover); }

.admin-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
}

/* Filters bar */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filters-bar input, .filters-bar select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.filters-bar input:focus, .filters-bar select:focus { border-color: var(--accent); }

/* ============================================================================
   MODALS
   ============================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 600px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeInScale 0.3s ease-out;
}
.modal-content.large {
  max-width: 900px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ============================================================================
   LOADING / SKELETON
   ============================================================================ */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-light) 25%, var(--bg-hover) 50%, var(--bg-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ============================================================================
   EDIT FORMS (inline)
   ============================================================================ */
.edit-input {
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 13px;
  width: 100%;
  outline: none;
  font-family: inherit;
}
.edit-input:focus { border-color: var(--accent); }

.inline-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============================================================================
   PROGRESS BAR (global)
   ============================================================================ */
.global-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.global-progress-bar {
  width: 120px;
  height: 6px;
  background: var(--bg-light);
  border-radius: 3px;
  overflow: hidden;
}
.global-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  border-radius: 3px;
  transition: width 0.8s ease;
}
.global-progress-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ============================================================================
   TOOLTIP
   ============================================================================ */
.tooltip-wrapper {
  position: relative;
  display: inline-block;
}
.tooltip-content {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 50;
  pointer-events: none;
  animation: fadeIn 0.2s ease;
  margin-bottom: 6px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

/* Tablet: <= 1024px */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .sidebar-toggle { left: 200px; }
  .sidebar.collapsed + .sidebar-toggle,
  .sidebar.collapsed ~ .sidebar-toggle { left: 0; }
  .etape-details-grid { grid-template-columns: 1fr 1fr; }
  .projects-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .admin-table-wrapper { font-size: 12px; }
  .filters-bar { gap: 8px; }
  .modal-content { max-width: 95vw; }
  .modal-content.large { max-width: 95vw; }
}

/* Mobile: <= 768px */
@media (max-width: 768px) {
  html, body, #root { overflow: auto; height: auto; }
  .app-shell { height: auto; min-height: 100vh; overflow: visible; }

  /* Header */
  .app-header { height: auto; min-height: 52px; padding: 8px 12px; flex-wrap: wrap; gap: 8px; position: sticky; top: 0; flex-shrink: 0; }
  .header-brand { font-size: 16px; }
  .header-breadcrumb { font-size: 12px; }
  .header-right { gap: 6px; }
  .header-user { padding: 4px 8px; font-size: 12px; max-width: 160px; overflow: hidden; }
  .header-user span:not(.avatar) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-user .avatar { width: 24px; height: 24px; font-size: 10px; flex-shrink: 0; }

  /* Login */
  .login-card { padding: 28px 20px; width: 95vw; border-radius: 12px; }
  .login-logo h1 { font-size: 22px; }
  .form-group input { padding: 10px 12px; font-size: 14px; }

  /* Projects */
  .projects-page, .admin-page { padding: 12px; height: auto; min-height: auto; overflow-y: visible; }
  .projects-header { flex-direction: column; gap: 12px; align-items: stretch; }
  .projects-header h2 { font-size: 20px; }
  .projects-grid { grid-template-columns: 1fr; gap: 12px; }
  .project-card { padding: 16px; }
  .project-card-header h3 { font-size: 16px; }
  .project-card-stats { gap: 6px; }
  .stat-badge { font-size: 11px; padding: 3px 8px; }

  /* GRAFCET layout */
  .grafcet-layout { flex-direction: column; height: auto; min-height: auto; overflow: visible; }
  .sidebar { width: 100%; height: auto; max-height: none; border-right: none; border-bottom: 1px solid var(--border); padding: 12px; order: -1; overflow: visible; }
  .sidebar.collapsed { width: 100%; height: 0; padding: 0; overflow: hidden; }
  .sidebar-toggle { position: relative; left: auto !important; top: auto; width: 100%; border-radius: 0; border: none; border-bottom: 1px solid var(--border); padding: 8px; text-align: center; }
  .main-content { padding: 12px; overflow-y: visible; height: auto; }
  .mini-grafcet { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .mini-phase { flex: 1; min-width: 100px; }
  .mini-transition { display: none; }

  /* Phase */
  .phase-header { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .phase-name { font-size: 12px; letter-spacing: 0.5px; }
  .phase-fullname { display: none; }
  .phase-header-right { width: 100%; justify-content: space-between; }
  .phase-body { padding: 10px; }

  /* Steps */
  .etape-bloc { padding: 10px 12px; gap: 8px; }
  .etape-abbr { font-size: 12px; }
  .etape-name { font-size: 11px; }
  .etape-status-icon { width: 24px; height: 24px; font-size: 12px; }
  .etape-badges { gap: 4px; }
  .etape-badge { font-size: 9px; padding: 1px 6px; }
  .etape-details { padding: 12px; }
  .etape-details-grid { grid-template-columns: 1fr; gap: 10px; }
  .etape-drag { display: none; }

  /* Comments & Attachments */
  .comment-form { flex-direction: column; }
  .comment-form textarea { min-height: 60px; }
  .comment-item { padding: 8px 10px; }
  .attachment-item { padding: 6px 8px; flex-wrap: wrap; }
  .upload-zone { padding: 12px; }

  /* Modals */
  .modal-content { width: 95vw; max-width: 95vw; padding: 16px; max-height: 90vh; border-radius: 10px; }
  .modal-content.large { max-width: 95vw; }
  .modal-header h3 { font-size: 16px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; justify-content: center; }

  /* Buttons */
  .btn { padding: 10px 16px; font-size: 13px; }
  .btn-sm { padding: 8px 12px; }

  /* Admin */
  .admin-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .admin-tab { white-space: nowrap; padding: 8px 14px; font-size: 13px; }
  .admin-table-wrapper { overflow-x: auto; }
  .admin-table { min-width: 600px; }
  .admin-table th, .admin-table td { padding: 8px 10px; font-size: 12px; }
  .filters-bar { flex-direction: column; }
  .filters-bar input, .filters-bar select { width: 100%; }

  /* Global progress in sidebar */
  .global-progress-bar { width: 100%; }

  /* Sidebar buttons stack */
  .sidebar > div:last-child { display: flex; flex-wrap: wrap; gap: 6px; }
  .sidebar > div:last-child .btn { flex: 1; min-width: 120px; }
}

/* Small mobile: <= 480px */
@media (max-width: 480px) {
  .app-header { padding: 6px 8px; }
  .header-brand { font-size: 14px; }
  .header-breadcrumb { display: none; }
  .projects-page, .admin-page { padding: 8px; }
  .project-card { padding: 12px; }
  .project-card-stats { flex-wrap: wrap; }
  .phase-header { padding: 8px 10px; }
  .phase-name { font-size: 11px; }
  .phase-stats { font-size: 11px; }
  .phase-actions button { padding: 3px 6px; font-size: 11px; }
  .etape-bloc { padding: 8px 10px; }
  .login-card { padding: 20px 16px; }
  .login-logo h1 { font-size: 20px; }
  .login-logo p { font-size: 12px; }
}

/* ============================================================================
   FILE PREVIEW MODAL
   ============================================================================ */
.preview-image {
  max-width: 100%;
  max-height: 60vh;
  border-radius: var(--radius-sm);
}
.preview-pdf {
  width: 100%;
  height: 70vh;
  border: none;
  border-radius: var(--radius-sm);
}

/* ============================================================================
   ACTION BADGES
   ============================================================================ */
.action-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.action-login { background: rgba(232, 164, 74, 0.13); color: var(--accent); }
.action-create { background: var(--green-bg); color: var(--green); }
.action-update { background: var(--yellow-bg); color: var(--yellow); }
.action-delete { background: var(--red-bg); color: var(--red); }

/* Drag and drop */
.dragging { opacity: 0.5; }
.drag-over { border-color: var(--accent) !important; background: rgba(76, 201, 240, 0.05) !important; }

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  animation: slideInRight 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}
.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--accent); color: white; }

/* New project form */
.new-project-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.new-project-form input,
.new-project-form textarea {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.new-project-form input:focus,
.new-project-form textarea:focus { border-color: var(--accent); }

/* Role select badge */
.role-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.role-viewer { background: rgba(136,136,170,0.2); color: var(--text-muted); }
.role-editor { background: var(--blue-bg); color: var(--blue); }
.role-manager { background: var(--purple-bg); color: var(--purple); }
.role-admin { background: var(--green-bg); color: var(--green); }
