@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #4338ca;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* ===== Layout ===== */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 900px;
  margin: 0 auto;
}

.app-header .back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.app-header .back-btn:active {
  background: var(--bg);
}

.app-header .page-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.app-content {
  flex: 1;
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Login Page ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 28px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.login-card .form-control {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  background: #f8fafc;
}

.login-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
  background: #fff;
}

.login-card .btn-primary {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  width: 100%;
  transition: var(--transition);
  letter-spacing: 0.3px;
}

.login-card .btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

/* ===== Cards ===== */
.card-modern {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
}

.card-modern + .card-modern {
  margin-top: 12px;
}

/* ===== Client Cards (Mobile First) ===== */
.client-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 12px;
  transition: var(--transition);
}

.client-card:active {
  box-shadow: var(--shadow-md);
}

.client-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.client-card-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.client-card-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.client-card-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.client-card-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.client-card-meta-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.client-card-meta-value {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.client-card-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ===== Status Badges ===== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-active {
  background: #d1fae5;
  color: #065f46;
}

.badge-paused {
  background: #fee2e2;
  color: #991b1b;
}

.badge-yes {
  background: #d1fae5;
  color: #065f46;
}

.badge-no {
  background: #f1f5f9;
  color: #64748b;
}

/* ===== Action Buttons ===== */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  flex: 1;
  text-decoration: none;
  white-space: nowrap;
}

.action-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.action-btn:active {
  background: var(--bg);
  transform: scale(0.97);
}

.action-btn.btn-play {
  border-color: var(--success);
  color: var(--success);
}

.action-btn.btn-pause {
  border-color: var(--warning);
  color: var(--warning);
}

.action-btn.btn-ping {
  border-color: var(--info);
  color: var(--info);
}

.action-btn.btn-edit {
  border-color: var(--primary);
  color: var(--primary);
}

.action-btn.btn-power {
  border-color: var(--text-secondary);
  color: var(--text-secondary);
}

.action-btn.btn-monitor-on {
  border-color: var(--success);
  color: var(--success);
}

.action-btn.btn-monitor-off {
  border-color: var(--danger);
  color: var(--danger);
}

/* ===== Edit Form ===== */
.edit-form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px 20px;
}

.edit-form-card .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.edit-form-card .form-control {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  background: #f8fafc;
}

.edit-form-card .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
  background: #fff;
}

.edit-form-card .form-control:disabled {
  background: #f1f5f9;
  color: var(--text-muted);
}

.edit-form-card .form-range {
  accent-color: var(--primary);
  height: 6px;
}

.edit-form-card .form-check-input {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.edit-form-card .form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.edit-form-card .form-check-label {
  font-size: 0.95rem;
  margin-left: 6px;
  cursor: pointer;
}

.edit-form-card .btn-primary {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  width: 100%;
  transition: var(--transition);
}

.edit-form-card .btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.client-info-bar {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 16px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.client-info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.client-info-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.client-info-value {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

/* ===== Alerts ===== */
.alert-modern {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  text-align: center;
}

.alert-modern.alert-success {
  background: #d1fae5;
  color: #065f46;
}

.alert-modern.alert-danger {
  background: #fee2e2;
  color: #991b1b;
}

/* ===== DataTable Override ===== */
.dataTables_wrapper {
  display: none !important;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ===== Utilities ===== */
div.title {
  text-align: center;
}

td, th {
  vertical-align: middle;
}

.center {
  text-align: center;
}

.fade_div {
  display: none;
}

/* ===== Smooth Scroll & Touch ===== */
.client-list {
  padding-bottom: 24px;
}

/* ===== Responsive ===== */
@media (min-width: 600px) {
  .app-content {
    padding: 24px;
  }

  .client-card {
    padding: 20px;
  }

  .client-card-actions {
    gap: 10px;
  }

  .login-card {
    padding: 48px 36px;
  }

  .edit-form-card {
    padding: 32px 28px;
  }
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.client-card {
  animation: fadeIn 0.3s ease forwards;
}

.client-card:nth-child(1) { animation-delay: 0.03s; }
.client-card:nth-child(2) { animation-delay: 0.06s; }
.client-card:nth-child(3) { animation-delay: 0.09s; }
.client-card:nth-child(4) { animation-delay: 0.12s; }
.client-card:nth-child(5) { animation-delay: 0.15s; }
.client-card:nth-child(6) { animation-delay: 0.18s; }
.client-card:nth-child(7) { animation-delay: 0.21s; }
.client-card:nth-child(8) { animation-delay: 0.24s; }
.client-card:nth-child(9) { animation-delay: 0.27s; }
.client-card:nth-child(10) { animation-delay: 0.30s; }