/**
 * H2W Calculator Styles
 * CSS for both linear and rotary motion calculators
 * Ported and adapted from legacy Site.css
 */

/* Override WordPress theme layout constraints for calculator pages */
.page-template-default .entry-content.has-global-padding.is-layout-constrained .h2w-linear-motion-calculator,
.page-template-default .entry-content.has-global-padding.is-layout-constrained .h2w-rotary-motion-calculator {
    max-width: none !important;
    width: 80% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Override theme's content size constraint specifically for calculator blocks */
.is-layout-constrained .h2w-linear-motion-calculator,
.is-layout-constrained .h2w-rotary-motion-calculator {
    max-width: 1400px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Calculator containers */
.h2w-linear-motion-calculator,
.h2w-rotary-motion-calculator {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: Arial, sans-serif;
    width: 80%;
    box-sizing: border-box;
}

/* Brief description styling */
.calculator-brief {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background-color: #f0f8ff;
    border-radius: 6px;
    border: 1px solid #0073aa;
}

.calculator-brief p {
    margin: 0;
    font-size: 16px;
    color: #333;
    line-height: 1.5;
}

.calculator-brief a {
    color: #0073aa;
    text-decoration: none;
    font-weight: bold;
}

.calculator-brief a:hover {
    text-decoration: underline;
}

/* Introduction content styling */
.calculator-introduction {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid #ddd;
}

.calculator-introduction h3 {
    color: #333;
    font-size: 20px;
    margin-bottom: 15px;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 5px;
}

.calculator-introduction p {
    line-height: 1.6;
    margin-bottom: 15px;
    color: #555;
}

.calculator-introduction a {
    color: #0073aa;
    text-decoration: none;
}

.calculator-introduction a:hover {
    text-decoration: underline;
}

/* Variables table styling */
.variables-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: white;
    border: 1px solid #ddd;
}

.variables-table th,
.variables-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.variables-table th {
    background-color: #0073aa;
    color: white;
    font-weight: bold;
}

.variables-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.variables-table tr:hover {
    background-color: #f5f5f5;
}

.variables-table .result {
    font-weight: bold;
    color: #0073aa;
    padding: 3px 8px;
    background-color: #f0f8ff;
    border: 1px solid #0073aa;
    border-radius: 3px;
}

/* Performance notes styling */
.performance-notes {
    margin-top: 15px;
    padding: 10px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
}

.performance-notes p {
    margin: 2px 0;
    color: #856404;
}

/* Calculator header */
.calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ddd;
}

.calculator-header h2 {
    margin: 0;
    color: #333;
    font-size: 28px;
}

.calculator-nav-link {
    color: #0073aa;
    text-decoration: none;
    font-weight: bold;
    padding: 8px 16px;
    border: 1px solid #0073aa;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.calculator-nav-link:hover {
    background-color: #0073aa;
    color: white;
    text-decoration: none;
}

/* Unit converter section */
.unit-converter-section {
    background-color: #f9f9f9;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    text-align: center;
}

.unit-converter-section h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    display: inline-block;
    margin-right: 15px;
    vertical-align: middle;
}

.converter-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    vertical-align: middle;
}

.converter-controls .equals-sign {
    font-weight: bold;
    font-size: 16px;
    color: #333;
    margin: 0 5px;
}

.converter-controls select,
.converter-controls input {
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.converter-controls input[type="text"] {
    width: 100px;
}

/* Main calculator table */
#calculatorTopTable {
    margin: 0 auto;
    width: 100%;
}

/* Calculator tabs wider layout */
.calculator-tabs {
    width: 100%;
}

.calculator-tabs .ui-tabs-panel {
    min-height: 400px;
}

/* Form layout improvements for wider screens */
@media (min-width: 900px) {
    .calculation-form {
        max-width: 800px;
    }
    
    .form-row {
        display: flex;
        align-items: center;
        margin-bottom: 20px;
        gap: 15px;
    }
    
    .form-row label {
        min-width: 200px;
    }
    
    .converter-controls {
        justify-content: center;
        gap: 15px;
    }
    
    .converter-controls select,
    .converter-controls input {
        min-width: 120px;
    }
}

/* Calculator tabs */
.calculator-tabs {
    width: 100%;
}

.calculator-tabs .ui-tabs-nav {
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 6px 6px 0 0;
    padding: 0;
    margin: 0;
}

.calculator-tabs .ui-tabs-nav li {
    list-style: none;
    float: left;
    margin: 0;
    padding: 0;
    border-right: 1px solid #ccc;
}

.calculator-tabs .ui-tabs-nav li:last-child {
    border-right: none;
}

.calculator-tabs .ui-tabs-nav li a {
    display: block;
    padding: 10px 15px;
    text-decoration: none;
    color: #333;
    font-weight: bold;
    background: #f0f0f0;
    border: none;
    border-radius: 0;
    font-size: 13px;
}

.calculator-tabs .ui-tabs-nav li.ui-tabs-active a,
.calculator-tabs .ui-tabs-nav li a:hover {
    background: #0073aa;
    color: white;
}

.calculator-tabs .ui-tabs-panel {
    background: white;
    border: 1px solid #ccc;
    border-top: none;
    padding: 20px;
    border-radius: 0 0 6px 6px;
    clear: both;
}

/* Tab content */
.calculator-tabs h4 {
    margin-top: 0;
    color: #333;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.calculator-tabs h5 {
    color: #555;
    font-size: 16px;
    margin-top: 25px;
    margin-bottom: 15px;
}

/* Form elements */
.calculation-form {
    max-width: 600px;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.form-row label {
    min-width: 180px;
    font-weight: bold;
    color: #333;
}

.form-row input[type="text"] {
    width: 100px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.form-row select {
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    min-width: 80px;
}

.form-row input[readonly] {
    background-color: #f5f5f5;
    color: #666;
}

/* Results display */
.result {
    font-weight: bold;
    color: #0073aa;
    font-size: 16px;
    padding: 5px 10px;
    background-color: #f0f8ff;
    border: 1px solid #0073aa;
    border-radius: 4px;
    min-width: 60px;
    text-align: center;
    display: inline-block;
}

/* Radio button groups */
.radio-group {
    margin: 15px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.radio-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: normal;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    margin-right: 8px;
}

/* Equation display */
.equation-display {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background-color: #f0f8ff;
    border: 1px solid #0073aa;
    border-radius: 4px;
}

.equation-display div {
    font-size: 18px;
    color: #333;
}

/* MathJax equation images and equations from live site */
.mathjaxEquationImage1 {
    text-align: center;
    margin: 15px 0;
    padding: 10px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.mathjaxEquationImage1 img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.mathjaxEquation1 {
    text-align: center;
    margin: 15px 0;
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    min-height: 40px;
}

.mathjaxEquation1 div {
    font-size: 16px;
    color: #333;
}

/* Legacy support for mathjaxEquation class */
.mathjaxEquation {
    text-align: center;
    margin: 15px 0;
    padding: 12px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.mathjaxEquationImage {
    text-align: center;
    margin: 15px 0;
    padding: 10px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Large screen optimizations */
@media (min-width: 1200px) {
    .h2w-linear-motion-calculator,
    .h2w-rotary-motion-calculator {
        padding: 30px;
    }
    
    .calculator-tabs .ui-tabs-nav li a {
        padding: 12px 18px;
        font-size: 14px;
    }
    
    .form-row {
        margin-bottom: 18px;
    }
    
    .variables-table th,
    .variables-table td {
        padding: 15px;
    }
}

/* Mobile responsiveness */
@media (max-width: 900px) {
    /* Prevent horizontal scrolling */
    body {
        overflow-x: hidden;
    }
    
    /* Reset width constraints on mobile */
    .is-layout-constrained .h2w-linear-motion-calculator,
    .is-layout-constrained .h2w-rotary-motion-calculator {
        max-width: 100% !important;
        width: 100% !important;
        padding: 8px !important;
        margin: 0 !important;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .h2w-linear-motion-calculator,
    .h2w-rotary-motion-calculator {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .calculator-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .calculator-header h2 {
        font-size: 24px;
    }
    
    .calculator-brief {
        padding: 8px;
        font-size: 14px;
        margin: 10px 0;
    }
    
    .calculator-introduction {
        padding: 8px;
        margin: 10px 0;
    }
    
    .calculator-introduction h3 {
        font-size: 18px;
    }
    
    /* Transform table to card layout on mobile */
    .variables-table {
        border: none;
        background: none;
    }
    
    .variables-table thead {
        display: none;
    }
    
    .variables-table tbody,
    .variables-table tr,
    .variables-table td {
        display: block;
        width: 100%;
        border: none;
    }
    
    .variables-table tr {
        background-color: white;
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .variables-table tr:hover {
        background-color: white;
    }
    
    .variables-table td {
        padding: 8px 0;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .variables-table td:last-child {
        border-bottom: none;
    }
    
    /* Add labels for mobile using pseudo elements */
    .variables-table td:nth-child(1)::before {
        content: "Variable: ";
        font-weight: bold;
        color: #0073aa;
        min-width: 80px;
    }
    
    .variables-table td:nth-child(2)::before {
        content: "Description: ";
        font-weight: bold;
        color: #0073aa;
        min-width: 80px;
    }
    
    .variables-table td:nth-child(3)::before {
        content: "Units: ";
        font-weight: bold;
        color: #0073aa;
        min-width: 80px;
    }
    
    .variables-table td:nth-child(4)::before {
        content: "Value: ";
        font-weight: bold;
        color: #0073aa;
        min-width: 80px;
    }
    
    /* Specific labels for unit converter section */
    .unit-converter-section .variables-table td:nth-child(1)::before {
        content: "Conversion Type: ";
    }
    
    .unit-converter-section .variables-table td:nth-child(2)::before {
        content: "From Value: ";
    }
    
    .unit-converter-section .variables-table td:nth-child(3)::before {
        content: "From Units: ";
    }
    
    .unit-converter-section .variables-table td:nth-child(4)::before {
        content: "To Value: ";
    }
    
    .unit-converter-section .variables-table td:nth-child(5)::before {
        content: "To Units: ";
        font-weight: bold;
        color: #0073aa;
        min-width: 80px;
    }
    
    /* Make form inputs mobile-friendly */
    .variables-table input,
    .variables-table select {
        width: 100%;
        min-width: 120px;
        padding: 10px;
        font-size: 16px;
        border: 1px solid #ccc;
        border-radius: 6px;
        box-sizing: border-box;
    }
    
    .variables-table .result {
        width: 100%;
        padding: 10px;
        font-size: 16px;
        text-align: center;
        min-height: 20px;
        box-sizing: border-box;
    }
    
    .unit-converter-section h3 {
        display: block;
        margin-bottom: 10px;
        text-align: center;
    }
    
    .converter-controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .converter-controls > * {
        width: 100%;
        max-width: 200px;
        text-align: center;
    }
    
    .calculator-tabs .ui-tabs-nav li {
        float: none;
        display: block;
        border-right: none;
        border-bottom: 1px solid #ccc;
    }
    
    .calculator-tabs .ui-tabs-nav li:last-child {
        border-bottom: none;
    }
    
    .calculator-tabs .ui-tabs-nav li a {
        text-align: center;
        font-size: 14px;
        padding: 12px 10px;
    }
    
    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 20px;
    }
    
    .form-row label {
        min-width: auto;
        font-size: 16px;
        color: #0073aa;
        font-weight: bold;
    }
    
    .form-row input,
    .form-row select {
        width: 100%;
        padding: 10px;
        font-size: 16px;
        border: 1px solid #ccc;
        border-radius: 6px;
    }
    
    .calculation-form {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .h2w-linear-motion-calculator,
    .h2w-rotary-motion-calculator {
        padding: 5px !important;
    }
    
    /* Override WordPress theme padding on very small screens */
    .is-layout-constrained .h2w-linear-motion-calculator,
    .is-layout-constrained .h2w-rotary-motion-calculator {
        padding: 5px !important;
    }
    
    .calculator-header h2 {
        font-size: 20px;
    }
    
    .calculator-nav-link {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .calculator-brief {
        padding: 6px;
        font-size: 13px;
        margin: 8px 0;
    }
    
    .calculator-introduction {
        padding: 6px;
        font-size: 14px;
        margin: 8px 0;
    }
    
    .calculator-introduction h3 {
        font-size: 16px;
    }
    
    /* Enhance card layout for very small screens */
    .variables-table tr {
        margin-bottom: 12px;
        padding: 12px;
    }
    
    .variables-table td {
        padding: 6px 0;
    }
    
    .variables-table td::before {
        font-size: 14px;
        min-width: 70px;
    }
    
    .variables-table input,
    .variables-table select {
        padding: 8px;
        font-size: 16px;
    }
    
    .variables-table .result {
        padding: 8px;
        font-size: 16px;
    }
    
    .performance-notes {
        padding: 8px;
        font-size: 12px;
    }
    
    .unit-converter-section {
        padding: 12px;
    }
    
    .unit-converter-section h3 {
        display: block;
        margin-bottom: 8px;
        text-align: center;
        font-size: 16px;
    }
    
    .converter-controls {
        gap: 8px;
    }
    
    .converter-controls select,
    .converter-controls input {
        min-width: 100px;
        padding: 8px;
        font-size: 16px;
    }
    
    .converter-controls .equals-sign {
        margin: 0 4px;
        font-size: 18px;
    }
    
    .calculator-tabs .ui-tabs-nav li a {
        font-size: 13px;
        padding: 10px 8px;
    }
    
    .calculator-tabs .ui-tabs-panel {
        padding: 12px;
    }
    
    .form-row input,
    .form-row select {
        padding: 10px;
        font-size: 16px;
    }
    
    .form-row label {
        font-size: 15px;
    }
}

/* Fix for jQuery UI tabs z-index issues */
.calculator-tabs .ui-tabs-nav {
    position: relative;
    z-index: 2;
}

.calculator-tabs .ui-tabs-panel {
    position: relative;
    z-index: 1;
}

/* Ensure proper spacing for units */
.form-row span {
    white-space: nowrap;
    color: #666;
    font-size: 14px;
}

/* Disabled input styling */
input:disabled,
select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Focus styles for accessibility */
input:focus,
select:focus {
    outline: 2px solid #0073aa;
    outline-offset: 1px;
}

.calculator-nav-link:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Side-by-side equation and image layout */
.equation-image-container {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.equation-image-container .mathjaxEquationImage1 {
    flex: 0 0 auto;
    margin: 0;
}

.equation-image-container .mathjaxEquation1 {
    flex: 1;
    margin: 0;
    display: flex;
    align-items: center;
    min-height: 80px;
}

/* Newton's Second Law equation display under unit converter */
.newtons-law-equation {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.newtons-law-equation p {
    margin: 8px 0;
    color: #333;
    font-size: 18px;
    font-weight: bold;
}

.newtons-law-equation .mathjaxEquation1 {
    margin: 10px 0;
    background-color: transparent;
    border: none;
    padding: 5px;
}

/* Newton's Second Law standalone section */
.newtons-law-calculator {
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border: 1px solid #ddd;
}

.newtons-law-calculator h3 {
    margin-top: 0;
    color: #333;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

/* Duty cycle and force at duty cycle styling */
.duty-cycle-example,
.duty-cycle-note,
.force-duty-cycle-example,
.ac-duty-cycle-info,
.ac-duty-cycle-note {
    margin: 15px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.duty-cycle-note,
.ac-duty-cycle-note {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.ac-duty-cycle-info ul {
    margin: 5px 0;
    padding-left: 20px;
}

.ac-duty-cycle-info li {
    margin: 3px 0;
}


/* Mobile responsiveness for side-by-side layout */
@media (max-width: 900px) {
    .equation-image-container {
        flex-direction: column;
        gap: 10px;
        margin: 10px 0;
    }
    
    .equation-image-container .mathjaxEquation1 {
        min-height: 50px;
        padding: 8px;
        margin: 0;
    }
    
    .equation-image-container .mathjaxEquationImage1 {
        padding: 5px;
        margin: 0;
    }
    
    /* Fix MathJax equation overflow */
    .mathjaxEquation1,
    .mathjaxEquation,
    .equation-display {
        overflow-x: auto;
        max-width: 100%;
        padding: 8px;
        margin: 10px 0;
        box-sizing: border-box;
    }
    
    .mathjaxEquation1 div,
    .mathjaxEquation div,
    .equation-display div {
        white-space: nowrap;
        min-width: max-content;
    }
    
    /* Make MathJax content responsive */
    .MathJax_Display {
        overflow-x: auto !important;
        overflow-y: hidden !important;
    }
    
    .MathJax {
        max-width: 100% !important;
    }
    
    /* Newton's law equation mobile fixes */
    .newtons-law-equation {
        padding: 8px;
        margin: 10px 0;
    }
    
    .newtons-law-equation p {
        font-size: 16px;
    }
    
    .newtons-law-calculator {
        padding: 8px;
        margin: 10px 0;
    }
}