/* ============================================
   Gear Design & Analysis Tool CSS
   ============================================ */

html {
    scrollbar-gutter: stable;
}

/* Page Layout */
.gear-app {
    min-height: 100vh;
    background: var(--color-bg-primary);
    background-image: radial-gradient(circle at 10% 20%, rgba(220, 38, 38, 0.03) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.03) 0%, transparent 40%);
}

.gear-app-header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.gear-app-header .back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.02);
}

.gear-app-header .back-link:hover {
    color: var(--color-accent);
    background: rgba(220, 38, 38, 0.08);
}

.gear-app-header .back-link svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.gear-app-header .back-link:hover svg {
    transform: translateX(-4px);
}

.gear-app-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: linear-gradient(135deg, var(--color-text-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gear-app-title .title-icon {
    font-size: 1.4rem;
    -webkit-text-fill-color: initial;
}

.gear-app-actions {
    display: flex;
    gap: 0.5rem;
}

/* Main Layout Container */
.gear-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
}

/* Main Grid Layout */
.gear-main-grid {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
}

.grid-col-left {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
}

.grid-col-middle {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
}

.grid-col-right {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
}

.panel-section {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 1);
    transition: all 0.3s ease;
}

.panel-section:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 1);
}

.panel-section-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 0.75rem;
}

.panel-section-title .section-icon {
    font-size: 1.1rem;
}

/* Form inputs & rows */
.prop-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.prop-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.prop-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.prop-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.prop-val-display {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-accent);
    background: rgba(220, 38, 38, 0.08);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.prop-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.prop-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--color-border-light);
    outline: none;
    transition: background 0.2s;
}

.prop-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
    transition: transform 0.1s;
}

.prop-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.prop-input.num-only {
    width: 65px;
    padding: 0.4rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--color-text-primary);
    transition: all 0.2s ease;
}

.prop-input.num-only:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
    background: #fff;
}

.prop-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.prop-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
    background: #fff;
}

/* Reference Diagram Container */
.diagram-container {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 1);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

.diagram-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.diagram-title .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.6);
}

.diagram-title .dot.red { background: var(--color-accent); }

.diagram-svg-wrap {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: radial-gradient(circle at center, var(--color-bg-tertiary), var(--color-bg-secondary));
    border: 1px solid rgba(0,0,0,0.05);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}

/* Status/Info Bar */
.status-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.2rem;
    background: linear-gradient(90deg, rgba(5, 150, 105, 0.1), rgba(255,255,255,0));
    border-radius: 10px;
    border-left: 4px solid #059669;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #059669;
    animation: pulse-dot 2s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.6);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(5, 150, 105, 0.6); }
    50% { opacity: 0.5; box-shadow: 0 0 4px rgba(5, 150, 105, 0.3); }
}

.status-info {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

.status-info span {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--color-text-muted);
    background: rgba(0,0,0,0.05);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
}

/* Tab Selector Styles */
.gear-type-tab-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    background: rgba(0,0,0,0.03);
    padding: 0.4rem;
    border-radius: 12px;
}

.gear-tab-btn {
    padding: 0.65rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.gear-tab-btn:hover {
    color: var(--color-text-primary);
    background: rgba(0,0,0,0.04);
}

.gear-tab-btn.active {
    background: #fff;
    color: var(--color-accent);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

/* Geometric Result Rows */
.geom-results-box {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.85rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: 10px;
    font-size: 0.85rem;
    transition: transform 0.2s ease, background 0.2s ease;
}

.result-row:hover {
    transform: translateX(4px);
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(220, 38, 38, 0.2);
}

.result-row-header {
    display: flex;
    flex-direction: column;
}

.result-row-lbl {
    font-weight: 600;
    color: var(--color-text-primary);
}

.result-row-desc {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

.result-row-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-text-primary);
    background: rgba(0,0,0,0.03);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.result-row-unit {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Strength calculations cards */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
}

.result-card {
    padding: 1rem;
    background: linear-gradient(135deg, rgba(255,255,255,0.8), rgba(255,255,255,0.4));
    border: 1.5px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: transparent;
    transition: background 0.3s;
}

.result-card.safe::before { background: #059669; }
.result-card.unsafe::before { background: #dc2626; }

.result-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.result-card.unsafe {
    animation: pulse-danger 2s infinite;
}

@keyframes pulse-danger {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); border-color: rgba(220, 38, 38, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); border-color: rgba(220, 38, 38, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); border-color: rgba(220, 38, 38, 0.6); }
}

.result-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 0.4rem;
}

.result-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--color-accent);
    font-family: var(--font-mono);
}

.result-subtitle {
    font-size: 0.72rem;
    color: var(--color-text-secondary);
    margin-top: 0.3rem;
    font-weight: 500;
}

/* Engineering Theory Card */
.info-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1rem;
}

.info-card-title {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 2px solid rgba(220, 38, 38, 0.2);
    padding-bottom: 0.6rem;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
}

.info-card-title::before {
    content: '🔬';
    margin-right: 0.5rem;
}

.info-card-text {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.info-formula {
    background: rgba(255, 255, 255, 0.9);
    padding: 0.6rem;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid var(--color-accent);
    overflow-x: auto;
    color: var(--color-accent);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.info-formula .katex-display {
    margin: 0.4rem 0;
}

/* Desktop Symmetrical Columns Layout */
@media (min-width: 1280px) {
    .gear-container {
        max-width: 1700px;
    }
    .gear-main-grid {
        display: grid;
        grid-template-columns: 1fr 1.2fr 1fr;
        gap: 2rem;
    }
    .grid-col-left { order: 0; }
    .grid-col-middle { order: 0; }
    .grid-col-right { order: 0; }
}

/* Mobile/Tablet Column Stacking Order */
@media (max-width: 1279px) {
    .diagram-container { aspect-ratio: 4/3; }
    .grid-col-middle { order: 1; }
    .grid-col-left { order: 2; }
    .grid-col-right { order: 3; }
}

/* Dark Mode Overrides */
body.dark-mode .gear-app {
    background-image: radial-gradient(circle at 10% 20%, rgba(220, 38, 38, 0.08) 0%, transparent 40%),
                      radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.08) 0%, transparent 40%);
}

body.dark-mode .gear-app-header { background: rgba(15, 15, 20, 0.7); border-bottom-color: rgba(255, 255, 255, 0.05); }
body.dark-mode .gear-app-header .back-link { background: rgba(255,255,255,0.05); }
body.dark-mode .gear-app-header .back-link:hover { background: rgba(220, 38, 38, 0.15); }

body.dark-mode .panel-section, body.dark-mode .diagram-container, body.dark-mode .info-card {
    background: rgba(30, 30, 35, 0.6);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

body.dark-mode .gear-tab-btn.active {
    background: rgba(255,255,255,0.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

body.dark-mode .prop-input.num-only, body.dark-mode .prop-select {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255,255,255,0.1);
}

body.dark-mode .result-row { background: rgba(0,0,0,0.2); border-color: rgba(255,255,255,0.05); }
body.dark-mode .result-row:hover { background: rgba(220, 38, 38, 0.1); }
body.dark-mode .result-row-val { background: rgba(255,255,255,0.05); }

body.dark-mode .result-card { background: linear-gradient(135deg, rgba(40,40,45,0.8), rgba(30,30,35,0.8)); border-color: rgba(255,255,255,0.05); }
body.dark-mode .info-formula { background: rgba(0,0,0,0.3); }

/* Force KaTeX formulas to render in theme's red accent color */
.katex, .katex-display { color: var(--color-accent) !important; }

/* Visual Toggle Buttons */
.visual-toggle-group { display: flex; background: rgba(0,0,0,0.05); border-radius: 8px; padding: 3px; }
body.dark-mode .visual-toggle-group { background: rgba(255,255,255,0.05); }
.visual-toggle-btn { padding: 0.4rem 0.8rem; background: transparent; border: none; border-radius: 6px; cursor: pointer; font-family: var(--font-heading); font-size: 0.75rem; font-weight: 600; color: var(--color-text-secondary); transition: all 0.2s ease; }
.visual-toggle-btn:hover { color: var(--color-text-primary); }
.visual-toggle-btn.active { background: var(--color-accent); color: #ffffff; box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3); }
