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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #6b7280;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --bg-light: #f9fafb;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --text-dark: #1f2937;
  --text-light: #6b7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  color: var(--text-dark);
  min-height: 100vh;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeIn 0.3s ease;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

.modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.beaker-icon, .failure-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.modal-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-dark);
}

.modal-header p {
  color: var(--text-light);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.safety-alert {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.warning-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.alert-title {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 4px;
}

.safety-alert p {
  color: #b45309;
  font-size: 13px;
  line-height: 1.5;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  user-select: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active:not(:disabled) {
  transform: scale(0.95);
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-light);
  border-color: var(--secondary);
}

.btn-danger {
  background: var(--danger);
  color: white;
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-outline {
  border: 2px solid var(--border);
  color: var(--text-dark);
  background: transparent;
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-light);
}

.btn-small {
  padding: 8px 12px;
  font-size: 12px;
}

.btn-danger-small {
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger-small:hover:not(:disabled) {
  background: #fee2e2;
}

/* Header */
.header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon {
  font-size: 24px;
  margin-right: 8px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
}

.app-subtitle {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.goggles-btn {
  padding: 8px 12px;
  border-radius: 9999px;
  border: 1px solid;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  color: var(--danger);
  border-color: #fecaca;
  background: #fee2e2;
  animation: pulse 2s infinite;
}

.goggles-btn.active {
  color: var(--success);
  border-color: #d1fae5;
  background: #ecfdf5;
  animation: none;
}

/* Main Layout */
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.container.hidden {
  display: none;
}

.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  gap: 0;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
}

.experiment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.experiment-btn {
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  font-weight: 600;
}

.experiment-btn:hover {
  background: var(--bg-light);
  border-color: var(--border);
}

.experiment-btn.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.1);
}

.experiment-btn .name {
  display: block;
  margin-bottom: 4px;
}

.experiment-btn .desc {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 400;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.experiment-btn.active .desc {
  color: var(--primary);
  opacity: 0.8;
}

.procedure-box {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.procedure-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}

.procedure-steps {
  list-style-position: inside;
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.8;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.procedure-steps li {
  color: var(--text-light);
}

/* Workspace */
.workspace {
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.placeholder {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.placeholder-icon {
  font-size: 96px;
  opacity: 0.3;
}

.placeholder-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-light);
}

.placeholder-subtitle {
  font-size: 14px;
  color: #9ca3af;
}

.workspace-content {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 24px;
  padding: 24px;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.workspace-content.hidden {
  display: none;
}

/* Reagents Section */
.reagents-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 8px;
}

.reagent-panel {
  background: var(--bg-white);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reagent-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  text-align: center;
}

.reagent-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.reagent-bottle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  border: none;
}

.reagent-bottle:hover:not(:disabled) {
  background: var(--bg-light);
}

.reagent-bottle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.reagent-bottle:active:not(:disabled) {
  transform: scale(0.95);
}

.bottle-visual {
  width: 48px;
  height: 64px;
  border-radius: 6px 6px 12px 12px;
  border: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottle-visual::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: #e5e7eb;
  border-bottom: 1px solid var(--border);
}

.bottle-visual::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 2px;
  right: 2px;
  height: 12px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
}

.bottle-label {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: var(--text-dark);
}

/* Bench Section */
.bench-section {
  background: var(--bg-white);
  border-radius: 20px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
}

.controls-top {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  margin-bottom: 16px;
}

.tube-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.test-tube {
  position: relative;
  width: 80px;
  height: 240px;
  transform: scale(1.2);
}

.tube-body {
  width: 100%;
  height: 100%;
  border-radius: 0 0 50% 50%;
  border: 3px solid var(--border);
  background: transparent;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.tube-liquid {
  width: 100%;
  height: 0;
  background: transparent;
  transition: height 0.5s ease, background-color 1s ease;
  border-radius: 20px 20px 0 0;
  position: relative;
}

.tube-liquid::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 100%;
}

.tube-bubbles {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.bubble {
  position: absolute;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: bubble-rise 1.5s ease-in infinite;
}

@keyframes bubble-rise {
  0% {
    bottom: 0;
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 1;
  }
  100% {
    bottom: 100%;
    opacity: 0;
    transform: scale(1.5);
  }
}

.tube-rim {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  height: 16px;
  background: transparent;
  border: 2px solid var(--border);
  border-radius: 50%;
  z-index: 10;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.tube-stand {
  margin-top: 8px;
  width: 160px;
  height: 12px;
  background: #9ca3af;
  border-radius: 2px;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tube-stand::before,
.tube-stand::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 12px;
  background: #6b7280;
  border-radius: 2px;
}

.tube-stand::before {
  left: 16px;
}

.tube-stand::after {
  right: 16px;
}

.controls-bottom {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
  margin-top: 16px;
}

/* Notebook Section */
.notebook-section {
  background: var(--bg-white);
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  min-height: 320px;
}

.notebook-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notebook-header h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
}

.time-display {
  font-size: 10px;
  color: var(--text-light);
  font-family: 'Courier New', monospace;
}

.notebook-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: rgba(248, 250, 252, 0.5);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
}

.notebook-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  opacity: 0.5;
}

.log-entry {
  padding: 8px;
  border-radius: 6px;
  border-left: 3px solid var(--border);
  animation: slideInLog 0.3s ease;
}

@keyframes slideInLog {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.log-entry.info {
  background: #f3f4f6;
  border-left-color: var(--secondary);
  color: var(--text-dark);
}

.log-entry.warning {
  background: #fffbeb;
  border-left-color: var(--warning);
  color: #92400e;
}

.log-entry.success {
  background: #ecfdf5;
  border-left-color: var(--success);
  color: #065f46;
}

.log-entry.error {
  background: #fee2e2;
  border-left-color: var(--danger);
  color: #991b1b;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Responsive */
@media (max-width: 1400px) {
  .workspace-content {
    gap: 16px;
    padding: 16px;
  }
}

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 280px 1fr;
  }

  .workspaceContent {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 16px;
  }
}
