/* ── Portal Reset & Base ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: #050507;
  color: rgba(255,255,255,0.7);
  min-height: 100vh;
}

a { color: #06b6d4; text-decoration: none; }
a:hover { color: #22d3ee; }

.font-mono { font-family: 'JetBrains Mono', monospace; }

/* ── Layout ────────────────────────────────────── */
.portal-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 32px;
}
.portal-brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: rgba(255,255,255,0.3);
}
.portal-brand a { color: rgba(255,255,255,0.3); }
.portal-brand a:hover { color: #06b6d4; }
.portal-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}
.portal-nav a, .portal-nav button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.25s, border-color 0.25s;
}
.portal-nav a:hover, .portal-nav button:hover {
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.15);
}

/* ── Section Label ─────────────────────────────── */
.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: rgba(99,102,241,0.8);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 16px;
}

/* ── Panel (Terminal Block) ────────────────────── */
.panel {
  background: rgba(10,10,15,0.85);
  border: 1px solid rgba(255,255,255,0.06);
  border-left: 2px solid #06b6d4;
  border-radius: 8px;
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.panel-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}
.panel-body {
  padding: 20px;
}
.panel.admin { border-left-color: #10b981; }
.panel.cyan { border-left-color: #06b6d4; }

/* ── Forms ─────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-label .prompt { color: rgba(6,182,212,0.5); }
.form-input,
.form-textarea {
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.form-input::placeholder,
.form-textarea::placeholder {
  color: rgba(255,255,255,0.25);
}
.form-input:focus,
.form-textarea:focus {
  border-color: rgba(6,182,212,0.3);
  box-shadow: 0 0 0 2px rgba(6,182,212,0.08);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

/* ── Buttons ───────────────────────────────────── */
.btn {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 13px;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.25s, color 0.25s, box-shadow 0.25s;
  border: 1px solid;
}
.btn-cyan {
  color: #06b6d4;
  background: rgba(6,182,212,0.08);
  border-color: rgba(6,182,212,0.2);
}
.btn-cyan:hover {
  background: rgba(6,182,212,0.12);
  color: #22d3ee;
  box-shadow: 0 0 20px rgba(6,182,212,0.1);
}
.btn-emerald {
  color: #10b981;
  background: rgba(16,185,129,0.08);
  border-color: rgba(16,185,129,0.2);
}
.btn-emerald:hover {
  background: rgba(16,185,129,0.12);
  color: #34d399;
  box-shadow: 0 0 20px rgba(16,185,129,0.1);
}
.btn-sm {
  font-size: 11px;
  padding: 6px 12px;
}
.btn-block { width: 100%; justify-content: center; }

/* ── Login Page ────────────────────────────────── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 400px;
}
.login-box .panel {
  margin-bottom: 0;
}

/* ── Project Cards (Admin) ─────────────────────── */
.project-grid {
  display: grid;
  gap: 16px;
}
.project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}
.project-card:hover {
  background: rgba(255,255,255,0.04);
  border-color: rgba(6,182,212,0.15);
}
.project-card-info h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 4px;
}
.project-card-info p {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
}
.project-card-meta {
  display: flex;
  gap: 12px;
  align-items: center;
}
.badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-active { color: #10b981; background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); }
.badge-paused { color: #eab308; background: rgba(234,179,8,0.1); border: 1px solid rgba(234,179,8,0.2); }
.badge-completed { color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); }
.badge-count {
  color: #06b6d4;
  background: rgba(6,182,212,0.1);
  border: 1px solid rgba(6,182,212,0.2);
  min-width: 20px;
  text-align: center;
}

/* ── Messages Thread ───────────────────────────── */
.messages-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
  padding: 4px 0;
}
.message {
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 85%;
}
.message-client {
  background: rgba(6,182,212,0.06);
  border: 1px solid rgba(6,182,212,0.1);
  align-self: flex-start;
}
.message-admin {
  background: rgba(16,185,129,0.06);
  border: 1px solid rgba(16,185,129,0.1);
  align-self: flex-end;
}
.message-sender {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.message-content {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255,255,255,0.75);
  white-space: pre-wrap;
  word-break: break-word;
}
.message-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  margin-top: 6px;
}
.message-failed {
  opacity: 0.5;
  border-color: rgba(239,68,68,0.25);
  position: relative;
}
.message-failed::after {
  content: 'failed';
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: #ef4444;
  position: absolute;
  bottom: 4px;
  right: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── File List ─────────────────────────────────── */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
}
.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.file-icon {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(6,182,212,0.6);
  background: rgba(6,182,212,0.08);
  border-radius: 4px;
  padding: 4px 6px;
  white-space: nowrap;
}
.file-name {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  white-space: nowrap;
  margin-left: 12px;
}

/* ── File Upload Area ──────────────────────────── */
.upload-area {
  border: 2px dashed rgba(6,182,212,0.15);
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
}
.upload-area:hover,
.upload-area.dragover {
  border-color: rgba(6,182,212,0.3);
  background: rgba(6,182,212,0.03);
}
.upload-area-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: rgba(255,255,255,0.35);
}
.upload-area-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  margin-top: 6px;
}
.upload-progress {
  margin-top: 12px;
  display: none;
}
.upload-bar {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.upload-bar-fill {
  height: 100%;
  background: #06b6d4;
  width: 0;
  transition: width 0.3s;
}

/* ── Copy Link ─────────────────────────────────── */
.copy-link-group {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.copy-link-group .form-input {
  flex: 1;
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}

/* ── Status Select ─────────────────────────────── */
.status-select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}
.status-select option { background: #0a0a0f; }

/* ── Empty State ───────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255,255,255,0.25);
}
.empty-state p {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

/* ── Alert ─────────────────────────────────────── */
.alert {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
}
.alert-error {
  color: #ef4444;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
}
.alert-success {
  color: #10b981;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
}

/* ── Back Link ─────────────────────────────────── */
.back-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  margin-bottom: 20px;
  display: inline-block;
}
.back-link:hover { color: #06b6d4; }

/* ── Files Header & View Toggle ────────────────── */
.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.view-toggle-btn {
  background: transparent;
  border: 1px solid #06b6d4;
  color: #06b6d4;
  padding: 6px 16px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.view-toggle-btn:hover {
  background: rgba(6, 182, 212, 0.1);
}

/* ── File Thumbnail ────────────────────────────── */
.file-thumbnail {
  display: none;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  margin-bottom: 12px;
}

.file-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s;
}

.file-thumbnail img:hover {
  transform: scale(1.05);
}

/* ── Gallery View ──────────────────────────────── */
.files-gallery {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}

.files-gallery .file-item {
  display: flex;
  flex-direction: column;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.files-gallery .file-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(6,182,212,0.2);
  transform: translateY(-2px);
}

.files-gallery .file-thumbnail {
  display: block;
}

.files-gallery .file-info {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.files-gallery .file-name {
  font-size: 14px;
  white-space: normal;
  word-break: break-word;
}

.files-gallery .file-meta {
  margin-left: 0;
  flex-wrap: wrap;
}

/* ── Lightbox ──────────────────────────────────── */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1;
}

.lightbox-close {
  position: absolute;
  top: -50px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s;
}

.lightbox-close:hover {
  color: #06b6d4;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: 1px solid #06b6d4;
  color: #06b6d4;
  font-size: 48px;
  line-height: 1;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.lightbox-prev {
  left: -80px;
}

.lightbox-next {
  right: -80px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(6, 182, 212, 0.2);
}

#lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  border: 2px solid #06b6d4;
}

.lightbox-info {
  text-align: center;
  margin-top: 16px;
  font-family: 'JetBrains Mono', monospace;
}

.lightbox-filename {
  color: #06b6d4;
  font-size: 16px;
  margin: 0 0 4px;
}

.lightbox-meta {
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  margin: 0;
}

/* ── Timeline ──────────────────────────────────── */
.timeline-section {
  background: rgba(10,10,15,0.85);
  border: 1px solid rgba(255,255,255,0.06);
  border-left: 2px solid #06b6d4;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.timeline-horizontal {
  display: flex;
  align-items: center;
  gap: 40px;
  min-height: 80px;
  position: relative;
  padding: 10px 0;
}

.timeline-event {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-width: 100px;
}

.timeline-event:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 20px;
  left: calc(100% + 10px);
  width: 40px;
  height: 2px;
  background: rgba(255,255,255,0.1);
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid;
  background: rgba(10,10,15,0.9);
  transition: transform 0.2s;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.timeline-dot:hover {
  transform: scale(1.3);
}

.timeline-dot.cyan {
  border-color: #06b6d4;
  box-shadow: 0 0 8px rgba(6,182,212,0.3);
}

.timeline-dot.emerald {
  border-color: #10b981;
  box-shadow: 0 0 8px rgba(16,185,129,0.3);
}

.timeline-dot.gray {
  border-color: rgba(255,255,255,0.3);
  box-shadow: 0 0 8px rgba(255,255,255,0.1);
}

.timeline-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-top: 8px;
  text-align: center;
  white-space: nowrap;
}

.timeline-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  margin-top: 4px;
}

/* ── Timeline Mobile (Vertical) ────────────────── */
@media (max-width: 768px) {
  .timeline-section {
    padding: 16px;
  }

  .timeline-horizontal {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    padding-left: 30px;
  }

  .timeline-event {
    align-items: flex-start;
    flex-direction: row;
    gap: 16px;
    width: 100%;
  }

  .timeline-event:not(:last-child)::after {
    top: calc(100% - 10px);
    left: -23px;
    width: 2px;
    height: 20px;
    background: rgba(255,255,255,0.1);
  }

  .timeline-dot {
    position: absolute;
    left: -30px;
    top: 4px;
  }

  .timeline-label {
    text-align: left;
    white-space: normal;
    margin-top: 0;
  }

  .timeline-date {
    margin-top: 2px;
  }
}

/* ── Mobile Menu Toggle ────────────────────────── */
.mobile-menu-toggle {
  display: none;
  background: rgba(6,182,212,0.1);
  border: 1px solid rgba(6,182,212,0.3);
  color: #06b6d4;
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.25s;
  padding: 0;
  line-height: 1;
}

.mobile-menu-toggle:hover {
  background: rgba(6,182,212,0.15);
}

/* ── Mobile Nav Overlay ────────────────────────── */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  z-index: 999;
  align-items: center;
  justify-content: center;
}

.mobile-nav-overlay.active {
  display: flex;
}

.mobile-nav-content {
  background: rgba(10,10,15,0.95);
  border: 1px solid rgba(6,182,212,0.3);
  border-left: 2px solid #06b6d4;
  border-radius: 8px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 280px;
}

.mobile-nav-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: #06b6d4;
  text-align: center;
  padding: 12px;
  border: 1px solid rgba(6,182,212,0.2);
  border-radius: 6px;
  transition: all 0.25s;
}

.mobile-nav-link:hover {
  background: rgba(6,182,212,0.1);
  border-color: rgba(6,182,212,0.4);
}

/* ── Responsive ────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .files-gallery {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1025px) {
  .files-gallery {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  /* Mobile Header - Sticky */
  .portal-header {
    position: sticky;
    top: 0;
    background: #050507;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    padding: 12px 16px;
    margin: -24px -20px 24px;
  }

  /* Show hamburger menu button */
  .mobile-menu-toggle {
    display: block;
  }

  /* Hide desktop nav on mobile */
  .portal-nav {
    display: none;
  }

  /* General mobile adjustments */
  .portal-wrapper { padding: 24px 20px; }
  .project-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .project-card-meta { align-self: flex-start; }
  .copy-link-group { flex-direction: column; }
  .message { max-width: 95%; }
  .files-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
  .lightbox-prev {
    left: 10px;
  }
  .lightbox-next {
    right: 10px;
  }

  /* Touch-friendly button sizes (min 44x44px) */
  .btn {
    min-height: 44px;
    padding: 12px 18px;
  }

  .btn-sm {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 12px;
  }

  .view-toggle-btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Larger upload dropzone for mobile */
  .upload-area {
    padding: 48px 20px;
  }

  .upload-area-text {
    font-size: 14px;
  }

  .upload-area-hint {
    font-size: 12px;
  }

  /* Fixed message input on mobile */
  .panel:has(#messageForm) .panel-body {
    padding-bottom: 24px;
  }

  #messageForm {
    position: sticky;
    bottom: 0;
    background: rgba(10,10,15,0.95);
    padding: 16px;
    margin: 16px -20px -20px;
    border-top: 1px solid rgba(255,255,255,0.06);
  }

  #messageForm .form-textarea {
    min-height: 100px;
    font-size: 14px;
  }

  #messageForm .btn {
    width: 100%;
  }
}
