/*
 * AutoPlanX Agents — Custom CSS
 * Tailwind handles utilities. This file adds:
 *   - Component classes (nav-item, widget-card, btn, input-field, etc.)
 *   - Status indicators
 *   - Shimmer loading animation
 *   - Flash message styles
 *   - Table styles
 *
 * Dark theme: bg-gray-950 base, bg-gray-900 surfaces, bg-gray-800 borders
 */

/* ── Nav items ─────────────────────────────────────────────────────────────── */

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: rgb(156 163 175);       /* gray-400 */
  text-decoration: none;
  transition: background-color 0.1s, color 0.1s;
  white-space: nowrap;
}

.nav-item:hover {
  background-color: rgb(31 41 55);  /* gray-800 */
  color: rgb(229 231 235);          /* gray-200 */
}

.nav-item-active {
  background-color: rgb(30 27 75 / 0.6);  /* indigo-950/60 */
  color: rgb(165 180 252);                  /* indigo-300 */
  font-weight: 500;
}

.nav-icon {
  font-size: 0.875rem;
  width: 1.125rem;
  text-align: center;
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background-color: rgb(31 41 55);  /* gray-800 */
  margin: 0.375rem 0.625rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.1s, background-color 0.1s;
  border: none;
  text-decoration: none;
}

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

.btn-primary {
  background-color: rgb(99 102 241);  /* indigo-500 */
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: rgb(79 70 229);  /* indigo-600 */
}

.btn-secondary {
  background-color: rgb(31 41 55);  /* gray-800 */
  color: rgb(209 213 219);           /* gray-300 */
  border: 1px solid rgb(55 65 81);   /* gray-700 */
}

.btn-secondary:hover:not(:disabled) {
  background-color: rgb(55 65 81);  /* gray-700 */
}

.btn-danger {
  background-color: rgb(127 29 29 / 0.6);  /* red-900/60 */
  color: rgb(252 165 165);                   /* red-300 */
  border: 1px solid rgb(153 27 27);          /* red-800 */
}

.btn-danger:hover:not(:disabled) {
  background-color: rgb(153 27 27 / 0.6);
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
}

/* ── Input fields ──────────────────────────────────────────────────────────── */

.input-field {
  background-color: rgb(17 24 39);      /* gray-900 */
  border: 1px solid rgb(55 65 81);      /* gray-700 */
  border-radius: 0.375rem;
  color: rgb(229 231 235);              /* gray-200 */
  font-size: 0.8125rem;
  padding: 0.4375rem 0.75rem;
  outline: none;
  transition: border-color 0.1s;
}

.input-field:focus {
  border-color: rgb(99 102 241);        /* indigo-500 */
  box-shadow: 0 0 0 1px rgb(99 102 241 / 0.3);
}

.input-field::placeholder {
  color: rgb(75 85 99);                 /* gray-600 */
}

/* ── Widget cards ──────────────────────────────────────────────────────────── */

.widget-card {
  background-color: rgb(17 24 39);     /* gray-900 */
  border: 1px solid rgb(31 41 55);     /* gray-800 */
  border-radius: 0.5rem;
  padding: 1rem;
}

.widget-panel {
  background-color: rgb(17 24 39);
  border: 1px solid rgb(31 41 55);
  border-radius: 0.5rem;
}

.widget-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgb(31 41 55);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.widget-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgb(156 163 175);   /* gray-400 */
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.widget-body {
  padding: 1rem;
}

/* ── Status indicators ─────────────────────────────────────────────────────── */

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.status-ok     { background-color: rgb(52 211 153); }   /* emerald-400 */
.status-warn   { background-color: rgb(251 191 36); }   /* amber-400 */
.status-error  { background-color: rgb(248 113 113); }  /* red-400 */
.status-unknown { background-color: rgb(75 85 99); }    /* gray-600 */

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
}

.badge-green  { background-color: rgb(6 78 59 / 0.5); color: rgb(52 211 153); }
.badge-red    { background-color: rgb(127 29 29 / 0.5); color: rgb(248 113 113); }
.badge-yellow { background-color: rgb(120 53 15 / 0.5); color: rgb(251 191 36); }
.badge-gray   { background-color: rgb(31 41 55); color: rgb(156 163 175); }
.badge-indigo { background-color: rgb(30 27 75 / 0.5); color: rgb(165 180 252); }

/* ── Tables ────────────────────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(107 114 128);        /* gray-500 */
  border-bottom: 1px solid rgb(31 41 55);
}

.data-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid rgb(17 24 39);  /* gray-900 — subtle */
  color: rgb(209 213 219);                  /* gray-300 */
}

.data-table tr:hover td {
  background-color: rgb(17 24 39 / 0.5);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ── Shimmer loading animation ─────────────────────────────────────────────── */

.shimmer {
  background: linear-gradient(
    90deg,
    rgb(31 41 55) 25%,
    rgb(55 65 81) 50%,
    rgb(31 41 55) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.25rem;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.shimmer-text {
  height: 0.75rem;
  border-radius: 0.25rem;
}

.shimmer-block {
  height: 4rem;
  border-radius: 0.5rem;
}

/* ── Flash messages ────────────────────────────────────────────────────────── */

.flash-zone {
  position: relative;
}

.flash {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  animation: fadeIn 0.2s ease;
}

.flash-success {
  background-color: rgb(6 78 59 / 0.5);
  color: rgb(52 211 153);
  border: 1px solid rgb(6 78 59);
}

.flash-error {
  background-color: rgb(127 29 29 / 0.5);
  color: rgb(248 113 113);
  border: 1px solid rgb(127 29 29);
}

.flash-info {
  background-color: rgb(30 27 75 / 0.5);
  color: rgb(165 180 252);
  border: 1px solid rgb(49 46 129);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Alert boxes ───────────────────────────────────────────────────────────── */

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid;
  font-size: 0.8125rem;
}

.alert-info    { background: rgb(30 27 75 / 0.3); border-color: rgb(49 46 129); color: rgb(165 180 252); }
.alert-success { background: rgb(6 78 59 / 0.3);  border-color: rgb(6 78 59);   color: rgb(52 211 153); }
.alert-warning { background: rgb(120 53 15 / 0.3); border-color: rgb(146 64 14); color: rgb(251 191 36); }
.alert-error   { background: rgb(127 29 29 / 0.3); border-color: rgb(153 27 27); color: rgb(248 113 113); }

/* ── HTMX loading state ────────────────────────────────────────────────────── */

.htmx-request .htmx-indicator { display: inline; }
.htmx-indicator { display: none; }

/* Spinner for inline use */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgb(55 65 81);
  border-top-color: rgb(99 102 241);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Misc utilities ────────────────────────────────────────────────────────── */

.section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(107 114 128);
  margin-bottom: 0.75rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: rgb(107 114 128);
  font-size: 0.875rem;
}

.divider {
  height: 1px;
  background-color: rgb(31 41 55);
  margin: 1.5rem 0;
}

/* ── Form elements — S1 ── */
.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #9ca3af;
  margin-bottom: 0.375rem;
}
.form-input {
  display: block;
  width: 100%;
  background-color: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: #e5e7eb;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
}
.form-input::placeholder { color: #6b7280; }
select.form-input { cursor: pointer; }
.form-hint {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: #6b7280;
}

/* ── Buttons — S1 ── */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background-color: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  color: #d1d5db;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn-secondary:hover {
  background-color: #374151;
  border-color: #4b5563;
}

/* ── Alert ── */
.alert-success {
  background-color: rgba(16,185,129,0.1);
  border: 1px solid #059669;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: #34d399;
}

/* ── Badge extras ── */
.badge-emerald { background-color: rgba(16,185,129,0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }

/* ── Flash messages — S3 ── */
#flash-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}
.flash-success, .flash-error, .flash-warn, .flash-info {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: flash-in 0.2s ease-out;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateX(1rem); }
  to   { opacity: 1; transform: translateX(0); }
}
.flash-success {
  background: rgba(16,185,129,0.12);
  border: 1px solid #059669;
  color: #34d399;
}
.flash-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid #dc2626;
  color: #f87171;
}
.flash-warn {
  background: rgba(245,158,11,0.12);
  border: 1px solid #d97706;
  color: #fbbf24;
}
.flash-info {
  background: rgba(99,102,241,0.12);
  border: 1px solid #4f46e5;
  color: #a5b4fc;
}
.flash-message { flex: 1; }
.flash-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.flash-close:hover { opacity: 1; }
