/* =================================================================
   Workflow-Erweiterung für das-ingenieurbuero.com
   © Dipl.-Ing. Rolf Krause · Alle Rechte vorbehalten
   Ergänzt style.css um Workflow-Sidebar, Stepper, CSV-Import
   ================================================================= */

/* ── LAYOUT: SIDEBAR + CONTENT ── */
.app-layout {
  display: flex;
  min-height: calc(100vh - 120px);
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── SIDEBAR (Workflow) ── */
.workflow-sidebar {
  width: 300px;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0;
  flex-shrink: 0;
  position: sticky;
  top: 100px;
  height: calc(100vh - 120px);
}

.wf-header {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.wf-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 4px;
}
.wf-progress {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Phasen */
.wf-phase { margin-bottom: 2px; }
.wf-phase-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.wf-phase-header:hover { background: var(--bg-light); }
.wf-phase-icon { font-size: 16px; flex-shrink: 0; }
.wf-phase-name { font-size: 0.8125rem; font-weight: 600; color: var(--text); flex: 1; }
.wf-phase-chevron {
  font-size: 16px;
  color: var(--text-light);
  transition: transform 0.2s;
}
.wf-phase.active .wf-phase-name { color: var(--primary); }
.wf-phase.done .wf-phase-name { color: var(--success); }

/* Schritte */
.wf-steps { display: none; padding: 0 0 8px; }
.wf-steps.open { display: block; }
.wf-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 20px 8px 28px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}
.wf-step:hover { background: var(--bg-light); text-decoration: none; }
.wf-step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--text-light);
  margin-top: 4px;
  flex-shrink: 0;
}
.wf-step.active .wf-step-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,160,210,0.2);
}
.wf-step.done .wf-step-dot {
  background: var(--success);
  border-color: var(--success);
}
.wf-step-content { flex: 1; min-width: 0; }
.wf-step-name { display: block; font-size: 0.8125rem; font-weight: 500; }
.wf-step-desc { display: block; font-size: 0.6875rem; color: var(--text-light); margin-top: 1px; }
.wf-step.active .wf-step-name { color: var(--primary); font-weight: 600; }
.wf-step-badge {
  font-size: 0.625rem;
  background: rgba(0,160,210,0.1);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Workflow-Actions */
.wf-actions {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.wf-btn {
  display: block;
  text-align: center;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.wf-btn-next {
  background: var(--primary);
  color: #fff;
}
.wf-btn-next:hover { background: var(--accent); text-decoration: none; color: #fff; }
.wf-btn-back {
  background: var(--bg-light);
  color: var(--text-light);
}
.wf-btn-back:hover { background: var(--border); text-decoration: none; }
.wf-btn-export {
  background: var(--success);
  color: #fff;
}
.wf-btn-export:hover { opacity: 0.9; }

.wf-import {
  padding: 12px 20px;
  text-align: center;
}
.wf-import-label {
  font-size: 0.75rem;
  color: var(--text-light);
  cursor: pointer;
  text-decoration: underline;
}
.wf-import-label:hover { color: var(--accent); }

/* ── CONTENT AREA (Workflow) ── */
.content-area {
  flex: 1;
  min-width: 0;
  padding: 0;
}
.content-area .tool-wrapper {
  max-width: 100%;
  overflow-x: hidden;
}

/* ── STARTSEITE ── */
.start-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1.25rem;
}
.start-page h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.75rem;
  line-height: 1.15;
}
.start-page .accent {
  color: var(--accent);
}
.start-lead {
  font-size: 1.0625rem;
  color: var(--text-light);
  margin-bottom: 2.5rem;
  max-width: 600px;
}
.workflow-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 3rem;
}
.wf-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 2rem;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}
.wf-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0,160,210,0.12);
  transform: translateY(-2px);
  text-decoration: none;
}
.wf-card-icon { font-size: 2rem; margin-bottom: 1rem; }
.wf-card h2 { font-size: 1.375rem; font-weight: 700; color: var(--primary-dark); margin: 0 0 0.5rem; }
.wf-card p { font-size: 0.875rem; color: var(--text-light); line-height: 1.5; margin: 0; }
.wf-card .start-arrow {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
}

/* CSV Import */
.import-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  border: 2px dashed var(--border);
}
.import-box h3 { font-size: 1rem; color: var(--primary-dark); margin: 0 0 0.5rem; }
.import-box p { font-size: 0.8125rem; color: var(--text-light); margin: 0 0 1rem; }
.import-box label {
  display: inline-block;
  padding: 0.5rem 1.5rem;
  background: var(--bg-light);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--primary);
  transition: background 0.15s;
}
.import-box label:hover { background: var(--border); }

/* Platzhalter */
.placeholder-page {
  max-width: 640px;
  margin: 5rem auto;
  text-align: center;
  padding: 1.5rem;
}
.placeholder-page h1 { margin-bottom: 1rem; }
.placeholder-page p { color: var(--text-light); }

/* ── MOBILE ── */
@media (max-width: 1024px) {
  .workflow-sidebar { width: 260px; }
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }

  /* Mobile: Sidebar als Slide-In-Drawer (initial versteckt) */
  .workflow-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 86%;
    max-width: 340px;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
    border-right: 1px solid var(--border, #E2E8F0);
  }
  .workflow-sidebar.is-open { transform: translateX(0); }

  /* Backdrop hinter dem Drawer */
  .wf-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,42,82,.45);
    z-index: 9998;
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  }
  .wf-backdrop.is-open { display: block; }

  /* Floating Hamburger-Button öffnet die Sidebar */
  .wf-toggle-mobile {
    display: flex;
    position: sticky;
    top: 60px;
    z-index: 50;
    width: calc(100% - 16px);
    margin: 8px;
    padding: 11px 14px;
    background: linear-gradient(135deg,#1B4B82,#0D3A5C);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-family: 'Outfit',sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 8px rgba(13,58,92,.18);
  }
  .wf-toggle-mobile::before {
    content: '☰';
    font-size: 18px;
    line-height: 1;
  }
  .wf-toggle-mobile .wf-toggle-step {
    flex: 1;
    text-align: left;
    opacity: .9;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Cards / Phasen full-width */
  .workflow-cards { grid-template-columns: 1fr; }

  /* Tool-Wrapper: volle Breite */
  .content-area .tool-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .content-area { padding: 12px 8px; }

  /* Workflow-Step-Phasen: horizontal scrollbar */
  .workflow-phases { overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 8px; padding-bottom: 8px; }
  .workflow-phases .phase-card { min-width: 120px; flex-shrink: 0; padding: 12px 10px; }
  .workflow-phases .phase-card .phase-label { font-size: 10px; }
  .workflow-phases .phase-card .phase-name { font-size: 12px; }

  /* Tool-Toolbar: wrap */
  .tool-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .tool-toolbar .btn { font-size: 12px; padding: 6px 12px; }
}

/* Desktop / Tablet: Mobile-Toggle versteckt */
@media (min-width: 769px) {
  .wf-toggle-mobile, .wf-backdrop { display: none !important; }
}

/* Tablet: Sidebar schmaler */
@media (min-width: 769px) and (max-width: 1024px) {
  .workflow-sidebar { width: 240px; }
  .sidebar-toggle { display: none; }
}
@media (min-width: 1025px) {
  .sidebar-toggle { display: none; }
}

/* ── Hide-Modus für breit-arbeitende Tools (Marktwert, 3D, FEM, …) ──
   Sidebar wird komplett ausgeblendet, content-area bekommt volle Breite.
   Ein dezenter "☰ Workflow"-Knopf links oben blendet sie wieder ein. */
.wf-sidebar-reopen {
  display: none;
  position: fixed;
  left: 8px;
  top: 92px;
  z-index: 60;
  background: linear-gradient(135deg, #1B4B82 0%, #00A0D2 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font: 600 12px/1 Outfit, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(13,58,92,0.25);
  letter-spacing: 0.02em;
}
.wf-sidebar-reopen:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.app-layout.wf-sidebar-hidden .workflow-sidebar {
  display: none;
}
.app-layout.wf-sidebar-hidden .content-area {
  flex: 1;
  max-width: 100%;
}
.app-layout.wf-sidebar-hidden .wf-sidebar-reopen {
  display: inline-flex;
  align-items: center;
}
