/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

/* Header */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  gap: 2rem;
}

.header-text {
  flex: 1;
  text-align: center;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

header p {
  font-size: 1rem;
  opacity: 0.9;
}

/* Language Selector */
.language-selector {
  display: flex;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.5rem;
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.lang-button {
  padding: 0.5rem 1rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.lang-button.active {
  background: white;
  color: #667eea;
  border-color: white;
  font-weight: 600;
}

.lang-button.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

/* Main Content */
main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.project-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.project-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #e0e0e0;
}

.project-card-content {
  padding: 1.5rem;
}

.project-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: #667eea;
}

.project-card p {
  color: #666;
  font-size: 0.9rem;
}

.project-card .soc-badge {
  display: inline-block;
  background: #f0f0f0;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.8rem;
  color: #555;
  margin-top: 0.5rem;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 3rem;
  color: #999;
  font-size: 1.1rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: white;
  margin: 2rem auto;
  padding: 2rem;
  border-radius: 12px;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.close {
  position: absolute;
  right: 1.5rem;
  top: 1.5rem;
  font-size: 2rem;
  font-weight: bold;
  color: #999;
  cursor: pointer;
  line-height: 1;
}

.close:hover {
  color: #333;
}

/* Project Details */
#project-details h2 {
  color: #667eea;
  margin-bottom: 0.5rem;
  padding-right: 2rem;
}

#project-description {
  color: #666;
  margin-bottom: 1.5rem;
}

.readme-content {
  background: #f9f9f9;
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1.5rem 0;
  max-height: 400px;
  overflow-y: auto;
}

.readme-content h1 {
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 0.2rem;
  color: #333;
}

.readme-content h2 {
  font-size: 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 0.15rem;
  color: #444;
}

.readme-content h3 {
  font-size: 1.1rem;
  margin-top: 1.25rem;
  margin-bottom: 0.1rem;
  color: #555;
}

.readme-content p {
  margin-top: 0;
  margin-bottom: 1rem;
}

.readme-content h1 + p,
.readme-content h2 + p,
.readme-content h3 + p {
  margin-top: 0;
}

.readme-content ul, .readme-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.readme-content code {
  background: #e8e8e8;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

.readme-content pre {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.readme-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* Flash Controls */
.flash-controls {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  background: white;
  cursor: pointer;
}

.form-group input[type="checkbox"] {
  margin-right: 0.5rem;
  cursor: pointer;
}

/* Buttons */
button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

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

/* Progress Bar */
.progress-container {
  margin: 1.5rem 0;
}

.progress-bar {
  width: 100%;
  height: 30px;
  background: #f0f0f0;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  width: 0%;
  transition: width 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

#progress-text {
  text-align: center;
  color: #666;
  font-weight: 500;
}

/* Console Output */
.console-container {
  margin: 1.5rem 0;
}

.console-output {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 1rem;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  height: 200px;
  overflow-y: auto;
  line-height: 1.4;
}

.console-output .log-info {
  color: #66d9ef;
}

.console-output .log-success {
  color: #a6e22e;
}

.console-output .log-error {
  color: #f92672;
}

.console-output .log-warning {
  color: #e6db74;
}

/* Port Selection Container */
.port-selection-top {
  background: #f9f9f9;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  border: 1px solid #e0e0e0;
}

.port-selection-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.selected-port-display {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #999;
  font-style: italic;
}

.selected-port-display.port-selected {
  color: #667eea;
  font-weight: 500;
  font-style: normal;
}

/* Port Selection Popup Modal */
.port-modal-content {
  max-width: 500px;
  width: 90%;
}

.port-select-container {
  margin-top: 1rem;
}

/* Ports List */
.ports-list {
  background: #f9f9f9;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #333;
  min-height: 50px;
}

.ports-list.no-agent {
  color: #999;
  font-style: italic;
}

.ports-popup-list {
  background: #f9f9f9;
  padding: 0;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #333;
  min-height: 50px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
}

.ports-popup-list.no-agent {
  color: #999;
  font-style: italic;
}

.port-item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: white;
  border-radius: 6px;
  border: 2px solid #ddd;
  cursor: pointer;
  transition: all 0.2s;
}

.port-item:hover {
  border-color: #667eea;
  background: #f8f9ff;
  transform: translateX(4px);
}

.port-item.selected {
  border-color: #667eea;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.port-item:last-child {
  margin-bottom: 0;
}

.port-item-popup {
  padding: 0.2rem 0.5rem;
  margin-bottom: 1px;
  background: white;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1.2;
}

.port-item-popup:hover {
  background: #f0f0f5;
}

.port-item-popup.selected {
  background: #667eea;
  color: white;
  font-weight: 500;
}

.port-item-popup:last-child {
  margin-bottom: 0;
}

/* Disclaimer Modal */
.disclaimer-modal {
  z-index: 2000;
}

.disclaimer-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.disclaimer-content {
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
}

.disclaimer-content h2 {
  color: #667eea;
  margin-bottom: 1rem;
  font-size: 1.75rem;
  text-align: center;
}

.disclaimer-text {
  background: #f9f9f9;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
}

.disclaimer-text h1 {
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 0.2rem;
  color: #333;
}

.disclaimer-text h2 {
  font-size: 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 0.15rem;
  color: #444;
}

.disclaimer-text h3 {
  font-size: 1.1rem;
  margin-top: 1.25rem;
  margin-bottom: 0.1rem;
  color: #555;
}

.disclaimer-text p {
  margin-bottom: 1rem;
  line-height: 1.6;
}

.disclaimer-text ul, .disclaimer-text ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.disclaimer-text strong {
  color: #667eea;
  font-weight: 600;
}

.disclaimer-text hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 1.5rem 0;
}

.disclaimer-actions {
  display: flex;
  justify-content: center;
}

.disclaimer-actions button {
  min-width: 150px;
  font-size: 1.1rem;
  padding: 1rem 2rem;
}

.disclaimer-actions button:disabled,
.disclaimer-actions button.disabled {
  background: #ccc !important;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none !important;
  box-shadow: none !important;
}

.disclaimer-actions button:disabled:hover,
.disclaimer-actions button.disabled:hover {
  transform: none !important;
  box-shadow: none !important;
}

/* Serial Monitor Modal */
.monitor-modal-content {
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
}

.monitor-controls {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid #e0e0e0;
  flex-wrap: wrap;
}

.monitor-control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.monitor-control-group label {
  font-weight: 500;
  color: #333;
  margin: 0;
}

.baudrate-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  background: white;
  cursor: pointer;
  font-family: 'Courier New', monospace;
}

.baudrate-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.monitor-status-container {
  margin-left: auto;
}

.monitor-status-indicator {
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  display: inline-block;
}

.monitor-status-indicator.connected {
  color: #28a745;
  background: #d4edda;
}

.monitor-status-indicator.disconnected {
  color: #999;
  background: #f0f0f0;
}

.monitor-status-indicator.status-connected {
  color: #28a745;
  background: #d4edda;
}

.monitor-status-indicator.status-disconnected {
  color: #999;
  background: #f0f0f0;
}

.monitor-status-indicator.status-suspended {
  color: #fd7e14;
  background: #fff3cd;
}

.monitor-output-container {
  margin-bottom: 1rem;
}

.monitor-output {
  width: 100%;
  height: 400px;
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 1rem;
  border: 1px solid #444;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.4;
  resize: vertical;
  overflow-y: auto;
}

.monitor-output:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.monitor-output.readonly {
  cursor: default;
  background: #1a1a1a;
}

.monitor-input-container {
  margin-bottom: 1rem;
}

.monitor-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  background: white;
}

.monitor-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.monitor-input::placeholder {
  color: #999;
  font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 1rem;
  }
  
  .header-text {
    text-align: center;
  }
  
  .language-selector {
    justify-content: center;
  }
  
  header h1 {
    font-size: 1.5rem;
  }
  
  .projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
  }
  
  .modal-content {
    margin: 1rem;
    padding: 1.5rem;
    width: 95%;
  }
  
  .button-group {
    flex-direction: column;
  }
  
  .button-group button {
    width: 100%;
  }
  
  .disclaimer-content {
    width: 95%;
  }
  
  .disclaimer-text {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }
  
  .disclaimer-content h2 {
    font-size: 1.5rem;
  }
  
  .disclaimer-actions button {
    min-width: 120px;
    font-size: 1rem;
    padding: 0.875rem 1.5rem;
  }
}
