/* ═════════════════════════════════════════════════════════════════
   TapTorque (tap-drill-engagement) — Bespoke Machining & Metalworking CSS
   100% Client-Side Responsive Precision Engine
   ═════════════════════════════════════════════════════════════════ */

:root {
    /* Machining & Metalworking Dark Theme Tokens */
    --bg-primary: #0a0e17;
    --bg-surface: #121824;
    --bg-card: #18202f;
    --bg-card-hover: #1e283d;
    --border: rgba(148, 163, 184, 0.14);
    --border-highlight: rgba(56, 189, 248, 0.35);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent & Brand Colors */
    --accent: #38bdf8;          /* Signal Blue */
    --accent-secondary: #06b6d4;/* Cyan */
    --accent-glow: rgba(56, 189, 248, 0.2);
    --accent-gradient: linear-gradient(135deg, #38bdf8, #818cf8);

    /* Status Badges */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);

    /* Typography */
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Radius & Elevation */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);
}

/* Base Body Styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Header Styling */
.app-header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
    background: radial-gradient(circle at 50% 0%, rgba(56, 189, 248, 0.12), transparent 70%);
}

.header-badge {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-size: 2.75rem;
    font-weight: 800;
    margin: 0;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.header-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-top: 0.4rem;
    font-weight: 400;
}

/* Main Container & Layout */
.app-main {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

/* Ad Space Placeholders */
.ad-placeholder {
    background: var(--bg-surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-align: center;
    margin: 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-desktop {
    width: 728px;
    height: 90px;
    display: none;
}

.ad-mobile {
    width: 320px;
    height: 50px;
}

@media (min-width: 768px) {
    .ad-desktop { display: flex; }
    .ad-mobile { display: none; }
}

/* Mode Bar Switcher */
.mode-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.85rem 1.2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: rgba(56, 189, 248, 0.4);
}

.mode-btn.active {
    background: rgba(56, 189, 248, 0.12);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.15);
}

/* Main Grid Layout */
.calculator-grid {
    display: grid;
    grid-template-columns: 1rem;
    gap: 1.5rem;
}

@media (min-width: 992px) {
    .calculator-grid {
        grid-template-columns: 440px 1fr;
    }
}

/* Cards Base */
.controls-card, .results-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.card-tag {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-glow);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Input Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-select, .form-input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.form-select:focus, .form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input[type="number"] {
    font-family: var(--font-mono);
}

/* Toggle Tabs for Preset vs Custom */
.input-type-toggle {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 3px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.type-btn {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Process Selector (Radio Cards) */
.process-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.radio-card {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-card input {
    display: none;
}

.radio-card:hover {
    border-color: rgba(56, 189, 248, 0.4);
}

.radio-card.active {
    background: rgba(56, 189, 248, 0.08);
    border-color: var(--accent);
}

.radio-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.radio-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Range Slider */
.slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.slider-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-glow);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
}

.form-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-card);
    border-radius: 4px;
    outline: none;
    margin: 0.75rem 0;
    cursor: pointer;
}

.form-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
    border: 2px solid #fff;
    transition: transform 0.1s ease;
}

.form-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Preset Buttons Row */
.preset-buttons-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    margin-top: 0.5rem;
}

@media (min-width: 480px) {
    .preset-buttons-row {
        grid-template-columns: repeat(4, 1fr);
    }
}

.preset-btn {
    padding: 0.4rem 0.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.preset-btn.active {
    background: var(--accent);
    color: #000;
    font-weight: 700;
    border-color: var(--accent);
}

/* Grid Layout Utilities */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }
.hidden { display: none !important; }

/* Hero Result Card */
.hero-result-card {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(18, 24, 36, 0.95));
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-glow);
}

.hero-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.hero-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.hero-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: #000;
    background: var(--accent);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.hero-body {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.hero-bit-name {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
}

.hero-dimensions {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    font-family: var(--font-mono);
}

.dim-main {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.dim-sub {
    font-size: 1rem;
    color: var(--text-muted);
}

.hero-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.75rem;
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.stat-val {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-val.highlight {
    color: var(--accent);
}

/* Risk Card */
.risk-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.25rem;
    transition: all 0.3s ease;
}

.risk-card.risk-low {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.08);
}

.risk-card.risk-moderate {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.08);
}

.risk-card.risk-critical {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
}

.risk-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.risk-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.risk-title-wrap h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.risk-title-wrap p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.2rem 0 0;
}

.risk-stat {
    display: flex;
    flex-direction: column;
}

.risk-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.risk-stat-val {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Schematic Container */
.schematic-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.schematic-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.schematic-header h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.schematic-legend {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.thread-color { background: #818cf8; }
.hole-color { background: #38bdf8; }
.engage-color { background: #10b981; }

.svg-container {
    width: 100%;
    background: #080c14;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

/* Drill Candidate Table */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.table-header {
    margin-bottom: 0.75rem;
}

.table-header h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

.table-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.table-responsive {
    overflow-x: auto;
}

.drill-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.drill-table th {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.drill-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: var(--font-mono);
}

.drill-table tr:hover {
    background: rgba(56, 189, 248, 0.04);
}

.drill-table tr.best-match-row {
    background: rgba(56, 189, 248, 0.12);
}

.badge-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-best { background: var(--accent); color: #000; }
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }

/* Action Buttons */
.action-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
    background: #7dd3fc;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: rgba(56, 189, 248, 0.4);
}

/* Saved Setups Grid */
.saved-setups-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin: 0;
}

.btn-text-danger {
    background: transparent;
    border: none;
    color: var(--danger);
    font-size: 0.85rem;
    cursor: pointer;
}

.saved-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .saved-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.saved-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    position: relative;
}

.saved-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
}

.saved-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.saved-delete {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
}

.saved-delete:hover {
    color: var(--danger);
}

/* Article / Content Depth Styling */
.content-depth-article {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    margin-top: 3rem;
}

.article-inner {
    max-width: 860px;
    margin: 0 auto;
}

.article-inner h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 1rem;
}

.article-inner h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

.article-inner p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.article-inner ul {
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding-left: 1.25rem;
    margin-bottom: 1.25rem;
}

.article-inner li {
    margin-bottom: 0.5rem;
}

/* Formulas Callout */
.formula-callout {
    background: var(--bg-card);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin: 1.5rem 0;
}

.formula-callout h4 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    color: var(--accent);
    margin: 0 0 1rem;
}

.formula-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

@media (min-width: 600px) {
    .formula-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.formula-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.formula-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.formula-card code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent);
}

/* Reference Table */
.reference-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin: 1.25rem 0;
}

.reference-table th {
    background: var(--bg-card);
    color: var(--text-primary);
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.reference-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

/* FAQ Accordion */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-question {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    padding: 0.9rem 1rem;
    cursor: pointer;
    user-select: none;
}

.faq-question:hover {
    color: var(--accent);
}

.faq-answer {
    padding: 0 1rem 0.9rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.faq-answer p {
    margin: 0;
}
