/* ==============================================
   PERMANENT MAGNET ALTERNATOR CONFIGURATOR
   Tool-specific styles.
   Requires: ../css/shared.css, ../css/components.css
   ============================================== */

/* ==============================================
   ACCESSIBILITY
   ============================================== */

/* Replaces bare <label> where no form control is associated (accessibility fix) */
.form-group-heading {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-medium-text);
    letter-spacing: 0.5px;
}

/* ==============================================
   MODE CARD OVERRIDES
   ============================================== */

.mode-selector {
    margin-bottom: 30px;
}

.mode-card {
    padding: 20px;
}

.mode-card.active {
    background: linear-gradient(135deg, rgba(0, 73, 144, 0.08) 0%, rgba(53, 196, 181, 0.08) 100%);
    box-shadow: var(--shadow-md);
}

/* ==============================================
   CONFIG PANEL
   ============================================== */

.config-panel {
    background: var(--color-bg-blue-light);
    padding: 25px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 25px;
    border-left: 3px solid var(--color-primary-medium);
}

/* ==============================================
   RANGE SLIDER
   ============================================== */

input[type="range"] {
    padding: 0;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-bg-gray-light);
    border-radius: 4px;
    border: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-teal), var(--color-teal-dark));
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-teal), var(--color-teal-dark));
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

/* ==============================================
   RESULT PANEL
   ============================================== */

.result-panel {
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary-medium) 100%);
    color: white;
    border-radius: var(--border-radius-lg);
    padding: 25px;
    border: 2px solid var(--color-accent-teal);
}

.result-panel h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
    color: white;
    border-bottom: 2px solid var(--color-accent-teal);
    padding-bottom: 10px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.result-item {
    background: rgba(255, 255, 255, 0.12);
    padding: 15px;
    border-radius: var(--border-radius-sm);
    backdrop-filter: blur(10px);
    border-left: 3px solid var(--color-accent-teal);
}

.result-item label {
    display: block;
    font-size: 0.85em;
    opacity: 0.9;
    margin-bottom: 5px;
    color: white;
    font-weight: normal;
}

.result-item .value {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--color-accent-teal);
}

/* ==============================================
   SPECIFICATIONS
   ============================================== */

.specs {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.spec-item {
    font-size: 0.95em;
    opacity: 0.9;
    color: white;
}

.spec-item strong {
    opacity: 1;
    color: var(--color-accent-teal);
}

/* ==============================================
   RESULT TABLE
   ============================================== */

.result-table {
    width: 100%;
    margin-top: 15px;
    border-collapse: collapse;
}

.result-table th,
.result-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-table th {
    font-weight: bold;
    opacity: 1;
    color: white;
    background: rgba(0, 0, 0, 0.1);
}

.result-table td {
    opacity: 0.9;
}

.result-table tr:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ── Row action cell ──────────────────────────────────────────────────── */
.row-action-th {
    width: 80px;
    font-size: 0.78em;
    letter-spacing: .3px;
    text-align: center;
    opacity: .85;
}

.row-action-cell {
    width: 80px;
    text-align: center;
    padding: 4px 8px !important;
}

/* Always dark background + white text so button contrasts on any row colour
   (green match-exact, yellow match-close, orange match-under, default dark) */
.row-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 20px;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background .15s, transform .1s;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

.row-action-btn:hover {
    background: rgba(0, 0, 0, 0.72);
    transform: scale(1.08);
}

/* ==============================================
   MATCH COLOR STATES
   ============================================== */

.match-exact {
    background: var(--color-teal-dark) !important;
    color: #ffffff !important;
}

.match-close {
    background: var(--color-accent-yellow) !important;
    color: var(--color-dark-text) !important;
}

.match-under {
    background: var(--color-accent-orange) !important;
    color: #ffffff !important;
}

/* ==============================================
   NO DATA
   ============================================== */

.no-data {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

/* ==============================================
   BUTTONS - PMG OVERRIDES
   ============================================== */

.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--color-bg-gray-light);
    color: var(--color-dark-text);
}

.btn-secondary:hover {
    background: var(--color-neutral-gray);
    color: white;
}

.print-btn {
    background: linear-gradient(135deg, var(--color-accent-teal) 0%, var(--color-teal-dark) 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.print-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(53, 196, 181, 0.4);
}

/* ==============================================
   PRINT STYLES
   ============================================== */

@media print {
    body * {
        visibility: hidden;
    }

    .print-area,
    .print-area * {
        visibility: visible;
    }

    .print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        font-family: 'Panton', Arial, sans-serif;
    }

    .print-area h1,
    .print-area h2,
    .print-area h3,
    .print-area h4,
    .print-area th {
        font-family: 'Klavika', Arial, sans-serif;
    }

    .no-print,
    .btn-back {
        display: none !important;
    }

    @page {
        margin: 2cm;
        size: A4;
    }
}

/* ==============================================
   OPERATING MODE CARDS
   ============================================== */

.operating-mode-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.op-mode-card {
    flex: 1;
    min-width: 160px;
    max-width: 250px;
    padding: 20px 15px;
    border: 2px solid var(--color-neutral-gray);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    background: var(--color-bg-white);
}

.op-mode-card:hover {
    border-color: var(--color-accent-teal);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.op-mode-card.active {
    border-color: var(--color-primary-dark);
    background: linear-gradient(135deg, rgba(0, 73, 144, 0.08) 0%, rgba(53, 196, 181, 0.08) 100%);
    box-shadow: var(--shadow-md);
}

.op-mode-card .op-mode-icon {
    font-size: 2em;
    margin-bottom: 10px;
    display: block;
}

.op-mode-card h4 {
    color: var(--color-primary-dark);
    font-size: 1.1em;
    margin-bottom: 8px;
    font-weight: 700;
}

.op-mode-card p {
    color: var(--color-medium-text);
    font-size: 0.85em;
    line-height: 1.4;
    margin: 0;
}

.op-mode-card.active h4 {
    color: var(--color-primary-dark);
}

.op-mode-card.active .op-mode-icon {
    color: var(--color-accent-teal);
}

/* ==============================================
   TERMS BUTTON
   ============================================== */

.terms-button {
    position: fixed;
    top: 30px;
    right: 140px;
    background: linear-gradient(135deg, #004990, #003366);
    color: white;
    border: none;
    padding: 16px 28px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1em;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 73, 144, 0.4);
    z-index: 1000;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.terms-button:hover {
    background: linear-gradient(135deg, #35c4b5, #006d68);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(53, 196, 181, 0.4);
    color: white;
}

.terms-button::before {
    content: '\00A7';
    font-size: 1.2em;
    font-weight: bold;
}

/* ==============================================
   RESPONSIVE - PMG SPECIFIC
   ============================================== */

@media (max-width: 800px) {
    .config-panel {
        padding: 15px;
    }

    .operating-mode-cards {
        flex-direction: column;
        gap: 10px;
    }

    .op-mode-card {
        min-width: 100%;
        max-width: 100%;
        padding: 14px;
        display: flex;
        align-items: center;
        gap: 12px;
        text-align: left;
    }

    .op-mode-card .op-mode-icon {
        font-size: 1.5em;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .result-panel {
        padding: 16px;
    }

    .result-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Scrollable table on narrow screens */
    .result-table,
    .result-panel table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Doc buttons stack vertically */
    .rb-doc-buttons {
        flex-direction: column;
    }

    .rb-doc-btn {
        width: 100%;
        justify-content: center;
    }

    /* Popup full-width on mobile */
    .row-action-popup {
        min-width: 0;
        width: calc(100vw - 24px);
        left: 12px !important;
    }

    /* 2D modal full-screen on mobile */
    .drawing-modal {
        max-width: 100vw;
        max-height: 100dvh;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .result-grid {
        grid-template-columns: 1fr;
    }

    .result-item .value {
        font-size: 1.2em;
    }

    .mode-selector {
        flex-direction: column;
    }

    .mode-card {
        min-width: 100%;
    }

    /* Graph canvases: scrollable container, canvas not resized */
    .form-group:has(canvas) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==============================================
   ROW ACTION POPUP  (result row → 3 buttons)
   ============================================== */

.row-action-popup {
    position: absolute;
    z-index: 9999;
    background: #1c2a36;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    padding: 14px 12px 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3);
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 220px;
    animation: rap-in .15s ease;
}
@keyframes rap-in {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.rap-model-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: #35c4b5;
    padding: 2px 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 2px;
    padding-right: 24px; /* avoid overlap with × */
}

.rap-close {
    position: absolute;
    top: 8px; right: 10px;
    background: none; border: none;
    color: rgba(255,255,255,.4);
    font-size: 15px; line-height: 1;
    cursor: pointer; padding: 2px 4px;
    border-radius: 4px;
    transition: color .15s, background .15s;
}
.rap-close:hover { color: #fff; background: rgba(255,255,255,.1); }

.rap-btn {
    display: block; width: 100%;
    padding: 9px 14px;
    border-radius: 8px; border: none;
    font-size: 13px; font-weight: 600;
    letter-spacing: .2px;
    cursor: pointer; text-align: left;
    transition: background .15s, box-shadow .15s, transform .1s;
    white-space: nowrap;
}
.rap-btn:hover { transform: translateX(3px); }

.rap-btn-rb   { background: #004a90; color: #fff; }
.rap-btn-rb:hover { background: #0060bb; box-shadow: 0 2px 8px rgba(0,74,144,.4); }

.rap-btn-2d   { background: #17593a; color: #fff; }
.rap-btn-2d:hover { background: #1f7a50; box-shadow: 0 2px 8px rgba(23,89,58,.4); }

.rap-btn-step { background: rgba(53,196,181,.15); color: #35c4b5; border: 1px solid rgba(53,196,181,.35); }
.rap-btn-step:hover { background: rgba(53,196,181,.25); box-shadow: 0 2px 8px rgba(53,196,181,.2); }

/* ==============================================
   RATINGS BOOK DOC BUTTONS
   ============================================== */

.rb-doc-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,.15);
}

.rb-doc-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}
.rb-doc-btn:hover { transform: translateY(-2px); }

.rb-doc-2d {
    background: #17593a;
    color: #fff;
}
.rb-doc-2d:hover { background: #1f7a50; box-shadow: 0 4px 12px rgba(23,89,58,.4); }

.rb-doc-step {
    background: rgba(53,196,181,.15);
    color: #35c4b5;
    border: 1px solid rgba(53,196,181,.4);
}
.rb-doc-step:hover { background: rgba(53,196,181,.28); box-shadow: 0 4px 12px rgba(53,196,181,.25); }

/* ==============================================
   2D DRAWING MODAL
   ============================================== */

.drawing-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.72);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.drawing-modal {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    max-width: 92vw;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.drawing-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    background: #1a2732; color: #fff;
    font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}

.drawing-modal-body {
    overflow: auto;
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: #f4f6f8;
}
.drawing-modal-body img {
    max-width: 100%; max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

/* ==============================================
   PMG TECHNICAL DOCUMENTATION SECTION
   ============================================== */

/* ── PMG Technical Documentation Section ── */
.pmg-docs-section {
  padding: 28px 28px 40px;
  flex: 1;
}

.pmg-docs-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--color-neutral-gray, #e8eef4);
}

.pmg-docs-title h2 {
  font-size: 1.4em;
  color: #002f5c;
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pmg-docs-title p {
  font-size: 0.88em;
  color: #5e6f7e;
  margin: 0;
}

.pmg-family-filter {
  flex-shrink: 0;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.78em;
  font-weight: 700;
  color: #5e6f7e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid #c5ced8;
  background: #fff;
  color: #3a4f63;
  font-size: 0.82em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: #004a90;
  color: #004a90;
}

.filter-btn.active {
  background: #004a90;
  border-color: #004a90;
  color: #fff;
}

/* ── PMG Docs Table ── */
.pmg-docs-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pmg-docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

.pmg-docs-table thead th {
  background: linear-gradient(90deg, #002f5c 0%, #004a90 100%);
  color: #fff;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85em;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pmg-th-num      { width: 42px; text-align: center; }
.pmg-th-model    { width: 148px; }
.pmg-th-coupling { width: 90px; }
.pmg-th-draw     { width: 35%; }
.pmg-th-step     { width: 35%; }

.pmg-docs-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #e8eef4;
  vertical-align: top;
}

.pmg-first-coupling td {
  border-top: 2px solid #c5d3e0;
}

.pmg-first-coupling:first-child td {
  border-top: none;
}

.pmg-num {
  text-align: center;
  color: #8a99a8;
  font-size: 0.82em;
}

.pmg-model {
  font-weight: 700;
  color: #002f5c;
  font-size: 0.92em;
  vertical-align: middle !important;
  white-space: nowrap;
}

.pmg-coupling {
  font-family: monospace;
  font-size: 0.88em;
  color: #004a90;
  font-weight: 600;
}

.pmg-draw-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-content: flex-start;
}

.pmg-step-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

/* ── PMG doc buttons ── */
.pmg-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 0.78em;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.16s;
  border: 1.5px solid transparent;
}

.pmg-doc-2d {
  background: #e8f0fb;
  color: #004a90;
  border-color: #b8cfee;
}

.pmg-doc-2d:hover {
  background: #004a90;
  color: #fff;
}

.pmg-doc-step {
  background: #e6f7f6;
  color: #007b74;
  border-color: #a8dcd9;
}

.pmg-doc-step:hover {
  background: #0097a7;
  color: #fff;
}

/* ── 2D Drawing Modal ── */
.pmg-rb-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pmg-rb-modal-inner {
  background: #fff;
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.pmg-rb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(90deg, #002f5c, #004a90);
  color: #fff;
  gap: 16px;
  flex-shrink: 0;
}

.pmg-rb-modal-header span {
  font-size: 0.9em;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.pmg-rb-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5em;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.8;
  flex-shrink: 0;
}

.pmg-rb-modal-close:hover { opacity: 1; }

.pmg-rb-modal-body {
  overflow: auto;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f6f8;
  flex: 1;
}

.pmg-rb-modal-body img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  background: #fff;
}

/* ── Active state for PMG Docs button ── */
.pmg-docs-active {
  background: #004a90 !important;
  color: #fff !important;
  border-color: #004a90 !important;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .pmg-docs-section { padding: 16px 12px 28px; }
  .pmg-docs-header { flex-direction: column; gap: 12px; }
  .pmg-docs-table { font-size: 0.82em; }
  .pmg-docs-table td { padding: 6px 8px; }
}

