/* Shared Component Library - DLS Intranet */
/* Consolidated styles for buttons, forms, modals, cards, and notifications */
/* This file works alongside shared.css (navigation) and app-specific themes */

/* ===== COLOR SCHEMES ===== */
/* These are extended from app-specific root definitions */
/* Apps should define their own --primary, --secondary, --text colors in root */

/* ===== BUTTON COMPONENT LIBRARY ===== */

/* Base button reset */
button,
.btn {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

/* Standard button sizing */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

/* Primary button (app-specific colors) */
.btn-primary {
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Secondary button (gray theme) */
.btn-secondary {
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  opacity: 0.9;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Danger button (destructive actions) */
.btn-danger {
  transition: all 0.2s ease;
}

.btn-danger:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Size variants */
.btn-sm {
  padding: 8px 12px;
  font-size: 0.85em;
}

.btn-large {
  padding: 14px 20px;
  font-size: 1em;
}

.btn-full {
  width: 100%;
  display: flex;
}

/* Button groups */
.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-group .btn {
  flex: 1;
  min-width: 100px;
}

/* ===== FORM COMPONENT LIBRARY ===== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  font-size: 0.95em;
}

/* Text input base */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="url"],
select,
textarea {
  padding: 10px 12px;
  border: 1px solid;
  border-radius: 6px;
  font-size: 0.95em;
  font-family: inherit;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input::placeholder,
textarea::placeholder {
  opacity: 0.6;
}

/* Focus state for inputs */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px;
}

textarea {
  resize: vertical;
  min-height: 100px;
  font-family: 'Courier New', monospace;
}

/* Input with suffix icon */
.input-with-icon {
  position: relative;
}

.input-with-icon input {
  padding-right: 40px;
}

.input-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.5;
}

/* Input with clear button */
.input-with-clear {
  position: relative;
}

.input-with-clear input {
  padding-right: 36px;
}

.input-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  display: none;
  transition: opacity 0.2s;
}

.input-clear-btn:hover {
  opacity: 0.7;
}

.input-with-clear.has-value .input-clear-btn {
  display: block;
}

/* Form grid for multi-column layouts */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-grid .form-group {
  grid-column: auto;
}

.form-grid .form-group.full-width {
  grid-column: 1 / -1;
}

/* Form section container */
.form-section {
  padding: 20px;
  border-radius: 8px;
  border-left: 4px solid;
}

.form-section h2,
.form-section h3 {
  margin-bottom: 20px;
}

/* Checkbox group */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-group input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  margin: 0;
}

.checkbox-group label {
  margin: 0;
  font-weight: normal;
  cursor: pointer;
}

/* ===== CARD & CONTAINER COMPONENT ===== */

.card {
  border-radius: 8px;
  padding: 16px;
  border: 1px solid;
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-header h3,
.card-title {
  font-size: 1.1em;
  font-weight: 600;
  margin: 0;
}

.card-section {
  margin-bottom: 12px;
}

.card-section:last-child {
  margin-bottom: 0;
}

.card-label {
  font-weight: 600;
  font-size: 0.85em;
  margin-bottom: 4px;
  opacity: 0.8;
}

.card-value {
  font-size: 0.95em;
}

/* Card grid (multi-column layouts) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

/* ===== MODAL & DIALOG COMPONENT ===== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow: auto;
}

.modal[style*="display: flex"],
.modal[style*="display: block"],
.modal.show,
.modal.active {
  display: flex !important;
}

.modal-content {
  background: inherit;
  border: 1px solid;
  border-radius: 12px;
  padding: 0;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid;
  font-weight: 600;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.8em;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.modal-close:hover {
  transform: scale(1.2);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 20px;
  border-top: 1px solid;
}

/* ===== NOTIFICATION & ALERT COMPONENT ===== */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  min-width: 240px;
  max-width: 320px;
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 20px 35px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2000;
  display: none;
  cursor: pointer;
}

.toast.visible,
.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
  display: block;
}

.toast.hiding,
.toast.toast-hide {
  opacity: 0;
  transform: translateY(16px);
}

/* Toast variants */
.toast.success,
.toast.toast-success {
}

.toast.error,
.toast.toast-error {
}

.toast.warning,
.toast.toast-warning {
}

.toast.info,
.toast.toast-info {
}

/* Alert/Message component */
.alert,
.message {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid;
  display: none;
  font-size: 0.95em;
  margin-bottom: 16px;
}

.alert.show,
.message.show {
  display: block;
}

.alert-success,
.message.success {
}

.alert-error,
.message.error {
}

.alert-warning,
.message.warning {
}

.alert-info,
.message.info {
}

/* Error message inline */
.error-message {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid;
  margin-bottom: 16px;
  font-size: 0.9em;
}

/* ===== TABLE COMPONENT ===== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

thead {
  font-weight: 600;
  border-bottom: 2px solid;
}

th {
  padding: 12px;
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid;
}

tbody tr {
  transition: background-color 0.2s ease;
}

tbody tr:hover {
  opacity: 0.8;
}

/* Table in container */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid;
}

.table-container table {
  margin: 0;
}

/* ===== UTILITY CLASSES ===== */

/* Spacing helpers */
.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.gap-20 {
  gap: 20px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-20 {
  margin-top: 20px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-20 {
  margin-bottom: 20px;
}

/* Flexbox helpers */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.flex-start {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

/* Grid helpers */
.grid {
  display: grid;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Text utilities */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  opacity: 0.7;
}

.text-bold {
  font-weight: 600;
}

.text-sm {
  font-size: 0.85em;
}

.text-lg {
  font-size: 1.15em;
}

/* Display helpers */
.hidden {
  display: none !important;
}

.block {
  display: block !important;
}

.inline {
  display: inline !important;
}

.inline-flex {
  display: inline-flex !important;
}

/* Opacity */
.opacity-50 {
  opacity: 0.5;
}

.opacity-75 {
  opacity: 0.75;
}

/* Borders */
.border {
  border: 1px solid;
}

.border-l {
  border-left: 4px solid;
}

.rounded {
  border-radius: 6px;
}

.rounded-lg {
  border-radius: 12px;
}

/* Shadows */
.shadow-sm {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.shadow {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.shadow-lg {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* ===== LOADING STATE ===== */

.loading {
  display: none;
  text-align: center;
}

.loading.show {
  display: block;
}

.spinner {
  border: 3px solid;
  border-top-color: inherit;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ===== RESPONSIVE UTILITIES ===== */

@media (max-width: 768px) {
  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    max-width: none;
  }

  .grid-cols-2,
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.85em;
  }

  th,
  td {
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .toast {
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .modal-content {
    max-width: 100%;
    max-height: 100vh;
  }

  .modal-header h2 {
    font-size: 1.1em;
  }
}
