/* Rep5x G-code Viewer Styles */

:root {
    --toolbar-bg: #ffffff;
    --toolbar-border: #e5e7eb;
    --toolbar-surface: #f9fafb;
    --toolbar-hover: #f3f4f6;
    --accent: #32D74B;
    --accent-dim: rgba(50, 215, 75, 0.1);
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: #f9fafb;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Toolbar Container */
.toolbar-container {
    background: var(--toolbar-bg);
    border-bottom: 2px solid var(--toolbar-border);
    flex-shrink: 0;
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 0 1rem;
    height: 56px;
    background: var(--toolbar-bg);
}

.toolbar-row.secondary {
    height: 48px;
    background: var(--toolbar-surface);
    border-top: 1px solid var(--toolbar-border);
}

/* Toolbar Sections */
.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    height: 100%;
    border-right: 1px solid var(--toolbar-border);
}

.toolbar-section:last-child {
    border-right: none;
}

.toolbar-section.flex-1 {
    flex: 1;
}

.section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Toolbar Buttons */
.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.toolbar-btn:hover:not(:disabled) {
    background: var(--toolbar-hover);
    color: var(--text-primary);
    border-color: var(--toolbar-border);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

.toolbar-btn.primary {
    width: auto;
    padding: 0 1.25rem;
    gap: 0.5rem;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
}

.toolbar-btn.primary:hover:not(:disabled) {
    background: #2bc441;
}

.toolbar-btn.primary:disabled {
    background: var(--toolbar-border);
    color: var(--text-muted);
}

.toolbar-btn svg {
    width: 18px;
    height: 18px;
}

/* File Upload Zone */
.file-zone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    background: var(--toolbar-surface);
    border: 2px dashed var(--toolbar-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 180px;
}

.file-zone:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.file-zone.has-file {
    border-style: solid;
    border-color: var(--accent);
    background: var(--accent-dim);
}

.file-zone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-zone-icon {
    width: 22px;
    height: 22px;
    color: var(--text-muted);
}

.file-zone.has-file .file-zone-icon {
    color: var(--accent);
}

.file-zone-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.file-zone.has-file .file-zone-text {
    color: var(--text-primary);
    font-weight: 500;
}

/* Slider Controls */
.slider-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-control input[type="range"] {
    width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--toolbar-border);
    border-radius: 3px;
    cursor: pointer;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.slider-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid white;
}

.slider-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 3rem;
    text-align: right;
}

/* Progress Bar */
.progress-bar-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    position: relative;
    flex: 1;
    height: 8px;
    background: var(--toolbar-border);
    border-radius: 4px;
    cursor: pointer;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #4ade80);
    border-radius: 4px;
    transition: width 0.05s linear;
    pointer-events: none;
}

.progress-bar-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: grab;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.progress-bar-thumb:hover {
    transform: translate(-50%, -50%) scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.progress-bar-thumb:active,
.progress-bar-thumb.dragging {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 2px 10px rgba(50, 215, 75, 0.5);
}

.progress-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 3rem;
}

/* Position Display */
.position-display {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.position-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem;
    background: var(--toolbar-surface);
    border: 1px solid var(--toolbar-border);
    border-radius: 6px;
    min-width: 70px;
}

.position-item.wide {
    min-width: 80px;
}

.position-item.narrow {
    min-width: 50px;
}

.position-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.position-label.x { color: #dc2626; }
.position-label.y { color: #16a34a; }
.position-label.z { color: #2563eb; }
.position-label.c { color: #d97706; }
.position-label.b { color: #9333ea; }
.position-label.layer { color: var(--text-muted); }

.position-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    width: 55px;
    text-align: right;
    display: inline-block;
}

.position-value.angle {
    width: 45px;
}

.position-value.layer-value {
    width: 25px;
}

.position-unit {
    font-size: 0.625rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* View Options */
.view-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.view-toggle:hover {
    background: var(--toolbar-hover);
}

.view-toggle input {
    display: none;
}

.view-toggle-indicator {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid var(--toolbar-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    background: white;
}

.view-toggle input:checked + .view-toggle-indicator {
    background: var(--accent);
    border-color: var(--accent);
}

.view-toggle input:checked + .view-toggle-indicator svg {
    opacity: 1;
}

.view-toggle-indicator svg {
    width: 10px;
    height: 10px;
    color: white;
    opacity: 0;
}

.view-toggle-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.view-toggle:hover .view-toggle-text {
    color: var(--text-primary);
}

/* Dropdown Select */
.toolbar-select {
    background: white;
    border: 2px solid var(--toolbar-border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 150px;
}

.toolbar-select:hover {
    border-color: var(--accent);
}

.toolbar-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Collision Badge */
.collision-badge {
    display: none;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #dc2626;
}

.collision-badge.visible {
    display: flex;
}

.collision-badge svg {
    width: 14px;
    height: 14px;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    overflow: hidden;
}

.canvas-container canvas {
    width: 100%;
    height: 100%;
    cursor: default;
}

/* Canvas Overlay Hints */
.canvas-hint {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.625rem 1.25rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--toolbar-border);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.canvas-hint-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.canvas-hint-item kbd {
    padding: 0.25rem 0.5rem;
    background: var(--toolbar-surface);
    border: 1px solid var(--toolbar-border);
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    font-weight: 500;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(249, 250, 251, 0.95);
    z-index: 100;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--toolbar-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animation uses shared @keyframes spin from shared/styles.css */

.loading-text {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Settings Panel */
.settings-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: var(--toolbar-bg);
    border-left: 2px solid var(--toolbar-border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 50;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,0.08);
}

.settings-panel.open {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--toolbar-border);
    background: var(--toolbar-surface);
}

.settings-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-content {
    padding: 1.25rem;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0;
}

.settings-input {
    flex: 1;
    background: white;
    border: 2px solid var(--toolbar-border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.settings-input-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    min-width: 60px;
}

/* Divider */
.toolbar-divider {
    width: 1px;
    height: 28px;
    background: var(--toolbar-border);
    margin: 0 0.5rem;
}

/* File Info Panel */
.file-info-panel {
    padding: 0.75rem 1.25rem;
    background: var(--toolbar-surface);
    border-top: 1px solid var(--toolbar-border);
    display: none;
}

.file-info-panel.visible {
    display: block;
}

/* Footer visibility */
#shared-footer {
    flex-shrink: 0;
}

#shared-footer footer {
    margin-top: 0;
}

/* Canvas Drop Overlay */
.canvas-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(50, 215, 75, 0.1);
    border: 3px dashed var(--accent);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: none;
}

.canvas-drop-overlay.active {
    display: flex;
}

.canvas-drop-content {
    text-align: center;
    color: var(--accent);
}

.canvas-drop-content svg {
    margin: 0 auto 0.75rem;
}

.canvas-drop-content p {
    font-size: 1.125rem;
    font-weight: 600;
}

/* ==========================================
   Responsive Styles
   ========================================== */

/* Large screens */
@media (max-width: 1400px) {
    .position-display {
        gap: 0.5rem;
    }
    .position-item {
        padding: 0.25rem 0.4rem;
        min-width: auto;
    }
    .slider-control input[type="range"] {
        width: 80px;
    }
}

/* Medium screens */
@media (max-width: 1200px) {
    .toolbar-row {
        height: auto;
        min-height: 56px;
        padding: 0.5rem 0.75rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .toolbar-row.secondary {
        min-height: 44px;
    }

    .toolbar-section {
        border-right: none;
        padding: 0.375rem 0.5rem;
        flex-shrink: 0;
    }

    .toolbar-section.flex-1 {
        flex: 1 1 200px;
        min-width: 200px;
        order: 10;
        width: 100%;
    }

    .section-label {
        display: none;
    }

    .file-zone {
        min-width: 140px;
        padding: 0.5rem 0.75rem;
    }

    .position-display {
        gap: 0.375rem;
    }

    .position-item {
        padding: 0.25rem 0.375rem;
    }

    .position-unit {
        display: none;
    }

    .view-toggle {
        padding: 0.25rem 0.5rem;
    }

    .view-toggle-text {
        font-size: 0.75rem;
    }

    .toolbar-select {
        min-width: 120px;
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Small/tablet screens */
@media (max-width: 900px) {
    .toolbar-container {
        position: relative;
    }

    .toolbar-row {
        padding: 0.5rem;
        gap: 0.375rem;
    }

    /* Hide position display on small screens - moved to settings or overlay */
    .position-display {
        display: none;
    }

    /* Compact file zone */
    .file-zone {
        min-width: 44px;
        width: 44px;
        padding: 0.5rem;
        justify-content: center;
    }

    .file-zone-text {
        display: none;
    }

    .file-zone.has-file {
        width: auto;
        min-width: 44px;
        max-width: 120px;
    }

    .file-zone.has-file .file-zone-text {
        display: block;
    }

    /* Compact playback controls */
    .toolbar-btn.primary {
        padding: 0 0.75rem;
        font-size: 0.8125rem;
    }

    .toolbar-btn.primary span {
        display: none;
    }

    .toolbar-btn.primary svg {
        margin: 0;
    }

    .slider-control input[type="range"] {
        width: 60px;
    }

    .slider-value {
        min-width: 2.5rem;
        font-size: 0.75rem;
    }

    /* Progress takes full width on its own row */
    .toolbar-section.flex-1 {
        flex: 1 1 100%;
        min-width: 100%;
        order: 20;
        padding: 0.25rem 0.5rem;
    }

    .progress-bar-container {
        gap: 0.5rem;
    }

    .progress-text {
        min-width: 2.5rem;
        font-size: 0.75rem;
    }

    /* Secondary toolbar - horizontal scroll */
    .toolbar-row.secondary {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .toolbar-row.secondary::-webkit-scrollbar {
        display: none;
    }

    .toolbar-row.secondary .toolbar-section {
        flex-shrink: 0;
    }

    .view-toggle-text {
        font-size: 0.6875rem;
    }

    /* Canvas hints - compact */
    .canvas-hint {
        padding: 0.5rem 0.75rem;
        gap: 0.75rem;
    }

    .canvas-hint-item span {
        display: none;
    }
}

/* Mobile screens */
@media (max-width: 600px) {
    .toolbar-row {
        padding: 0.375rem;
        gap: 0.25rem;
    }

    .toolbar-section {
        padding: 0.25rem 0.375rem;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
    }

    .toolbar-btn svg {
        width: 16px;
        height: 16px;
    }

    .toolbar-btn.primary {
        height: 32px;
        padding: 0 0.625rem;
    }

    .toolbar-divider {
        display: none;
    }

    .slider-control input[type="range"] {
        width: 50px;
    }

    .slider-value {
        min-width: 2rem;
        font-size: 0.6875rem;
    }

    /* Even more compact secondary toolbar */
    .toolbar-row.secondary {
        min-height: 36px;
        padding: 0.25rem 0.375rem;
    }

    .view-toggle {
        padding: 0.125rem 0.375rem;
        gap: 0.375rem;
    }

    .view-toggle-indicator {
        width: 14px;
        height: 14px;
    }

    .view-toggle-indicator svg {
        width: 8px;
        height: 8px;
    }

    .view-toggle-text {
        font-size: 0.625rem;
    }

    .toolbar-select {
        min-width: 100px;
        padding: 0.25rem 0.375rem;
        font-size: 0.6875rem;
    }

    /* Progress bar adjustments */
    .progress-bar {
        height: 6px;
    }

    .progress-bar-thumb {
        width: 14px;
        height: 14px;
    }

    /* Hide canvas hints on mobile */
    .canvas-hint {
        display: none;
    }

    /* Settings panel full width */
    .settings-panel {
        width: 100%;
    }
}

/* Touch-friendly adjustments */
@media (pointer: coarse) {
    .toolbar-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .view-toggle {
        min-height: 44px;
    }

    .progress-bar {
        height: 10px;
    }

    .progress-bar-thumb {
        width: 20px;
        height: 20px;
    }

    .slider-control input[type="range"] {
        height: 8px;
    }

    .slider-control input[type="range"]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }
}
