/*
   Core Components - Desa Temesi
   Shared UI elements for Frontend and Admin
   Standardized for Anti-Adblock Compliance (Prefix: tm-)
*/

/* GLOBAL BASE */
html,
body {
  font-family: var(--tm-font-body);
  background-color: var(--tm-bg);
  color: var(--tm-text);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--tm-font-head);
  font-weight: 700;
  line-height: 1.2;
}

/* 1. BUTTONS (Refined Premium) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--tm-radius-md);
  font-family: var(--tm-font-head);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--tm-transition);
  text-decoration: none !important;
  line-height: 1;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.btn * {
  text-decoration: none !important;
}

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

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--tm-radius-sm);
}

.btn-primary {
  background: var(--tm-primary) !important;
  color: var(--tm-white) !important;
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover) !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(var(--primary-rgb), 0.3);
}

/* Header Specific Button Balance */
.desa-header .btn-primary {
  padding: 0.6rem 1.25rem;
  font-size: 0.8rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #2d5a27, #1e3a1e) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 4px 12px rgba(30, 58, 30, 0.2);
}

.desa-header .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(30, 58, 30, 0.35);
  background: linear-gradient(135deg, #366d2f, #1e3a1e) !important;
}

.btn-secondary {
  background: var(--tm-white) !important;
  color: var(--tm-text) !important;
  border: 1px solid var(--tm-border) !important;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--tm-bg) !important;
  border-color: var(--tm-muted) !important;
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--tm-danger-light) !important;
  color: var(--tm-danger) !important;
  border: 1px solid rgba(230, 57, 70, 0.1) !important;
}

.btn-danger:hover:not(:disabled) {
  background: var(--tm-danger) !important;
  color: var(--tm-white) !important;
  transform: translateY(-2px);
}

/* Table & Icon Action Buttons */
.btn-action {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: var(--tm-transition);
  background: var(--tm-white);
  color: var(--tm-muted);
  border: 1px solid var(--tm-border);
  cursor: pointer;
  text-decoration: none;
}

.btn-action:hover {
  transform: translateY(-2px);
  background: var(--tm-primary);
  color: var(--tm-white);
  border-color: var(--tm-primary);
  box-shadow: var(--shadow-sm);
}

.btn-action.btn-delete:hover {
  background: var(--tm-danger);
  border-color: var(--tm-danger);
}

/* 2. ALERTS (Modern Minimal) */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--tm-radius-md);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.alert-success {
  background: var(--tm-success-light);
  color: #065f46;
  border-color: rgba(16, 185, 129, 0.1);
}

.alert-error,
.alert-danger {
  background: var(--tm-danger-light);
  color: #991b1b;
  border-color: rgba(230, 57, 70, 0.1);
}

.alert-warning {
  background: var(--tm-warning-light);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.1);
}

/* 3. BADGES */
/* 3. BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-success {
  background: var(--tm-success-light);
  color: var(--tm-success);
}

.badge-warning {
  background: var(--tm-warning-light);
  color: var(--tm-warning);
}

.badge-danger {
  background: var(--tm-danger-light);
  color: var(--tm-danger);
}

/* 4. QUICK ACCESS LISTS */
.quick-access-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.quick-access-list li a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--tm-white);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-md);
  color: var(--tm-primary);
  text-decoration: none;
  font-weight: 700;
  transition: var(--tm-transition);
  box-shadow: var(--shadow-sm);
}

.quick-access-list li a:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--tm-primary);
  background: var(--tm-primary-light);
}

.quick-access-list li a i {
  color: var(--tm-accent);
}

/* 5. PAGINATION (Premium) */
.admin-pagination,
.desa-pagination,
div.desa-pagination,
div.admin-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 1rem;
  clear: both;
}

.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--tm-border);
  border-radius: 12px;
  background: var(--tm-white);
}

.tag-input-container input {
  border: none;
  padding: 0.5rem;
  flex: 1;
  outline: none;
}

.admin-pagination .page-numbers,
.desa-pagination .page-numbers,
.desa-pagination a.page-numbers,
.desa-pagination span.page-numbers {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.5rem;
  border-radius: 10px;
  background: var(--tm-white) !important;
  border: 1px solid var(--tm-border) !important;
  color: var(--tm-text) !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  transition: var(--tm-transition);
  font-size: 0.9rem;
}

.admin-pagination .page-numbers:hover,
.desa-pagination .page-numbers:hover,
.desa-pagination a.page-numbers:hover {
  border-color: var(--tm-primary) !important;
  color: var(--tm-primary) !important;
  background: var(--tm-primary-light) !important;
  transform: translateY(-2px);
}

.admin-pagination .page-numbers.current,
.desa-pagination .page-numbers.current,
.desa-pagination span.page-numbers.current {
  background: var(--tm-primary) !important;
  color: var(--tm-white) !important;
  border-color: var(--tm-primary) !important;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.2);
}

.admin-pagination .page-numbers.dots {
  border: none;
  background: transparent;
  min-width: 20px;
}

/* 4. FORM ELEMENTS */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--tm-primary);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--tm-border);
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--tm-text);
  background: var(--tm-white);
  transition: var(--tm-transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--tm-primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.08);
}

/* Premium Search Input Variant */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrapper input {
  padding-left: 2.75rem !important;
  background: #f8fafc;
  border: 1px solid var(--tm-border);
  height: 48px;
  border-radius: 14px;
}

.search-wrapper input:focus {
  background: white;
  border-color: var(--tm-primary);
  box-shadow: 0 10px 25px -5px rgba(var(--primary-rgb), 0.1);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tm-muted);
  opacity: 0.6;
  transition: var(--tm-transition);
  pointer-events: none;
}

.search-wrapper input:focus+.search-icon {
  color: var(--tm-primary);
  opacity: 1;
}

/* Premium Dropdown (Select) */
select.premium-select,
.filter-bar select,
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.2em;
  padding: 0.75rem 3rem 0.75rem 1.25rem;
  background-color: var(--tm-white);
  border: 1px solid var(--tm-border);
  border-radius: 12px;
  font-family: var(--tm-font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--tm-text);
  cursor: pointer;
  transition: var(--tm-transition);
  min-width: 160px;
}

select.premium-select:hover,
.filter-bar select:hover,
.form-group select:hover {
  border-color: var(--tm-primary);
  background-color: #f8fafc;
}

select.premium-select:focus,
.filter-bar select:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--tm-primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.08);
}

/* 4.5 PREMIUM CUSTOM SELECT COMPONENT */
.temesi-select {
  position: relative;
  width: 100%;
  user-select: none;
}

.temesi-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: white;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--tm-text);
  transition: all 0.2s;
}

.temesi-select-trigger:hover {
  border-color: var(--tm-primary);
}

.temesi-select.active .temesi-select-trigger {
  border-color: var(--tm-primary);
  box-shadow: 0 0 0 4px rgba(30, 58, 30, 0.05);
}

.temesi-select-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.temesi-select.active .temesi-select-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.temesi-select-option {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.temesi-select-option:hover {
  background: #f8fafc;
  color: var(--tm-primary);
}

.temesi-select-option.selected {
  background: #f0f6f0;
  color: var(--tm-primary);
  font-weight: 600;
}

.temesi-select-option i,
.temesi-select-option svg {
  width: 16px !important;
  height: 16px !important;
  opacity: 0 !important;
  transition: opacity 0.2s;
}

.temesi-select-option.selected i,
.temesi-select-option.selected svg {
  opacity: 1 !important;
}

/* 4.6 ADMIN PAGINATION */
.admin-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 2rem;
}

.admin-pagination a,
.admin-pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--tm-border);
  color: var(--tm-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.admin-pagination a:hover {
  border-color: var(--tm-primary);
  color: var(--tm-primary);
  background: #f0f6f0;
}

.admin-pagination span.current {
  background: var(--tm-primary);
  color: white;
  border-color: var(--tm-primary);
  box-shadow: 0 4px 12px rgba(30, 58, 30, 0.2);
}

.admin-pagination .prev,
.admin-pagination .next {
  background: #f8fafc;
}

/* 5. CUSTOM PREMIUM RADIO & CHECKBOX */
.premium-radio {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 32px;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
  min-height: 22px;
}

.premium-radio input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.radio-mark {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  width: 20px;
  background-color: #fff;
  border: 2px solid var(--tm-border);
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-radio:hover input~.radio-mark {
  border-color: var(--tm-primary);
}

.premium-radio input:checked~.radio-mark {
  background-color: #fff;
  border-color: var(--tm-primary);
  border-width: 6px;
}

.radio-label {
  font-weight: 500;
  color: var(--tm-text);
  line-height: 1.2;
}

.premium-radio input:checked~.radio-label {
  color: var(--tm-primary);
  font-weight: 700;
}

/* 5. WORDPRESS COMPATIBILITY FIXES */
.add_media {
  background: var(--tm-primary) !important;
  color: white !important;
  border: none !important;
  border-radius: var(--tm-radius-sm) !important;
  padding: 8px 16px !important;
  font-weight: 600 !important;
}

#wpadminbar {
  background: rgba(30, 58, 30, 0.95) !important;
  backdrop-filter: blur(8px);
}

/* 6. ADMIN PANELS & FILTERS (Global) */
.kotak-data {
  background: var(--tm-white);
  border-radius: var(--tm-radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--tm-border);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.kotak-data-header {
  padding: 1.25rem 1.75rem;
  background: #fafbfc;
  border-bottom: 1px solid var(--tm-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kotak-data-header h3 {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--tm-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.kotak-data-inside {
  padding: 1.75rem;
}

/* 7. CUSTOM MODAL SYSTEM (Standardized) */
.temesi-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

.temesi-modal-content {
  background: var(--tm-white);
  border-radius: var(--tm-radius-lg);
  width: 100%;
  max-width: 450px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.temesi-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--tm-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.temesi-modal-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--tm-primary);
}

.temesi-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--tm-muted);
  cursor: pointer;
  transition: color 0.2s;
}

.temesi-modal-close:hover { color: var(--tm-danger); }

.temesi-modal-body {
  padding: 1.5rem;
  font-size: 0.95rem;
  color: var(--tm-text);
  line-height: 1.6;
}

.temesi-modal-footer {
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--tm-border);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* 8. LOADING SYSTEM (Skeleton & Spinners) */
.tm-skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s infinite linear;
  border-radius: 8px;
  display: block;
}

@keyframes skeletonLoading {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.tm-skeleton-text { height: 1rem; margin-bottom: 0.5rem; width: 100%; }
.tm-skeleton-title { height: 1.5rem; margin-bottom: 1rem; width: 60%; }
.tm-skeleton-rect { height: 200px; width: 100%; }
.tm-skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }

/* Spinner Component */
.tm-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: tmSpin 0.8s infinite linear;
  display: none;
}

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

/* Button Loading State */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}

.btn.is-loading .tm-spinner {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -10px;
  margin-left: -10px;
}

/* Premium Success Notification Overlay */
.success-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  animation: fadeIn 0.3s ease-out;
}

.success-card {
  background: white;
  padding: 3rem;
  border-radius: 30px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0,0,0,0.3);
  transform: scale(0.8);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-overlay.active .success-card {
  transform: scale(1);
  opacity: 1;
}

.success-icon-wrapper {
  width: 80px;
  height: 80px;
  background: #f0fdf4;
  color: #16a34a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2.5rem;
}

.filter-bar {
  background: var(--tm-white);
  padding: 1.25rem;
  border-radius: 18px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  display: flex;
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--tm-border);
}

.filter-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* 7. ADMIN SIDEBAR (Global Premium) */
.desa-sidebar {
  width: var(--tm-sidebar-w);
  min-width: var(--tm-sidebar-w);
  background: var(--tm-primary);
  color: var(--tm-white);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

.sidebar-brand {
  padding: 2.5rem 2rem;
  font-family: var(--tm-font-head);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand i {
  color: var(--tm-accent);
}

.sidebar-label {
  padding: 0 2rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.4);
}

.desa-sidebar ul {
  list-style: none;
  padding: 0 1rem;
}

.desa-sidebar li {
  margin-bottom: 0.25rem;
}

.desa-sidebar a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: var(--tm-radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--tm-transition);
}

.desa-sidebar a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--tm-white);
  transform: translateX(4px);
}

.desa-sidebar a.active {
  background: var(--tm-white);
  color: var(--tm-primary);
  box-shadow: var(--shadow-md);
}

.desa-sidebar a.active i {
  color: var(--tm-accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.user-avatar {
  width: 42px;
  height: 42px;
  background: var(--tm-accent);
  color: #1e3a1e;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--tm-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--tm-muted);
  opacity: 0.8;
}