/* 
 * DIP Switch Address Calculator Styles
 * Part of the RappoDEV tools collection
 */

/* Only include tool-specific styles here - common calculator styles are in global.css */

/* DIP Switch specific form elements */
.checkbox-container {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.checkbox-container input[type="checkbox"] {
    margin-right: var(--space-sm);
    min-height: 18px; /* Better touch target */
    width: 18px;
    height: 18px;
}

/* Custom reset button for DIP switches */
.reset-button {
    background-color: var(--color-background);
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--border-radius-md);
    padding: var(--space-sm) var(--space-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

.reset-button:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

.reset-button:active {
    transform: scale(0.98);
}

.reset-button::before {
    content: "↺";
    font-weight: bold;
}

/* DIP Switch Container Styles */
.dip-switch-wrapper {
    width: 100%;
    overflow-x: auto; /* Enable horizontal scrolling if needed */
    margin: var(--space-md) 0;
}

.dip-switch-container {
    background-color: rgba(52, 152, 219, 0.05);
    background-image: linear-gradient(to bottom, rgba(52, 152, 219, 0.08), rgba(52, 152, 219, 0.03));
    border-radius: var(--border-radius-md);
    padding: var(--space-md);
    border-left: 4px solid var(--color-primary);
    text-align: center;
    max-width: 100%; /* Ensure container doesn't overflow viewport */
    display: inline-block; /* Allow the container to grow with content */
    min-width: min-content; /* Ensure content doesn't wrap */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    transition: all var(--transition-fast);
}

.dip-switch-container:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    background-color: rgba(52, 152, 219, 0.08);
}

.dip-switch-container h3 {
    color: var(--color-primary-dark);
    margin-bottom: var(--space-md);
    text-align: center;
}

/* Improved DIP switch visualization */
/* Horizontal Layout */
.switch-labels.horizontal, 
.switch-positions.horizontal,
.dip-switch-visual.horizontal {
    display: flex;
    flex-direction: row;
    justify-content: center;
    margin: 6px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    padding: 0;
    align-items: center;
}

.switch-labels.horizontal > div,
.switch-positions.horizontal > div,
.dip-switch-visual.horizontal .switch {
    min-width: 40px;
    width: 40px;
    flex: 0 0 40px;
    text-align: center;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.dip-switch-visual.horizontal {
    display: flex;
    flex-direction: row;
    justify-content: center;
    margin: 6px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    align-items: center;
    gap: 0;
    padding: 0;
}

/* Vertical Layout */
.vertical-layout-container {
    display: grid;
    grid-template-columns: min-content auto min-content;
    gap: var(--space-md);
    align-items: center;
    justify-content: center;
    margin: var(--space-md) auto;
    max-width: 250px;
    overflow-y: auto;
    max-height: 80vh; /* Prevent excessive height on small screens */
}

.switch-labels.vertical {
    display: grid;
    grid-template-rows: repeat(auto-fill, 40px);
    gap: var(--space-md);
    text-align: right;
    font-weight: 500;
    padding-right: var(--space-sm);
}

.dip-switch-visual.vertical {
    display: grid;
    grid-template-rows: repeat(auto-fill, 40px);
    gap: var(--space-md);
    justify-content: center;
    align-items: center;
    min-height: 0; /* Allow container to shrink if needed */
}

.dip-switch-visual.vertical .switch {
    margin: 0 auto;
    box-sizing: border-box;
}

.switch-positions.vertical {
    display: grid;
    grid-template-rows: repeat(auto-fill, 40px);
    gap: var(--space-md);
    text-align: left;
    padding-left: var(--space-sm);
}

.switch-labels.vertical > div,
.switch-positions.vertical > div {
    height: 40px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.switch-labels.vertical > div {
    justify-content: flex-end;
    padding-right: 5px;
}

.switch-positions.vertical > div {
    justify-content: flex-start;
    padding-left: 5px;
}

/* Switch styling */
.switch {
    position: relative;
    width: 40px;
    height: 80px;
    background-color: #f8f9fa; /* Lighter background for better light theme */
    background-image: linear-gradient(to bottom, #ffffff, #f0f0f0); /* Subtle gradient */
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    border: 1px solid #d0d0d0; /* Light border for light theme */
    transition: all var(--transition-fast);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    flex: 0 0 40px;
    min-width: 40px;
}

.switch:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.switch:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Add a subtle glow effect on hover for ON/OFF states */
.switch.on:hover .switch-toggle {
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.8);
}

.switch.off:hover .switch-toggle {
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.8);
}

.switch.vertical {
    width: 80px;
    height: 40px;
    margin: 0;
    box-sizing: border-box;
}

.switch-toggle {
    position: absolute;
    width: 34px;
    height: 40px;
    background-color: white;
    background-image: linear-gradient(to bottom, #ffffff, #f8f8f8); /* Subtle gradient */
    border: 1px solid #cccccc; /* Lighter border in light theme */
    border-radius: var(--border-radius-sm);
    left: 3px;
    top: 2px; /* Added slight top offset for better alignment */
    transition: transform var(--transition-fast), background-color var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.switch.on .switch-toggle {
    transform: translateY(2px); /* Adjusted to account for top offset */
    background-color: #27ae60; /* Green for ON in both themes */
    background-image: linear-gradient(to bottom, #2ecc71, #27ae60); /* Enhanced gradient */
    box-shadow: 0 1px 6px rgba(39, 174, 96, 0.5);
    border-color: #219955; /* Darker border for definition */
}

.switch.off .switch-toggle {
    transform: translateY(36px); /* Adjusted to position at the end of the switch */
    background-color: #e74c3c; /* Red for OFF in both themes */
    background-image: linear-gradient(to bottom, #e74c3c, #c0392b); /* Enhanced gradient */
    box-shadow: 0 1px 6px rgba(231, 76, 60, 0.5);
    border-color: #c0392b; /* Darker border for definition */
}

.switch.vertical .switch-toggle {
    width: 40px;
    height: 34px;
    top: 3px;
    left: 0; /* Ensure toggle starts at the left */
    box-sizing: border-box;
}

.switch.vertical.on .switch-toggle {
    transform: translateX(36px); /* Adjusted to position at the end of the switch */
}

.switch.vertical.off .switch-toggle {
    transform: translateX(0);
}

/* Position labels styling */
.position-on {
    color: #219955; /* Slightly darker green for better contrast in light mode */
    font-weight: bold;
    transition: color var(--transition-fast);
    height: 22px; /* Fixed height for better alignment */
    line-height: 22px; /* Consistent line height */
    display: flex;
    align-items: center;
    justify-content: center;
}

.position-off {
    color: #c0392b; /* Darker red for better contrast in light mode */
    font-weight: bold;
    transition: color var(--transition-fast);
    height: 22px; /* Fixed height for better alignment */
    line-height: 22px; /* Consistent line height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced position indicator styling */
.switch-labels.horizontal > div,
.switch-positions.horizontal > div {
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

/* Active position indicators with background highlights */
.switch-positions .position-on.active {
    color: #219955;
    font-weight: bold;
    background-color: rgba(39, 174, 96, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 1px rgba(39, 174, 96, 0.2); /* Subtle text shadow for emphasis */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.switch-positions .position-off.active {
    color: #c0392b;
    font-weight: bold;
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 1px rgba(231, 76, 60, 0.2); /* Subtle text shadow for emphasis */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Address warning */
.address-warning {
    display: flex;
    align-items: center;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    border-radius: var(--border-radius-md);
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    animation: fadeIn var(--transition-fast);
}

.address-warning.hidden {
    display: none;
}

.address-warning svg {
    margin-right: var(--space-sm);
    flex-shrink: 0;
    stroke: #856404;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments for tablets and mobile */
@media (max-width: 768px) {
    .dip-switch-wrapper {
        overflow-x: auto;
        padding-bottom: 0;
    }
    
    .dip-switch-container {
        padding: var(--space-sm);
    }
    
    .switch-labels.horizontal, 
    .switch-positions.horizontal,
    .dip-switch-visual.horizontal {
        justify-content: center;
        padding: 0;
        flex-wrap: nowrap;
        gap: 0;
        margin: 4px 0;
    }
      /* Make switches smaller on tablets with perfect alignment */
    .switch {
        width: 32px;
        height: 64px;
    }
    
    .switch-toggle {
        width: 26px;
        height: 32px;
    }
    
    .switch.off .switch-toggle {
        transform: translateY(29px); /* Adjusted for smaller switch height */
    }
    
    .switch.vertical {
        width: 64px;
        height: 32px;
    }
    
    .switch.vertical .switch-toggle {
        width: 32px;
        height: 26px;
    }
    
    .switch.vertical.on .switch-toggle {
        transform: translateX(29px); /* Adjusted for smaller switch width */
    }
    
    /* Perfect alignment for switches and labels */
    .switch-labels.horizontal > div,
    .switch-positions.horizontal > div,
    .dip-switch-visual.horizontal .switch {
        min-width: 32px;
        width: 32px;
        flex: 0 0 32px;
        font-size: 0.875rem;
        margin: 0;
        padding: 0;
        text-align: center;
        box-sizing: border-box;
    }
    
    .position-on, 
    .position-off {
        height: 20px;
        line-height: 20px;
    }
    
    /* Better vertical layout for tablets */
    .vertical-layout-container {
        gap: var(--space-sm);
        max-width: 220px;
    }
    
    .switch-labels.vertical,
    .switch-positions.vertical,
    .dip-switch-visual.vertical {
        gap: var(--space-sm);
    }
    
    .switch-labels.vertical > div,
    .switch-positions.vertical > div {
        height: 32px;
    }
    
    .address-warning {
        flex-wrap: wrap;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {    .switch {
        width: 28px;
        height: 56px;
    }
    
    .switch-toggle {
        width: 22px;
        height: 28px;
    }
    
    .switch.off .switch-toggle {
        transform: translateY(25px); /* Adjusted for smaller switch height */
    }
    
    .switch.vertical {
        width: 56px;
        height: 28px;
    }
    
    .switch.vertical .switch-toggle {
        width: 28px;
        height: 22px;
    }
    
    .switch.vertical.on .switch-toggle {
        transform: translateX(25px); /* Adjusted for smaller switch width */
    }
    
    .switch-labels.horizontal > div,
    .switch-positions.horizontal > div,
    .dip-switch-visual.horizontal .switch {
        min-width: 28px;
        width: 28px;
        flex: 0 0 28px;
        font-size: 0.75rem;
        margin: 0;
        padding: 0;
        text-align: center;
        box-sizing: border-box;
    }
    
    .position-on, 
    .position-off {
        height: 18px;
        line-height: 18px;
    }
    
    .dip-switch-visual.horizontal {
        gap: 0;
    }
    
    /* Vertical layout adjustments for small screens */
    .vertical-layout-container {
        max-width: 200px;
        gap: 8px;
    }
    
    .switch-labels.vertical > div,
    .switch-positions.vertical > div {
        height: 28px;
    }
    
    .switch-labels.vertical,
    .switch-positions.vertical,
    .dip-switch-visual.vertical {
        gap: 8px;
    }
}

/* Very small screens */
@media (max-width: 360px) {    .switch {
        width: 24px;
        height: 48px;
    }
    
    .switch-toggle {
        width: 18px;
        height: 24px;
    }
    
    .switch.off .switch-toggle {
        transform: translateY(21px); /* Adjusted for smaller switch height */
    }
    
    .switch.vertical {
        width: 48px;
        height: 24px;
    }
    
    .switch.vertical .switch-toggle {
        width: 24px;
        height: 18px;
    }
    
    .switch.vertical.on .switch-toggle {
        transform: translateX(21px); /* Adjusted for smaller switch width */
    }
    
    .switch-labels.horizontal > div,
    .switch-positions.horizontal > div,
    .dip-switch-visual.horizontal .switch {
        min-width: 24px;
        width: 24px;
        flex: 0 0 24px;
        font-size: 0.7rem;
        margin: 0;
        padding: 0;
        text-align: center;
        box-sizing: border-box;
    }
    
    .position-on, 
    .position-off {
        height: 16px;
        line-height: 16px;
    }
    
    .dip-switch-visual.horizontal {
        gap: 0;
    }
    
    /* Vertical layout adjustments for very small screens */
    .vertical-layout-container {
        max-width: 180px;
        gap: 6px;
    }
    
    .switch-labels.vertical > div,
    .switch-positions.vertical > div {
        height: 24px;
    }
    
    .switch-labels.vertical,
    .switch-positions.vertical,
    .dip-switch-visual.vertical {
        gap: 6px;
    }
    
    /* Override hover effect on very small screens to avoid misalignment */
    .switch:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

/* Ensure smooth transitions between themes */
.switch, .switch-toggle {
    transition: all var(--transition-fast);
}

/* Dark theme adjustments */
body.dark-theme .address-warning {
    background-color: #433c26;
    border-color: #665e3c;
    color: #ffeeba;
}

body.dark-theme .address-warning svg {
    stroke: #ffeeba;
}

body.dark-theme .reset-button {
    background-color: var(--color-secondary-light);
    color: #ff6b6b;
    border-color: #ff6b6b;
}

body.dark-theme .reset-button:hover {
    background-color: rgba(255, 107, 107, 0.2);
}

body.dark-theme .dip-switch-container {
    background-color: rgba(52, 152, 219, 0.15);
    background-image: linear-gradient(to bottom, rgba(52, 152, 219, 0.2), rgba(52, 152, 219, 0.1));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Dark theme for switch elements */
body.dark-theme .switch {
    background-color: #2c3e50; /* Dark blue-gray background for dark theme */
    background-image: linear-gradient(to bottom, #34495e, #2c3e50); /* Dark gradient */
    border-color: #34495e; /* Slightly lighter border for definition */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.dark-theme .switch:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

body.dark-theme .switch-toggle {
    background-color: #485b6e; /* Darker toggle for dark theme */
    background-image: linear-gradient(to bottom, #5d6d7e, #485b6e); /* Dark gradient */
    border-color: #5a6f88;
    box-sizing: border-box;
}

body.dark-theme .switch.on .switch-toggle {
    background-color: #2ecc71; /* Slightly brighter green for dark mode */
    background-image: linear-gradient(to bottom, #2ecc71, #27ae60); /* Green gradient */
    box-shadow: 0 1px 6px rgba(46, 204, 113, 0.5);
    border-color: #27ae60;
}

body.dark-theme .switch.off .switch-toggle {
    background-color: #e74c3c; /* Same red for OFF */
    background-image: linear-gradient(to bottom, #e74c3c, #c0392b); /* Red gradient */
    box-shadow: 0 1px 6px rgba(231, 76, 60, 0.5);
    border-color: #c0392b;
}

/* Enhanced active states for dark theme */
body.dark-theme .position-on {
    color: #2ecc71; /* Brighter green text for dark theme */
}

body.dark-theme .position-off {
    color: #e74c3c; /* Keep consistent red */
}

body.dark-theme .switch-positions .position-on.active {
    color: #2ecc71;
    font-weight: bold;
    background-color: rgba(46, 204, 113, 0.2);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 2px rgba(46, 204, 113, 0.5);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

body.dark-theme .switch-positions .position-off.active {
    color: #e74c3c;
    font-weight: bold;
    background-color: rgba(231, 76, 60, 0.2);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 2px rgba(231, 76, 60, 0.5);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Print styles */
@media print {
    body, .container, .calculator, .output-section, .reference-section, .dip-switch-container {
        background-color: white !important;
        color: black !important;
    }
    
    header, .input-section, .settings-container, .back-button, footer, #printBtn {
        display: none !important;
    }
    
    .dip-switch-container {
        border: 1px solid #222;
        box-shadow: none;
        padding: var(--space-md);
        margin: 0 auto;
        max-width: 500px;
        page-break-inside: avoid;
    }
    
    .calculator, /* Removed for global styling compatibility:
.reference-section {
        box-shadow: none;
        border: none;
    }
*/
    
    .switch {
        border: 1px solid black;
    }
}

/* Override responsive styles to keep buttons side-by-side */
.button-group {
    display: flex !important;
    flex-direction: row !important;
    gap: var(--space-md);
    justify-content: flex-start;
    flex-wrap: wrap;
}

.button-group button {
    width: auto !important;
    margin-right: 0;
    flex: 0 1 auto;
}

/* Ensure buttons have minimum width on small screens */
@media (max-width: 480px) {
    .button-group button {
        min-width: 120px;
    }
    
    .primary-button, .reset-button {
        padding: var(--space-sm) var(--space-sm);
        font-size: 0.9rem;
    }
}

/* DIP Switch specific form elements */
.checkbox-container {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.checkbox-container input[type="checkbox"] {
    margin-right: var(--space-sm);
    min-height: 18px; /* Better touch target */
    width: 18px;
    height: 18px;
}

/* Custom reset button for DIP switches */
.reset-button {
    background-color: var(--color-background);
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: var(--border-radius-md);
    padding: var(--space-sm) var(--space-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

.reset-button:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

.reset-button:active {
    transform: scale(0.98);
}

.reset-button::before {
    content: "↺";
    font-weight: bold;
}

/* DIP Switch Container Styles */
.dip-switch-wrapper {
    width: 100%;
    overflow-x: auto; /* Enable horizontal scrolling if needed */
    margin: var(--space-md) 0;
}

.dip-switch-container {
    background-color: rgba(52, 152, 219, 0.05);
    background-image: linear-gradient(to bottom, rgba(52, 152, 219, 0.08), rgba(52, 152, 219, 0.03));
    border-radius: var(--border-radius-md);
    padding: var(--space-md);
    border-left: 4px solid var(--color-primary);
    text-align: center;
    max-width: 100%; /* Ensure container doesn't overflow viewport */
    display: inline-block; /* Allow the container to grow with content */
    min-width: min-content; /* Ensure content doesn't wrap */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    transition: all var(--transition-fast);
}

.dip-switch-container:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    background-color: rgba(52, 152, 219, 0.08);
}

.dip-switch-container h3 {
    color: var(--color-primary-dark);
    margin-bottom: var(--space-md);
    text-align: center;
}

/* Improved DIP switch visualization */
/* Horizontal Layout */
.switch-labels.horizontal, 
.switch-positions.horizontal,
.dip-switch-visual.horizontal {
    display: flex;
    flex-direction: row;
    justify-content: center;
    margin: 6px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    padding: 0;
    align-items: center;
}

.switch-labels.horizontal > div,
.switch-positions.horizontal > div,
.dip-switch-visual.horizontal .switch {
    min-width: 40px;
    width: 40px;
    flex: 0 0 40px;
    text-align: center;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.dip-switch-visual.horizontal {
    display: flex;
    flex-direction: row;
    justify-content: center;
    margin: 6px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    align-items: center;
    gap: 0;
    padding: 0;
}

/* Vertical Layout */
.vertical-layout-container {
    display: grid;
    grid-template-columns: min-content auto min-content;
    gap: var(--space-md);
    align-items: center;
    justify-content: center;
    margin: var(--space-md) auto;
    max-width: 250px;
    overflow-y: auto;
    max-height: 80vh; /* Prevent excessive height on small screens */
}

.switch-labels.vertical {
    display: grid;
    grid-template-rows: repeat(auto-fill, 40px);
    gap: var(--space-md);
    text-align: right;
    font-weight: 500;
    padding-right: var(--space-sm);
}

.dip-switch-visual.vertical {
    display: grid;
    grid-template-rows: repeat(auto-fill, 40px);
    gap: var(--space-md);
    justify-content: center;
    align-items: center;
    min-height: 0; /* Allow container to shrink if needed */
}

.dip-switch-visual.vertical .switch {
    margin: 0 auto;
    box-sizing: border-box;
}

.switch-positions.vertical {
    display: grid;
    grid-template-rows: repeat(auto-fill, 40px);
    gap: var(--space-md);
    text-align: left;
    padding-left: var(--space-sm);
}

.switch-labels.vertical > div,
.switch-positions.vertical > div {
    height: 40px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.switch-labels.vertical > div {
    justify-content: flex-end;
    padding-right: 5px;
}

.switch-positions.vertical > div {
    justify-content: flex-start;
    padding-left: 5px;
}

/* Switch styling */
.switch {
    position: relative;
    width: 40px;
    height: 80px;
    background-color: #f8f9fa; /* Lighter background for better light theme */
    background-image: linear-gradient(to bottom, #ffffff, #f0f0f0); /* Subtle gradient */
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    border: 1px solid #d0d0d0; /* Light border for light theme */
    transition: all var(--transition-fast);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    flex: 0 0 40px;
    min-width: 40px;
}

.switch:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.switch:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Add a subtle glow effect on hover for ON/OFF states */
.switch.on:hover .switch-toggle {
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.8);
}

.switch.off:hover .switch-toggle {
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.8);
}

.switch.vertical {
    width: 80px;
    height: 40px;
    margin: 0;
    box-sizing: border-box;
}

.switch-toggle {
    position: absolute;
    width: 34px;
    height: 40px;
    background-color: white;
    background-image: linear-gradient(to bottom, #ffffff, #f8f8f8); /* Subtle gradient */
    border: 1px solid #cccccc; /* Lighter border in light theme */
    border-radius: var(--border-radius-sm);
    left: 3px;
    top: 2px; /* Added slight top offset for better alignment */
    transition: transform var(--transition-fast), background-color var(--transition-fast);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.switch.on .switch-toggle {
    transform: translateY(2px); /* Adjusted to account for top offset */
    background-color: #27ae60; /* Green for ON in both themes */
    background-image: linear-gradient(to bottom, #2ecc71, #27ae60); /* Enhanced gradient */
    box-shadow: 0 1px 6px rgba(39, 174, 96, 0.5);
    border-color: #219955; /* Darker border for definition */
}

.switch.off .switch-toggle {
    transform: translateY(36px); /* Adjusted to position at the end of the switch */
    background-color: #e74c3c; /* Red for OFF in both themes */
    background-image: linear-gradient(to bottom, #e74c3c, #c0392b); /* Enhanced gradient */
    box-shadow: 0 1px 6px rgba(231, 76, 60, 0.5);
    border-color: #c0392b; /* Darker border for definition */
}

.switch.vertical .switch-toggle {
    width: 40px;
    height: 34px;
    top: 3px;
    left: 0; /* Ensure toggle starts at the left */
    box-sizing: border-box;
}

.switch.vertical.on .switch-toggle {
    transform: translateX(36px); /* Adjusted to position at the end of the switch */
}

.switch.vertical.off .switch-toggle {
    transform: translateX(0);
}

/* Position labels styling */
.position-on {
    color: #219955; /* Slightly darker green for better contrast in light mode */
    font-weight: bold;
    transition: color var(--transition-fast);
    height: 22px; /* Fixed height for better alignment */
    line-height: 22px; /* Consistent line height */
    display: flex;
    align-items: center;
    justify-content: center;
}

.position-off {
    color: #c0392b; /* Darker red for better contrast in light mode */
    font-weight: bold;
    transition: color var(--transition-fast);
    height: 22px; /* Fixed height for better alignment */
    line-height: 22px; /* Consistent line height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced position indicator styling */
.switch-labels.horizontal > div,
.switch-positions.horizontal > div {
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

/* Active position indicators with background highlights */
.switch-positions .position-on.active {
    color: #219955;
    font-weight: bold;
    background-color: rgba(39, 174, 96, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 1px rgba(39, 174, 96, 0.2); /* Subtle text shadow for emphasis */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.switch-positions .position-off.active {
    color: #c0392b;
    font-weight: bold;
    background-color: rgba(231, 76, 60, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 1px rgba(231, 76, 60, 0.2); /* Subtle text shadow for emphasis */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Address warning */
.address-warning {
    display: flex;
    align-items: center;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    border-radius: var(--border-radius-md);
    padding: var(--space-sm);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    animation: fadeIn var(--transition-fast);
}

.address-warning.hidden {
    display: none;
}

.address-warning svg {
    margin-right: var(--space-sm);
    flex-shrink: 0;
    stroke: #856404;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments for tablets and mobile */
@media (max-width: 768px) {
    .dip-switch-wrapper {
        overflow-x: auto;
        padding-bottom: 0;
    }
    
    .dip-switch-container {
        padding: var(--space-sm);
    }
    
    .switch-labels.horizontal, 
    .switch-positions.horizontal,
    .dip-switch-visual.horizontal {
        justify-content: center;
        padding: 0;
        flex-wrap: nowrap;
        gap: 0;
        margin: 4px 0;
    }
      /* Make switches smaller on tablets with perfect alignment */
    .switch {
        width: 32px;
        height: 64px;
    }
    
    .switch-toggle {
        width: 26px;
        height: 32px;
    }
    
    .switch.off .switch-toggle {
        transform: translateY(29px); /* Adjusted for smaller switch height */
    }
    
    .switch.vertical {
        width: 64px;
        height: 32px;
    }
    
    .switch.vertical .switch-toggle {
        width: 32px;
        height: 26px;
    }
    
    .switch.vertical.on .switch-toggle {
        transform: translateX(29px); /* Adjusted for smaller switch width */
    }
    
    /* Perfect alignment for switches and labels */
    .switch-labels.horizontal > div,
    .switch-positions.horizontal > div,
    .dip-switch-visual.horizontal .switch {
        min-width: 32px;
        width: 32px;
        flex: 0 0 32px;
        font-size: 0.875rem;
        margin: 0;
        padding: 0;
        text-align: center;
        box-sizing: border-box;
    }
    
    .position-on, 
    .position-off {
        height: 20px;
        line-height: 20px;
    }
    
    /* Better vertical layout for tablets */
    .vertical-layout-container {
        gap: var(--space-sm);
        max-width: 220px;
    }
    
    .switch-labels.vertical,
    .switch-positions.vertical,
    .dip-switch-visual.vertical {
        gap: var(--space-sm);
    }
    
    .switch-labels.vertical > div,
    .switch-positions.vertical > div {
        height: 32px;
    }
    
    .address-warning {
        flex-wrap: wrap;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {    .switch {
        width: 28px;
        height: 56px;
    }
    
    .switch-toggle {
        width: 22px;
        height: 28px;
    }
    
    .switch.off .switch-toggle {
        transform: translateY(25px); /* Adjusted for smaller switch height */
    }
    
    .switch.vertical {
        width: 56px;
        height: 28px;
    }
    
    .switch.vertical .switch-toggle {
        width: 28px;
        height: 22px;
    }
    
    .switch.vertical.on .switch-toggle {
        transform: translateX(25px); /* Adjusted for smaller switch width */
    }
    
    .switch-labels.horizontal > div,
    .switch-positions.horizontal > div,
    .dip-switch-visual.horizontal .switch {
        min-width: 28px;
        width: 28px;
        flex: 0 0 28px;
        font-size: 0.75rem;
        margin: 0;
        padding: 0;
        text-align: center;
        box-sizing: border-box;
    }
    
    .position-on, 
    .position-off {
        height: 18px;
        line-height: 18px;
    }
    
    .dip-switch-visual.horizontal {
        gap: 0;
    }
    
    /* Vertical layout adjustments for small screens */
    .vertical-layout-container {
        max-width: 200px;
        gap: 8px;
    }
    
    .switch-labels.vertical > div,
    .switch-positions.vertical > div {
        height: 28px;
    }
    
    .switch-labels.vertical,
    .switch-positions.vertical,
    .dip-switch-visual.vertical {
        gap: 8px;
    }
}

/* Very small screens */
@media (max-width: 360px) {    .switch {
        width: 24px;
        height: 48px;
    }
    
    .switch-toggle {
        width: 18px;
        height: 24px;
    }
    
    .switch.off .switch-toggle {
        transform: translateY(21px); /* Adjusted for smaller switch height */
    }
    
    .switch.vertical {
        width: 48px;
        height: 24px;
    }
    
    .switch.vertical .switch-toggle {
        width: 24px;
        height: 18px;
    }
    
    .switch.vertical.on .switch-toggle {
        transform: translateX(21px); /* Adjusted for smaller switch width */
    }
    
    .switch-labels.horizontal > div,
    .switch-positions.horizontal > div,
    .dip-switch-visual.horizontal .switch {
        min-width: 24px;
        width: 24px;
        flex: 0 0 24px;
        font-size: 0.7rem;
        margin: 0;
        padding: 0;
        text-align: center;
        box-sizing: border-box;
    }
    
    .position-on, 
    .position-off {
        height: 16px;
        line-height: 16px;
    }
    
    .dip-switch-visual.horizontal {
        gap: 0;
    }
    
    /* Vertical layout adjustments for very small screens */
    .vertical-layout-container {
        max-width: 180px;
        gap: 6px;
    }
    
    .switch-labels.vertical > div,
    .switch-positions.vertical > div {
        height: 24px;
    }
    
    .switch-labels.vertical,
    .switch-positions.vertical,
    .dip-switch-visual.vertical {
        gap: 6px;
    }
    
    /* Override hover effect on very small screens to avoid misalignment */
    .switch:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
}

/* Ensure smooth transitions between themes */
.switch, .switch-toggle {
    transition: all var(--transition-fast);
}

/* Dark theme adjustments */
body.dark-theme .address-warning {
    background-color: #433c26;
    border-color: #665e3c;
    color: #ffeeba;
}

body.dark-theme .address-warning svg {
    stroke: #ffeeba;
}

body.dark-theme .reset-button {
    background-color: var(--color-secondary-light);
    color: #ff6b6b;
    border-color: #ff6b6b;
}

body.dark-theme .reset-button:hover {
    background-color: rgba(255, 107, 107, 0.2);
}

body.dark-theme .dip-switch-container {
    background-color: rgba(52, 152, 219, 0.15);
    background-image: linear-gradient(to bottom, rgba(52, 152, 219, 0.2), rgba(52, 152, 219, 0.1));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* Dark theme for switch elements */
body.dark-theme .switch {
    background-color: #2c3e50; /* Dark blue-gray background for dark theme */
    background-image: linear-gradient(to bottom, #34495e, #2c3e50); /* Dark gradient */
    border-color: #34495e; /* Slightly lighter border for definition */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.dark-theme .switch:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

body.dark-theme .switch-toggle {
    background-color: #485b6e; /* Darker toggle for dark theme */
    background-image: linear-gradient(to bottom, #5d6d7e, #485b6e); /* Dark gradient */
    border-color: #5a6f88;
    box-sizing: border-box;
}

body.dark-theme .switch.on .switch-toggle {
    background-color: #2ecc71; /* Slightly brighter green for dark mode */
    background-image: linear-gradient(to bottom, #2ecc71, #27ae60); /* Green gradient */
    box-shadow: 0 1px 6px rgba(46, 204, 113, 0.5);
    border-color: #27ae60;
}

body.dark-theme .switch.off .switch-toggle {
    background-color: #e74c3c; /* Same red for OFF */
    background-image: linear-gradient(to bottom, #e74c3c, #c0392b); /* Red gradient */
    box-shadow: 0 1px 6px rgba(231, 76, 60, 0.5);
    border-color: #c0392b;
}

/* Enhanced active states for dark theme */
body.dark-theme .position-on {
    color: #2ecc71; /* Brighter green text for dark theme */
}

body.dark-theme .position-off {
    color: #e74c3c; /* Keep consistent red */
}

body.dark-theme .switch-positions .position-on.active {
    color: #2ecc71;
    font-weight: bold;
    background-color: rgba(46, 204, 113, 0.2);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 2px rgba(46, 204, 113, 0.5);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

body.dark-theme .switch-positions .position-off.active {
    color: #e74c3c;
    font-weight: bold;
    background-color: rgba(231, 76, 60, 0.2);
    border-radius: var(--border-radius-sm);
    padding: 0 4px;
    text-shadow: 0 0 2px rgba(231, 76, 60, 0.5);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Print styles */
@media print {
    body, .container, .calculator, .output-section, .reference-section, .dip-switch-container {
        background-color: white !important;
        color: black !important;
    }
    
    header, .input-section, .settings-container, .back-button, footer, #printBtn {
        display: none !important;
    }
    
    .dip-switch-container {
        border: 1px solid #222;
        box-shadow: none;
        padding: var(--space-md);
        margin: 0 auto;
        max-width: 500px;
        page-break-inside: avoid;
    }
    
    .calculator, /* Removed for global styling compatibility:
.reference-section {
        box-shadow: none;
        border: none;
    }
*/
    
    .switch {
        border: 1px solid black;
    }
}

/* Override responsive styles to keep buttons side-by-side */
.button-group {
    display: flex !important;
    flex-direction: row !important;
    gap: var(--space-md);
    justify-content: flex-start;
    flex-wrap: wrap;
}

.button-group button {
    width: auto !important;
    margin-right: 0;
    flex: 0 1 auto;
}

/* Ensure buttons have minimum width on small screens */
@media (max-width: 480px) {
    .button-group button {
        min-width: 120px;
    }
    
    .primary-button, .reset-button {
        padding: var(--space-sm) var(--space-sm);
        font-size: 0.9rem;
    }
}

