/* Component styles - buttons, forms, inputs, error handling */

/* Accessibility utilities */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus indicators for better accessibility */
.focus-visible,
*:focus-visible {
    outline: 2px solid var(--accent-primary) !important;
    outline-offset: 2px !important;
    border-radius: 4px;
}

/* Hide outline for mouse users */
*:focus:not(.focus-visible) {
    outline: none;
}

/* Enhanced focus for interactive elements - but exclude inputs and selects that have their own styles */
button:focus-visible {
    outline: 2px solid var(--accent-primary) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(var(--accent-primary-rgb, 0, 123, 255), 0.25) !important;
}

/* For inputs and selects, remove the accessibility outline and let existing focus styles handle appearance */
.input-wrapper input:focus-visible,
.input-wrapper select:focus-visible {
    outline: none !important; /* Remove the accessibility outline */
    /* Let the existing focus styles handle the appearance */
}

/* Remove default fieldset borders while keeping accessibility benefits */
fieldset {
    border: none;
    margin: 0;
    padding: 0;
}

fieldset legend {
    /* Keep legends hidden for screen readers but not visible */
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Common header button style */
.header-button {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-medium);
    padding: 0;
    font-family: 'Material Icons';
    font-size: 20px;
    display: grid;
    place-items: center;
}

/* Only apply hover effects on devices that support hover */
@media (hover: hover) {
    .header-button:hover {
        background-color: var(--text-secondary);
        color: var(--text-white);;
    }

    /* Reset button - extends header-button */
    .reset-button:hover {
        background-color: var(--btn-danger-bg);
        color: var(--text-white);
    }
}

.copy-url-button.success {
    background-color: var(--btn-success-bg) !important;
    color: var(--text-white) !important;
}

/* Unit toggle button - override Material Icons font for text display */
.unit-toggle {
    font-family: 'Roboto Mono', monospace !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
}

/* Screen number badge */
.screen-number {
    position: absolute;
    top: 0;
    left: 16px;
    background: var(--bg-secondary);
    border: 2px solid;
    border-top: none;
    border-radius: 0 0 8px 8px;
    height: 28px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-white);
    z-index: 10;
    min-width: 32px;
    box-sizing: border-box;
    box-shadow: var(--shadow-medium);
    cursor: default;
}

/* Remove screen button (visible) */
.remove-screen {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: color 0.2s ease;
    line-height: 1;
    padding: 0;
    font-family: 'Material Icons';
}

/* Only apply hover effects on devices that support hover */
@media (hover: hover) {
    .remove-screen:hover {
        color: var(--text-primary);
    }
}

/* Hide remove button when only one screen */
.remove-screen.hidden {
    display: none;
}

/* Form fields */
.field-wrapper {
    margin-bottom: 0.75rem;
}

.field-wrapper label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 0.5rem;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(var(--accent-primary-rgb, 78, 205, 196), 0.2);
}

.input-wrapper input.input-error,
.input-wrapper select.input-error {
    border-color: var(--error-border);
    box-shadow: 0 0 0 2px rgba(var(--error-border-rgb, 220, 53, 69), 0.2);
}

.input-wrapper select {
    appearance: none;
    background-image: var(--select-arrow-svg);
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 0.6rem auto;
}

.unit {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 0.85rem;
    pointer-events: none;
}

.resolution,
.diagonal-scaling {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

/* Add screen button - now positioned in visualizer controls */
#add-screen {
    width: 40px;
    height: 40px;
    font-size: 20px;
    padding: 0;
    background-color: var(--btn-primary-bg);
    color: var(--text-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--btn-primary-bg-rgb, 0, 123, 255), 0.3);
    transition: all 0.2s ease;
    display: grid;
    place-items: center;
    font-weight: 300;
    margin-right: 1rem;
    font-family: 'Material Icons';
}

/* Only apply hover effects on devices that support hover */
@media (hover: hover) {
    #add-screen:hover {
        background-color: var(--btn-primary-hover);
        box-shadow: 0 4px 12px rgba(var(--btn-primary-bg-rgb, 0, 123, 255), 0.4);
    }
}

/* Mode toggle component for visualizer */
.mode-toggle {
    position: relative;
    width: 120px;
    height: 40px;
    display: inline-block;
    background-color: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: var(--shadow-medium);
    transition: all 0.2s ease;
}

.mode-toggle input[type="radio"] {
    display: none;
}

.mode-toggle .slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 56px;
    height: 36px;
    background-color: var(--text-secondary);
    border-radius: 18px;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-medium);
    z-index: 0;
}

.mode-toggle.fov-selected .slider {
    left: 62px;
}

.mode-toggle label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50%;
    text-align: center;
    z-index: 1;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: color 0.3s ease;
    white-space: nowrap;
}

.mode-toggle label:first-of-type {
    left: 0;
}

.mode-toggle label:last-of-type {
    right: 0;
}

/* Default state: Size is highlighted (white), FOV is not (gray) */
.mode-toggle label[for="realSize"] {
    color: var(--text-white) !important;
}

.mode-toggle label[for="fovBased"] {
    color: var(--text-secondary) !important;
}

/* FOV selected state: FOV is highlighted (white), Size is not (gray) */
.mode-toggle.fov-selected label[for="realSize"] {
    color: var(--text-secondary) !important;
}

.mode-toggle.fov-selected label[for="fovBased"] {
    color: var(--text-white) !important;
}

/* Error handling and validation */
.validation-errors {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: opacity 0.2s ease-in-out;
}

.error-header {
    color: var(--error-text);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.error-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.error-item {
    background-color: var(--error-bg);
    border: none;
    border-left: 4px solid var(--error-border);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    color: var(--error-text);
    font-size: 0.8rem;
    line-height: 1.4;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 1px 3px rgba(var(--error-border-rgb, 220, 53, 69), 0.1);
    opacity: 0;
    animation-fill-mode: forwards;
}

/* Animations */
@keyframes slideIn {
    from { 
        opacity: 0; 
        transform: translateY(-5px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(-2px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Responsive styles for add-screen button and mode-toggle */
@media (max-width: 768px) {
    .view-mode-controls {
        justify-content: center;
    }

    .mode-toggle {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    #add-screen {
        width: 36px;
        height: 36px;
        font-size: 18px;
        margin-right: 0.75rem;
    }
    
    .mode-toggle {
        width: 100px;
        height: 36px;
    }
    
    .mode-toggle .slider {
        width: 46px;
        height: 32px;
    }
    
    .mode-toggle.fov-selected .slider {
        left: 52px;
    }
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: 8px;
    box-shadow: var(--shadow-large);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-primary);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    font-family: 'Material Icons';
    font-size: 20px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px 24px;
}

.info-section {
    margin-bottom: 24px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.info-section p {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-section p:last-child {
    margin-bottom: 0;
}

.info-section strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 16px;
    }
    
    .modal-header {
        padding: 16px 20px 12px;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .modal-body {
        padding: 16px 20px 20px;
    }
    
    .info-section {
        margin-bottom: 20px;
    }
    
    .info-section h3 {
        font-size: 1rem;
    }
}

/* Amazon Link Styles */
.amazon-link-container {
    margin-top: 0.75rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.amazon-icon {
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
}

.amazon-icon .material-icons {
    font-size: 1rem;
}

.amazon-link {
    display: inline-flex;
    align-items: baseline;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-decoration: none;
    padding: 0.2rem 0.2rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-weight: normal;
}

.amazon-text {
    font-family: "Amazon Ember", Arial, sans-serif;
    font-weight: bold;
    text-transform: lowercase;
}

.amazon-link:hover {
    color: var(--text-secondary);
}

.amazon-link:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
