:root {
  --color-text: rgb(0, 54, 129);
  --color-bg-hover: #f0f0f0;
  --color-bg-active: rgb(236, 244, 255);
  --color-active: rgb(236, 244, 255);
  --color-border: #ddd;
  --color-icon: #6b7280;
  --api-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --api-radius: 8px;
}

.api-key-management {
  width: 100%;
  position: static;
  margin: -var(--spacing-lg);
  font-family: Arial, sans-serif;
}

.api-key-management .api-key-management__card {
  margin: 0;
  padding: 0;
  width: 100%;
  background: white;
  border-radius: var(--api-radius);
  box-shadow: var(--api-shadow);
}

.api-key-management .api-key-management__card-content {
  padding: 20px;
}

/* Section Layout */
.api-key-management .api-key-management__section {
  margin-bottom: 32px;
}

.api-key-management .api-key-management__section-header {
  margin-bottom: 24px;
}

.api-key-management .api-key-management__title {
  font-size: 24px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 20px;
}

/* Form Layout */
.api-key-management .api-key-management__form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.api-key-management .api-key-management__form-group {
  flex: 1;
  margin-bottom: 16px;
}

.api-key-management .api-key-management__label {
  display: block;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

.api-key-management .api-key-management__input-wrapper {
  position: relative;
}

/* Form Controls */
.api-key-management .api-key-management__input,
.api-key-management .api-key-management__select {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 16px;
  color: var(--color-text);
  font-size: 16px;
  transition: all 0.2s;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background-color: white;
  font-family: Arial, sans-serif;
}

.api-key-management .api-key-management__select-wrapper {
  position: relative;
  width: 100%;
}

.api-key-management .api-key-management__select {
  appearance: none;
  padding-right: 30px;
}

.api-key-management .api-key-management__select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 12px;
  color: var(--color-text);
}

.api-key-management .api-key-management__input:hover,
.api-key-management .api-key-management__select:hover {
  border-color: var(--color-active);
}

.api-key-management .api-key-management__input:focus,
.api-key-management .api-key-management__select:focus {
  outline: none;
  border-color: var(--color-active);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Button Group */
.api-key-management .api-key-management__button-group {
  display: flex;
  justify-content: flex-start;
  margin-top: 24px;
  width: 100%;
  gap: 16px;
}

/* Button Styles */
.api-key-management .api-key-management__button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  color: var(--color-text);
  font-size: 14px;
  transition: all 0.2s;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background-color: var(--color-bg-active);
  cursor: pointer;
  font-family: Arial, sans-serif;
  min-width: 120px;
  border-style: solid;
  border-width: 1px;
  line-height: normal;
  min-height: auto;
  max-width: none;
  outline: none;
  flex: 0 0 auto;
}

.api-key-management .api-key-management__button:hover {
  background-color: var(--color-bg-hover);
  transform: translateY(-2px);
}

.api-key-management .api-key-management__button--primary {
  margin-left: auto;
  background-color: var(--color-active);
  color: #ffffff;
  border: none;
}

.api-key-management .api-key-management__button--primary:hover {
  background-color: var(--color-bg-active);
  color: #333333;
  border: 1px solid var(--color-border);
}

.api-key-management .api-key-management__button--primary:active {
  background-color: var(--color-bg-active);
  color: var(--color-active);
}

/* Table Styles - High Priority */
.api-key-management .api-key-management__table-container {
  width: 100% !important;
  overflow-x: auto;
  border: 2px solid var(--color-border) !important;
  border-radius: var(--api-radius);
  background-color: white !important;
  box-sizing: border-box;
}

.api-key-management .api-key-management__table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  border-radius: var(--api-radius);
  overflow: hidden;
  background-color: white !important;
  box-sizing: border-box;
}

/* Table Header Cells - High Priority */
.api-key-management .api-key-management__table th {
  padding: 12px 16px !important;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-icon);
  background-color: var(--color-bg-hover) !important;
  border-bottom: 2px solid var(--color-border) !important;
  border-right: 1px solid var(--color-border) !important;
  box-sizing: border-box;
}

.api-key-management .api-key-management__table th:last-child {
  border-right: none !important;
}

/* Table Data Cells - High Priority */
.api-key-management .api-key-management__table td {
  padding: 12px 16px !important;
  font-size: 14px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border) !important;
  border-right: 1px solid var(--color-border) !important;
  vertical-align: middle;
  background-color: white !important;
  box-sizing: border-box;
}

.api-key-management .api-key-management__table td:last-child {
  border-right: none !important;
}

.api-key-management .api-key-management__table tr:last-child td {
  border-bottom: none !important;
}

/* Universal Table Cell Borders - Maximum Priority */
.api-key-management__table-cell,
.api-key-management .api-key-management__table-cell {
  border-right: 1px solid var(--color-border) !important;
  border-bottom: 1px solid var(--color-border) !important;
  background-color: white !important;
  padding: 12px 16px !important;
  box-sizing: border-box !important;
}

.api-key-management__table-cell:last-child,
.api-key-management .api-key-management__table-cell:last-child {
  border-right: none !important;
}

/* Ensure all table elements have borders regardless of class */
table.api-key-management__table th,
table.api-key-management__table td,
.api-key-management__table th,
.api-key-management__table td {
  border-right: 1px solid var(--color-border) !important;
  border-bottom: 1px solid var(--color-border) !important;
}

table.api-key-management__table th:last-child,
table.api-key-management__table td:last-child,
.api-key-management__table th:last-child,
.api-key-management__table td:last-child {
  border-right: none !important;
}

.api-key-management .api-key-management__table tr:hover td {
  background-color: var(--color-bg-hover);
}

/* Table Actions */
.api-key-management .api-key-management__table-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 2px;
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background-color: white;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
  min-width: 70px;
  font-family: Arial, sans-serif;
}

.api-key-management .api-key-management__table-button:hover {
  background-color: var(--color-bg-hover);
}

.api-key-management .api-key-management__table-button--delete {
  color: #ef4444;
  border-color: #ef4444;
  background-color: white;
}

.api-key-management .api-key-management__table-button--delete:hover {
  background-color: #fef2f2;
  border-color: #dc2626;
}

/* Responsive Layout */
@media (max-width: 1024px) {
  .api-key-management {
    width: 100%;
  }

  .api-key-management .api-key-management__card {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .api-key-management {
    margin: -var(--spacing-lg);
  }

  .api-key-management .api-key-management__form-row {
    flex-direction: column;
  }

  .api-key-management .api-key-management__form-group {
    width: 100%;
  }
}

/* ========== DEFAULT API KEY STYLES ========== */

/* Default API Key Display Card */
.default-api-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--api-radius);
  box-shadow: var(--api-shadow);
  margin-bottom: 24px;
  color: white;
}

.default-api-card-content {
  padding: 20px;
}

.default-api-title {
  display: flex;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.default-icon {
  margin-right: 8px;
  font-size: 20px;
}

.default-api-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#default-api-name {
  font-size: 16px;
  font-weight: 500;
}

#default-api-key-masked {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  opacity: 0.9;
}

.change-default-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.change-default-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

/* No Default API Key Warning Card */
.no-default-api-card {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: var(--api-radius);
  padding: 20px;
  margin-bottom: 24px;
  text-align: center;
  color: #856404;
}

.warning-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.warning-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.warning-desc {
  font-size: 14px;
  opacity: 0.8;
}

/* Default Badge in Table */
.default-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  min-width: 60px;
  display: inline-block;
}

.default-badge.default-yes {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.default-badge.default-no {
  background: #f8f9fa;
  color: #6c757d;
  border: 1px solid #dee2e6;
}

/* Set Default Button */
.set-default-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #28a745;
  color: white;
  border: 1px solid #28a745;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin: 2px;
  transition: all 0.2s;
  min-width: 90px;
  font-family: Arial, sans-serif;
}

.set-default-btn:hover {
  background: #218838;
  border-color: #1e7e34;
}

/* Already Default Button (Disabled State) */
.set-default-btn:disabled,
button[disabled].set-default-btn {
  background: #6c757d !important;
  border-color: #6c757d !important;
  color: white !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}

.edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #17a2b8;
  color: white;
  border: 1px solid #17a2b8;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin: 2px;
  transition: all 0.2s;
  min-width: 60px;
  font-family: Arial, sans-serif;
}

.edit-btn:hover {
  background: #138496;
  border-color: #117a8b;
}

/* Default Star Icon in Table */
.default-star-icon {
  margin-right: 6px;
  color: #ffc107;
  font-size: 14px;
}

/* API Key Row Highlighting for Default */
.api-key-item.is-default {
  background-color: #f8f9fa;
  border-left: 4px solid #28a745;
}

.api-key-item.is-default td {
  background-color: #f8f9fa;
}

.api-key-item.is-default:hover td {
  background-color: #e9ecef;
}

/* Action Buttons Container */
.api-key-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

/* Table Cell Content */
.api-key-management__table-cell {
  padding: 12px 16px !important;
}

/* Ensure buttons are visible */
.api-key-actions button {
  display: inline-flex !important;
  visibility: visible !important;
}

/* Responsive adjustments for default elements */
@media (max-width: 768px) {
  .default-api-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .api-key-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  
  .set-default-btn,
  .edit-btn {
    width: 100%;
    text-align: center;
    margin-right: 0;
  }
}
