/* ==========================================================================
   MATERIAL DESIGN 3 - COMPONENT LIBRARY
   Cards, Buttons, Textfields, Badges, Chips, Dialogs, Tables, Snackbars
   ========================================================================== */

/* --- MD3 BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--md-sys-typescale-font-plain);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--md-sys-shape-corner-full);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-standard);
  user-select: none;
  white-space: nowrap;
  outline: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-sys-elevation-1);
}

.btn-filled:hover {
  box-shadow: var(--md-sys-elevation-2);
  filter: brightness(1.08);
}

.btn-filled-tonal {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.btn-filled-tonal:hover {
  filter: brightness(0.95);
}

.btn-secondary {
  background-color: var(--md-sys-color-secondary);
  color: var(--md-sys-color-on-secondary);
}

.btn-secondary:hover {
  filter: brightness(1.08);
}

.btn-positive {
  background-color: var(--md-sys-color-positive);
  color: var(--md-sys-color-on-positive);
}

.btn-positive:hover {
  filter: brightness(1.08);
}

.btn-outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border-color: var(--md-sys-color-outline);
}

.btn-outlined:hover {
  background-color: var(--md-sys-color-surface-container);
  border-color: var(--md-sys-color-primary);
}

.btn-text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  padding: 8px 14px;
}

.btn-text:hover {
  background-color: var(--md-sys-color-surface-container);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--md-sys-shape-corner-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short);
}

.btn-icon:hover {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: var(--md-sys-shape-corner-large);
}

/* Floating Action Button (FAB) */
.fab-btn {
  position: fixed;
  bottom: 84px;
  right: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--md-sys-color-primary), var(--md-sys-color-tertiary));
  color: #ffffff;
  border-radius: var(--md-sys-shape-corner-large);
  border: none;
  box-shadow: var(--md-sys-elevation-3);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-standard);
}

.fab-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--md-sys-elevation-4);
}

/* --- MD3 CARDS --- */
.m3-card {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-large);
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 20px;
  box-shadow: var(--md-sys-elevation-1);
  transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-standard);
  position: relative;
  overflow: hidden;
}

.m3-card:hover {
  box-shadow: var(--md-sys-elevation-2);
}

.m3-card-elevated {
  border: none;
  box-shadow: var(--md-sys-elevation-2);
}

.m3-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

/* --- FORM CONTROLS & MD3 TEXTFIELDS --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  position: relative;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 2px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--md-sys-typescale-font-plain);
  font-size: 0.95rem;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-medium);
  outline: none;
  transition: border-color var(--md-sys-motion-duration-short), box-shadow var(--md-sys-motion-duration-short);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px var(--md-sys-color-primary-container);
  background-color: var(--md-sys-color-surface);
}

.currency-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-prefix {
  position: absolute;
  left: 14px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface-variant);
  pointer-events: none;
  font-size: 0.95rem;
}

.currency-input {
  padding-left: 44px;
  font-family: var(--md-sys-typescale-font-mono);
  font-weight: 600;
  font-size: 1.1rem;
}

/* --- BADGES & CHIPS --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-primary {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.badge-positive {
  background-color: var(--md-sys-color-positive-container);
  color: var(--md-sys-color-on-positive-container);
}

.badge-warning {
  background-color: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
}

.badge-error {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.badge-neutral {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
}

.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--md-sys-shape-corner-small);
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short);
}

.chip-filter:hover {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

.chip-filter.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: var(--md-sys-color-primary);
  font-weight: 700;
}

/* --- TABS --- */
.m3-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.m3-tab-item {
  padding: 12px 18px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--md-sys-motion-duration-short);
  white-space: nowrap;
}

.m3-tab-item:hover {
  color: var(--md-sys-color-primary);
  background-color: var(--md-sys-color-surface-container-low);
}

.m3-tab-item.active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

/* --- DATA TABLE --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface);
}

.m3-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.m3-table th {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.m3-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
}

.m3-table tbody tr:hover {
  background-color: var(--md-sys-color-surface-container-low);
}

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

/* --- MODAL / DIALOG --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-standard);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-extra-large);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--md-sys-elevation-5);
  border: 1px solid var(--md-sys-color-outline-variant);
  transform: translateY(24px) scale(0.96);
  transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-standard);
  overflow: hidden;
}

.modal-dialog-large {
  max-width: 860px;
}

.modal-backdrop.active .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--md-sys-color-surface-container-lowest);
}

/* --- SNACKBAR / TOAST --- */
.snackbar-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.snackbar {
  background-color: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  padding: 14px 20px;
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-sys-elevation-4);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  max-width: 90vw;
  pointer-events: auto;
  animation: snackbarSlideUp 0.3s cubic-bezier(0.2, 0, 0, 1) forwards;
}

.snackbar.snackbar-positive {
  border-left: 4px solid var(--md-sys-color-positive);
}

.snackbar.snackbar-warning {
  border-left: 4px solid var(--md-sys-color-warning);
}

.snackbar.snackbar-error {
  border-left: 4px solid var(--md-sys-color-error);
}

@keyframes snackbarSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- TOOLTIP & INFO POPUP --- */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short);
}

.info-icon:hover {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 2rem;
}
