:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 95%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

h1 {
    color: var(--text);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: -0.025em;
    line-height: 1.2;
    position: relative;
    padding-bottom: 1rem;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
    font-size: 0.875rem;
}

select, input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background-color: var(--surface);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,...");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.025em;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1em 0;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.card {
    background: var(--surface);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

#graphContainer {
    height: 500px;
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin: 2rem 0;
}

#circuitImage {
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

#circuitDescription, #circuitQasm {
    background: var(--background);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin: 1.5rem 0;
    font-size: 0.875rem;
    line-height: 1.6;
    border: 1px solid var(--border);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--surface);
    border-radius: 1rem;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    margin: 15vh auto;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

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

.close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: var(--text);
}

.preferences-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.preference-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    border-radius: inherit;
}
/* Dashboard Styles */
.dashboard {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.dashboard-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

.dashboard-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: var(--background);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.metric-header {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
}

/* Progress Bar */
.progress-bar {
    background: var(--background);
    border-radius: 9999px;
    height: 0.5rem;
    overflow: hidden;
}

.progress {
    background: var(--primary);
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.trend-icon {
    font-weight: bold;
}

.trend-value {
    color: var(--text-light);
}

/* Results History */
.results-history {
    margin-top: 2rem;
}

.results-history h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.history-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--background);
    font-weight: 500;
    color: var(--text-light);
}

tr:hover {
    background: var(--background);
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.status-running {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}

.status-failed {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}


/* Ansatz Constructor Styles */
.ansatz-constructor {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.gate-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.gate-btn {
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.3s;
}

.gate-btn:hover {
    background: var(--surface);
}

.circuit-canvas {
    margin-bottom: 1rem;
}

#qubitLines {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.qubit-line {
    display: flex;
    align-items: center;
    position: relative;
    height: 40px;
    border-bottom: 1px dashed #ccc;
}

.qubit-label {
    width: 50px;
    text-align: right;
    margin-right: 10px;
    font-weight: bold;
}

.circuit-area {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 100px;
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: 0.5rem;
    background: var(--background);
}

.circuit-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.circuit-controls button {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.3s;
}

.circuit-controls button:hover {
    background: darken(var(--primary), 10%);
}

.circuit-visualization {
    margin-top: 1rem;
}

.circuit-visualization img {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        margin: 0;
        border-radius: 0;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
}
