/* --- Global Customizations & Variables --- */
:root {
    --bg-dark: #090b0f;
    --panel-bg: rgba(22, 27, 37, 0.65);
    --panel-bg-solid: #161b25;
    --border-light: rgba(255, 255, 255, 0.07);
    --border-focus: rgba(0, 242, 254, 0.4);
    
    /* Premium Color Palette */
    --accent-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --accent-primary: #00f2fe;
    --accent-indigo: #4facfe;
    --accent-success: #00e676;
    --accent-warning: #ffb300;
    --accent-error: #ff3d00;
    
    /* Text Colors */
    --text-primary: #f5f6fa;
    --text-secondary: #a4b0be;
    --text-muted: #747d8c;
    
    /* Fonts */
    --font-outfit: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-inter: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Shadow effects */
    --glow-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
    --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* --- Resets --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(0, 242, 254, 0.03) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(79, 172, 254, 0.04) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-inter);
    min-height: 100vh;
    padding: 1.5rem;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    font-family: var(--font-outfit);
    font-weight: 700;
}

/* --- App Layout --- */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Header --- */
.app-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
}

.app-header h1 {
    font-size: 2.2rem;
    letter-spacing: -0.5px;
    font-weight: 800;
}

.app-header .highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.2);
    color: var(--accent-primary);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* --- Dashboard --- */
.dashboard {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* --- Glassmorphic Panels --- */
.glass {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--panel-shadow);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Sidebar Panels --- */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}

.panel-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.panel-section h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-num {
    background: var(--accent-gradient);
    color: var(--bg-dark);
    font-size: 0.8rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-outfit);
}

/* --- Drag & Drop Zone --- */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.01);
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(0, 242, 254, 0.03);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.1);
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.upload-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.drop-zone .main-text {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.drop-zone .sub-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* --- Form Controls --- */
.gauge-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.input-pair {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

input[type="number"] {
    background: #11141c;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    color: var(--text-primary);
    font-family: var(--font-mono);
    outline: none;
    font-size: 0.85rem;
    width: 100%;
    transition: all 0.2s ease;
}

input[type="number"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.1);
}

/* Sliders */
.slider-control {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

#digi-threshold-val, #digi-radius-val {
    font-family: var(--font-mono);
    color: var(--accent-primary);
    font-weight: 600;
}

input[type="range"] {
    appearance: none;
    background: #252c3a;
    height: 6px;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 0 5px rgba(0, 242, 254, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.info-note {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 0.25rem;
}

/* --- Back Link --- */
.sidebar-footer {
    margin-top: 0.5rem;
    text-align: center;
    border-top: 1px solid var(--border-light);
    padding-top: 1rem;
}

.nav-link {
    color: var(--accent-indigo);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

/* --- Workspace Area --- */
.workspace-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Visualizer Grid */
.visualizer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.visualizer-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 0.75rem;
}

.visualizer-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: -0.25rem;
}

/* Canvas Container styling */
.canvas-container {
    background-color: #0b0d12;
    background-image: 
        linear-gradient(45deg, #11141c 25%, transparent 25%), 
        linear-gradient(-45deg, #11141c 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #11141c 75%), 
        linear-gradient(-45deg, transparent 75%, #11141c 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    min-height: 420px;
    max-height: 520px;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem;
}

.canvas-container canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.digi-input-container, .digi-preview-container {
    cursor: crosshair;
}

.canvas-placeholder {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    pointer-events: none;
    position: absolute;
}

/* --- Buttons --- */
.btn {
    font-family: var(--font-outfit);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
    background: var(--accent-gradient);
    color: var(--bg-dark);
    box-shadow: var(--glow-shadow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 242, 254, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

/* --- Toast Notification --- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: -300px;
    background: #161b25;
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--accent-primary);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    transition: right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    right: 2rem;
}

.toast-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 4px rgba(0, 242, 254, 0.4));
}

.toast-message {
    font-size: 0.88rem;
    font-weight: 500;
}

/* --- Utility classes --- */
.hidden {
    display: none !important;
}

/* Button style reset for nav-link */
button.nav-link {
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    display: inline-block;
    padding: 0;
    text-align: center;
    width: 100%;
}

/* --- Help Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 5, 8, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 550px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 2.2rem;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease;
    outline: none;
}

.modal-close:hover {
    color: var(--accent-primary);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.help-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 0.5rem 0;
}

.help-emoji {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 4px rgba(0, 242, 254, 0.3));
    margin-top: 0.15rem;
}

.help-text h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.help-text p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.help-text strong {
    color: var(--accent-primary);
}

/* --- Edit Mode Styles --- */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    width: 100%;
}

.edit-status-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 179, 0, 0.15);
    border: 1px solid rgba(255, 179, 0, 0.3);
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    animation: fadeIn 0.2s ease-out;
}

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

.edit-status-badge {
    color: var(--accent-warning);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: none;
    transform: none;
}

.btn-xs {
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 4px;
}

/* Disabled styling overlay for inputs when editing */
.control-panel input:disabled, 
.control-panel .drop-zone.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.preview-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.checkbox-container {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.checkbox-container:hover {
    color: var(--text-primary);
}

.checkbox-container input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    background: #11141c;
    cursor: pointer;
    position: relative;
    outline: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-container input[type="checkbox"]:checked {
    background: var(--accent-indigo);
    border-color: var(--accent-primary);
}

.checkbox-container input[type="checkbox"]:checked::after {
    content: "✓";
    font-size: 9px;
    color: var(--bg-dark);
    font-weight: 800;
}

.checkbox-container input[type="checkbox"]:focus-visible {
    border-color: var(--accent-primary);
    box-shadow: 0 0 5px rgba(0, 242, 254, 0.3);
}

.checkbox-container input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Help Tips Styling --- */
.help-tips {
    margin-top: 1.25rem;
    padding: 1.1rem;
    background: rgba(0, 242, 254, 0.03);
    border: 1px solid rgba(0, 242, 254, 0.12);
    border-radius: 8px;
}

.help-tips h4 {
    font-size: 0.85rem;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.help-tips ul {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding-left: 1.2rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

/* --- Responsive overrides --- */
@media(max-width: 1024px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
        max-height: none;
    }
    
    .visualizer-grid {
        grid-template-columns: 1fr;
    }
}
