/* EC2 Manager 2.0 Main Stylesheet */

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f7fa;
  padding: 0;
  margin: 0;
}

/* Layout */
header {
  background-color: #0c2340;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.logo-container {
  display: flex;
  align-items: center;
}

.logo {
  height: 40px;
  margin-right: 1rem;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

footer {
  background-color: #0c2340;
  color: white;
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
}

/* User Info */
.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.username {
  font-weight: bold;
}

.role {
  background-color: #e0e7ff;
  color: #0c2340;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.logout-btn {
  background-color: transparent;
  border: 1px solid white;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background-color: white;
  color: #0c2340;
}

/* Form Styles */
.management-panel {
  background-color: white;
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

input, select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

input:focus, select:focus {
  outline: none;
  border-color: #0c2340;
  box-shadow: 0 0 0 2px rgba(12, 35, 64, 0.1);
}

.submit-btn {
  background-color: #0c2340;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.submit-btn:hover {
  background-color: #183b64;
}

.instructions {
  margin-bottom: 1.5rem;
  color: #666;
}

.schedule-info {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: #f8f9fa;
  border-left: 3px solid #0c2340;
  font-size: 0.9rem;
}

/* Table Styles */
.data-section {
  background-color: white;
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.table-container {
  overflow-x: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  table-layout: auto;
  min-width: 1200px; /* Ensure table has a minimum width to fit all columns */
}

thead {
  background-color: #f8f9fa;
}

th, td {
  padding: 0.75rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px; /* Limit cell width */
}

/* Column-specific widths */
th:nth-child(1), td:nth-child(1) { /* Copy button column */
  width: 60px;
  min-width: 60px;
}

th:nth-child(2), td:nth-child(2) { /* Name column */
  width: 15%;
}

th:nth-child(3), td:nth-child(3) { /* Instance ID column */
  width: 15%;
}

th:nth-child(4), td:nth-child(4) { /* State column */
  width: 8%;
}

th:nth-child(5), td:nth-child(5) { /* Private IP Address column */
  width: 12%;
}

th:nth-child(6), td:nth-child(6) { /* Instance Type column */
  width: 10%;
}

th:nth-child(7), td:nth-child(7) { /* GPU Type column */
  width: 8%;
}

th:nth-child(8), td:nth-child(8) { /* Owner column */
  width: 12%;
}

th:nth-child(9), td:nth-child(9) { /* Schedule column */
  width: 10%;
}

th {
  font-weight: 600;
  color: #555;
}

th.sortable {
  cursor: pointer;
  position: relative;
  user-select: none;
}

th.sortable:hover {
  background-color: #e9ecef;
}

tr:hover {
  background-color: #f8f9fa;
}

.selected-row {
  background-color: #e0e7ff !important;
}

/* Instance state styling */
.running-instance {
  border-left: 4px solid #28a745;
}

.stopped-instance {
  border-left: 4px solid #dc3545;
}

.pending-instance {
  border-left: 4px solid #ffc107;
}

.state-running {
  color: #28a745;
  font-weight: 600;
}

.state-stopped {
  color: #dc3545;
  font-weight: 600;
}

.state-pending {
  color: #ffc107;
  font-weight: 600;
}

/* Button Styles */
.copy-btn {
  background-color: #0c2340;
  color: white;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.copy-btn:hover {
  background-color: #183b64;
}

/* API Response Styling */
.api-response {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 4px;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.success {
  background-color: #d4edda;
  border-left: 4px solid #28a745;
  color: #155724;
}

.error {
  background-color: #f8d7da;
  border-left: 4px solid #dc3545;
  color: #721c24;
}

/* Loading Indicator */
.loading {
  display: none;
  padding: 1rem;
  text-align: center;
  color: #666;
  font-style: italic;
}

.error-message {
  padding: 1rem;
  background-color: #f8d7da;
  color: #721c24;
  border-radius: 4px;
  margin: 1rem 0;
}

/* Tooltip for truncated content */
td:hover {
  position: relative;
}

td:hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 1;
  background: #fff;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 3px;
  white-space: normal;
  max-width: 300px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  display: none; /* Only show if content is truncated */
}

td[title]:hover::after {
  display: block;
}

/* Responsive Styles */
@media (max-width: 1400px) {
  main {
    max-width: 100%;
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  header {
    flex-direction: column;
    padding: 1rem;
  }
  
  .logo-container {
    margin-bottom: 1rem;
  }
  
  main {
    padding: 1rem;
  }
  
  .management-panel, .data-section {
    padding: 1rem;
  }
  
  th, td {
    padding: 0.5rem 0.25rem;
    font-size: 0.9rem;
  }
  
  .user-info {
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
  }
}
