/**
 * webfe Design System
 * Components: buttons, forms, alerts, cards, tables, badges, modals
 * Version 1.0
 */

/* ==================== BUTTONS ==================== */
button,
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 200ms ease;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  white-space: nowrap;
}

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

button:focus-visible,
.btn:focus-visible {
  outline: 2px solid #fa8c00;
  outline-offset: 2px;
}

/* PRIMARY BUTTON */
.btn-primary {
  background: #fa8c00;
  color: #fff;
  border-color: #fa8c00;
}

.btn-primary:hover:not(:disabled) {
  background: #e07d00;
  box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
}

.btn-primary:active:not(:disabled) {
  background: #c66900;
  box-shadow: inset 0 1px 4px rgba(0, 102, 204, 0.3);
}

/* SECONDARY BUTTON */
.btn-secondary {
  background: #f5f5f5;
  color: #1a1a1a;
  border-color: #d3d3d3;
}

.btn-secondary:hover:not(:disabled) {
  background: #e8e8e8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-secondary:active:not(:disabled) {
  background: #d3d3d3;
}

/* DANGER BUTTON */
.btn-danger {
  background: #e6524a;
  color: #fff;
  border-color: #e6524a;
}

.btn-danger:hover:not(:disabled) {
  background: #c93f37;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
}

.btn-danger:active:not(:disabled) {
  background: #b23530;
}

/* SUCCESS BUTTON */
.btn-success {
  background: #28a745;
  color: #fff;
  border-color: #28a745;
}

.btn-success:hover:not(:disabled) {
  background: #218838;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

/* BUTTON SIZES */
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  min-height: 36px;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
  min-height: 48px;
}

/* BUTTON GROUP */
.btn-group {
  display: inline-flex;
  gap: 0.5rem;
}

/* ==================== FORMS ==================== */
.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a4a4a;
  margin-bottom: 0.25rem;
}

.form-label.required::after {
  content: " *";
  color: #e6524a;
}

/* ==================== INPUTS ==================== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
  width: 100%;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d3d3d3;
  border-radius: 4px;
  font-family: inherit;
  background: #fff;
  color: #1a1a1a;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #fa8c00;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

input::placeholder {
  color: #757575;
  opacity: 0.7;
}

input:disabled,
textarea:disabled,
select:disabled {
  background: #f5f5f5;
  color: #757575;
  cursor: not-allowed;
  opacity: 0.5;
}

/* TEXTAREA */
textarea {
  resize: vertical;
  min-height: 5rem;
  font-family: inherit;
}

/* SELECT */
select {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%230066cc"><path d="M7 10l5 5 5-5z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 20px;
  padding-right: 2.5rem;
}

/* FORM TEXT */
.form-text {
  font-size: 0.875rem;
  color: #757575;
  margin-top: 0.25rem;
}

/* FORM ERROR */
.form-error {
  font-size: 0.875rem;
  color: #e6524a;
  margin-top: 0.25rem;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
  border-color: #e6524a;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* ==================== ALERTS ==================== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  border-left: 4px solid;
  margin-bottom: 1rem;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideDown 200ms ease;
}

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

.alert-success {
  background: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.alert-error {
  background: #f8d7da;
  border-color: #e6524a;
  color: #721c24;
}

.alert-info {
  background: #d1ecf1;
  border-color: #1e8c9e;
  color: #0c5460;
}

.alert-warning {
  background: #fff3cd;
  border-color: #ffc107;
  color: #856404;
}

.alert-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 200ms ease;
  padding: 0;
  margin-left: 1rem;
  min-width: auto;
  min-height: auto;
}

.alert-close:hover {
  opacity: 1;
}

/* ==================== CARDS ==================== */
.card {
  background: #fff;
  border: 1px solid #d3d3d3;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: box-shadow 200ms ease, transform 200ms ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-header {
  padding: 1rem;
  background: #f5f5f5;
  border-bottom: 1px solid #d3d3d3;
}

.card-body {
  padding: 1rem;
}

.card-footer {
  padding: 0.75rem 1rem;
  background: #f5f5f5;
  border-top: 1px solid #d3d3d3;
  font-size: 0.875rem;
  color: #757575;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: #1a1a1a;
}

.card-text {
  font-size: 1rem;
  line-height: 1.6;
  color: #1a1a1a;
  margin: 0;
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-primary {
  background: #fa8c00;
  color: #fff;
}

.badge-success {
  background: #28a745;
  color: #fff;
}

.badge-danger {
  background: #e6524a;
  color: #fff;
}

.badge-warning {
  background: #ffc107;
  color: #1a1a1a;
}

.badge-info {
  background: #1e8c9e;
  color: #fff;
}

.badge-secondary {
  background: #d3d3d3;
  color: #1a1a1a;
}

/* ==================== MODALS ==================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 200ms ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #d3d3d3;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 200ms ease;
  padding: 0;
  min-width: auto;
  min-height: auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #d3d3d3;
  background: #f5f5f5;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ==================== FIELD ERROR ==================== */
.field-error {
  color: #e6524a;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ==================== LOADING STATE ==================== */
.loading {
  position: relative;
  opacity: 0.7;
  pointer-events: none;
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #fa8c00;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
