:root {
    --primary: rgba(3, 46, 77, 0.96);
    --background: #ffffff;
    --panels: #f8f9fa;
    --borders: #dee2e6;
    --text: #212529;
    --secondary: #6c757d;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--background);
    color: var(--text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 100;
    transition: top 0.3s;
}

.skip-to-content:focus {
    top: 0;
}

.container-fluid {
    max-width: 100%;
    padding: 0;
}

.card {
    border: 1px solid var(--borders);
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 0;
}

.card-header {
    background-color: var(--panels);
    border-bottom: 1px solid var(--borders);
    border-radius: 12px 12px 0 0;
    padding: 12px 16px;
}

.card-body {
    padding: 16px;
}

.accordion-button {
    background-color: var(--panels);
    color: var(--text);
    font-weight: 500;
}

.accordion-button:not(.collapsed) {
    background-color: var(--primary);
    color: white;
}

.accordion-button:focus {
    box-shadow: 0 0 0 0.25rem rgba(3, 46, 77, 0.25);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: rgba(3, 46, 77, 0.8);
    border-color: rgba(3, 46, 77, 0.8);
    color: white;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

.code-editor {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    min-height: 240px;
    border: none;
    border-radius: 0;
    resize: vertical;
    padding: 16px;
    background-color: #f8f9fa;
    color: #212529;
}

.code-editor:focus {
    background-color: #ffffff;
    outline: none;
}

.editor-actions {
    display: flex;
    gap: 4px;
}

.editor-actions .btn {
    min-width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container {
    position: relative;
    width: 100%;
    height: 500px;
    background-color: white;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    transition: width 0.3s ease;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
    background-image: 
        linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 10;
}

.grid-overlay.active {
    display: block;
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    display: none;
}

.loading-spinner.active {
    display: block;
}

.preview-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}

.device-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.control-group {
    margin-bottom: 16px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 14px;
}

.control-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--borders);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.control-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(3, 46, 77, 0.25);
}

.control-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.control-row .control-input {
    flex: 1;
}

.unit-selector {
    width: auto;
    min-width: 70px;
}

.range-slider {
    width: 100%;
    margin: 8px 0;
}

.color-picker-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-picker-wrapper input[type="color"] {
    width: 50px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--borders);
    border-radius: 6px;
    cursor: pointer;
}

.color-picker-wrapper input[type="text"] {
    flex: 1;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 0.2rem rgba(3, 46, 77, 0.25);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.preset-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.preset-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.preset-card.active {
    border-color: var(--primary);
}

.preset-preview {
    height: 80px;
    background-color: white;
    border: 1px solid var(--borders);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preset-name {
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    color: var(--text);
}

.property-info-table {
    width: 100%;
    border-collapse: collapse;
}

.property-info-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--borders);
}

.property-info-table tr:last-child td {
    border-bottom: none;
}

.property-info-table td:first-child {
    font-weight: 500;
    width: 40%;
    color: var(--secondary);
}

.property-info-table td:last-child {
    color: var(--text);
}

.code-block {
    background-color: #f8f9fa;
    border: 1px solid var(--borders);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 991.98px) {
    .preview-container {
        height: 400px;
    }
    
    .preview-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 767.98px) {
    body {
        padding: 10px;
    }
    
    .preview-container {
        height: 300px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    .preview-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .editor-actions {
        flex-wrap: wrap;
    }
    
    .control-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .unit-selector {
        width: 100%;
    }
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
