/* ============================================
   UstaNet Web Panel — Component Stilleri
   ============================================ */

/* ---------- Stat Card ---------- */
.stat-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  color: white;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card-header .material-icons-round {
  font-size: 28px;
  opacity: 0.9;
}

.stat-card-title {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 8px;
}

.stat-card-change {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.8;
}

.stat-card-change .up { color: #A7F3D0; }
.stat-card-change .down { color: #FCA5A5; }

/* ---------- Data Table ---------- */
.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: var(--table-header-bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--table-border);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}

.data-table thead th:hover {
  color: var(--text-primary);
}

.data-table thead th .sort-icon {
  font-size: 14px;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0.4;
}

.data-table thead th.sorted .sort-icon {
  opacity: 1;
  color: var(--accent);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--table-border);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--table-row-hover);
}

.data-table tbody tr.selected {
  background: var(--accent-light);
}

.data-table tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table .cell-worker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.data-table .cell-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.data-table .cell-name {
  font-weight: 600;
  color: var(--text-primary);
}

.data-table .cell-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Table Checkbox */
.table-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Table Actions */
.table-actions {
  display: flex;
  gap: 4px;
}

.table-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
}

.table-action-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.table-action-btn.edit:hover { color: var(--info); }
.table-action-btn.delete:hover { color: var(--danger); }
.table-action-btn.view:hover { color: var(--accent); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination-info {
  font-size: 12px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

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

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-container {
  background: var(--modal-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
}

.modal-close:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

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

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

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  font-size: 13px;
  color: var(--text-primary);
  animation: slideInRight 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }

.toast .toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast .toast-message { flex: 1; }

.toast .toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 18px;
  display: flex;
  align-items: center;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Form Elements ---------- */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group-modal {
  margin-bottom: 16px;
}

.form-group-modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

select.form-control {
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 20px;
}

.tab-btn {
  position: relative;
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.tab-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
}

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

.empty-state .material-icons-round {
  font-size: 56px;
  color: var(--text-muted);
  opacity: 0.4;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Filter Bar ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar .form-control {
  width: auto;
  min-width: 160px;
}

.filter-bar .search-filter {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.filter-bar .filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-bar {
  justify-content: space-between;
}

/* ---------- Page Header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ---------- Page Loading ---------- */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Status Badge ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
}

.status-badge.success { background: rgba(16, 185, 129, 0.12); color: #059669; }
.status-badge.danger { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.status-badge.warning { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.status-badge.info { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.status-badge.neutral { background: rgba(107, 114, 128, 0.12); color: #6b7280; }

.dark-mode .status-badge.success { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.dark-mode .status-badge.danger { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.dark-mode .status-badge.warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.dark-mode .status-badge.info { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.dark-mode .status-badge.neutral { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }

/* ---------- Cell Worker (table row avatar) ---------- */
.cell-worker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cell-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.cell-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.cell-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Detail Grid ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.detail-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
}

.detail-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.detail-label {
  font-size: 13px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ---------- Tabs (page-level) ---------- */
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

/* ---------- Mini Stat ---------- */
.mini-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mini-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.mini-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* ---------- Settings Nav ---------- */
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.settings-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.settings-nav-item.active {
  background: var(--primary);
  color: white;
}

.settings-nav-item.active .material-icons-round {
  color: white;
}

/* ---------- Permission Tag ---------- */
.perm-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
}

.dark-mode .perm-tag {
  background: rgba(99, 102, 241, 0.2);
}

/* ---------- Mini Stat Card ---------- */
.mini-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  transition: box-shadow var(--transition-fast);
}

.mini-stat-card:hover {
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08));
}

.mini-stat-card .material-icons-round {
  font-size: 28px;
}

.mini-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.mini-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---------- Expense Site List (Dashboard) ---------- */
.expense-site-list {
  padding: 12px 0;
}

.expense-site-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.expense-site-row:hover {
  background: var(--bg-hover);
}

.expense-site-info {
  min-width: 120px;
}

.expense-site-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.expense-site-count {
  font-size: 11px;
  color: var(--text-muted);
}

.expense-site-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.expense-site-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.expense-site-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
  min-width: 90px;
  text-align: right;
}

.expense-site-total {
  display: flex;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ---------- Form Grid ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Grid 3 ---------- */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Responsive Overrides ---------- */
@media (max-width: 768px) {
  .page-header { flex-direction: column; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .filter-group { flex-wrap: wrap; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr !important; }
  .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr !important; }
  .grid-3 { grid-template-columns: 1fr !important; }
  .grid-2 { grid-template-columns: 1fr !important; }
}
