/*
 * Chuẩn hoá giao diện cụm Cư dân (layout `main`, Bootstrap 3 + AngularJS).
 * Chỉ có hiệu lực khi <body> có class `kcc-resident` (xem layouts/main.php),
 * nên không ảnh hưởng trang In ấn / Admin. Không đổi markup, không đổi logic.
 * AA (tỷ lệ tương phản): chữ >= 4.5:1, chữ lớn / viền điều khiển >= 3:1.
 */
body.kcc-resident {
  --kcc-primary: #F79320;
  --kcc-primary-hover: #E8820E;
  --kcc-primary-text: var(--app-primary-text);
  --kcc-on-primary: var(--app-on-primary);
  --kcc-text: var(--app-text);
  --kcc-muted: var(--app-text-2);
  --kcc-border: #6B7280;
  --kcc-line: var(--app-border);
  --kcc-bg: var(--app-bg);
  --kcc-danger: var(--app-danger-strong);
  --kcc-success: var(--app-success-strong);
  --kcc-radius: var(--app-radius-md);
}

/* Nền + chữ */
body.kcc-resident,
body.kcc-resident.page {
  background: var(--kcc-bg) !important;
  color: var(--kcc-text);
  font-family: var(--app-font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0; /* assets/style.css đặt -1px làm chữ bị dính */
}
body.kcc-resident .body-wrapper,
body.kcc-resident .page-wrapper,
body.kcc-resident #content,
body.kcc-resident .container,
body.kcc-resident .container-fluid {
  background: transparent !important;
  box-shadow: none !important;
}
body.kcc-resident .container {
  max-width: 720px;
  padding-left: 16px;
  padding-right: 16px;
}
body.kcc-resident h1,
body.kcc-resident h2,
body.kcc-resident h3,
body.kcc-resident h4,
body.kcc-resident .page-header h1 {
  font-family: inherit;
  color: var(--app-text);
}
/* Tiêu đề trang (nhiều view đặt style inline color:#f79320 !important) */
body.kcc-resident h1[style*="f79320"],
body.kcc-resident h1[style*="F79320"],
body.kcc-resident .page-header h1 {
  color: var(--kcc-primary-text) !important;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}
body.kcc-resident .page-header {
  border-bottom: 0;
  margin: 8px 0 8px;
  padding-bottom: 0;
}

/* Thẻ nội dung */
body.kcc-resident .panel,
body.kcc-resident .well,
body.kcc-resident .card {
  background: #fff;
  border: 1px solid var(--kcc-line);
  border-radius: var(--app-radius-md);
  box-shadow: 0 1px 3px rgba(17, 24, 39, .06);
}
body.kcc-resident .panel-heading {
  background: #fff;
  border-bottom: 1px solid var(--kcc-line);
  border-radius: var(--app-radius-md) var(--app-radius-md) 0 0;
  color: var(--app-text);
}

/* Nhãn + ô nhập */
body.kcc-resident label,
body.kcc-resident .control-label {
  color: var(--app-text);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
body.kcc-resident .form-control,
body.kcc-resident select,
body.kcc-resident textarea,
body.kcc-resident input[type="text"],
body.kcc-resident input[type="tel"],
body.kcc-resident input[type="email"],
body.kcc-resident input[type="number"],
body.kcc-resident input[type="password"],
body.kcc-resident input[type="date"],
body.kcc-resident .selectize-input {
  min-height: 44px;
  height: auto;
  background: var(--app-subtle);
  border: 1px solid var(--kcc-border);
  border-radius: 8px;
  box-shadow: none;
  color: var(--app-text);
  font-family: inherit;
  font-size: 15px;
  padding: 9px 12px;
}
body.kcc-resident textarea.form-control { min-height: 88px; }
body.kcc-resident .form-control::placeholder,
body.kcc-resident input::placeholder,
body.kcc-resident textarea::placeholder,
body.kcc-resident .selectize-input input::placeholder {
  color: var(--kcc-muted);
  opacity: 1;
}
body.kcc-resident .selectize-input.items > .item,
body.kcc-resident .selectize-input > input { color: var(--app-text); }
body.kcc-resident .form-control:focus,
body.kcc-resident select:focus,
body.kcc-resident textarea:focus,
body.kcc-resident input:focus,
body.kcc-resident .selectize-input.focus {
  border-color: var(--kcc-primary);
  box-shadow: 0 0 0 3px rgba(247, 147, 32, .35);
  outline: 0;
}
body.kcc-resident .form-control[disabled],
body.kcc-resident .form-control[readonly],
body.kcc-resident fieldset[disabled] .form-control {
  background: #F3F4F6;
  color: var(--kcc-muted);
}
body.kcc-resident .selectize-dropdown {
  border: 1px solid var(--kcc-border);
  border-radius: 8px;
  color: var(--app-text);
}
body.kcc-resident .selectize-dropdown .active {
  background: #FEF3E2;
  color: var(--app-text);
}

/* Dấu bắt buộc / lỗi / ghi chú */
body.kcc-resident .text-danger,
body.kcc-resident .has-error .help-block,
body.kcc-resident .has-error .control-label,
body.kcc-resident span[style*="color: red"],
body.kcc-resident span[style*="color:red"],
body.kcc-resident span[style*="#f00"] {
  color: var(--kcc-danger) !important;
}
body.kcc-resident .has-error .form-control { border-color: var(--kcc-danger); }
body.kcc-resident .help-block,
body.kcc-resident .text-muted,
body.kcc-resident small,
body.kcc-resident .small {
  color: var(--kcc-muted);
}
body.kcc-resident .text-success,
body.kcc-resident .has-success .help-block { color: var(--kcc-success) !important; }
body.kcc-resident .text-warning { color: #92400E !important; }
body.kcc-resident .text-info { color: #155E75 !important; }

/* Nút */
body.kcc-resident .btn {
  border-radius: 8px;
  font-family: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 9px 18px;
}
body.kcc-resident .btn-sm,
body.kcc-resident .btn-xs { min-height: 34px; padding: 5px 12px; }
/* Nút chính: nền cam đậm + chữ/icon trắng (đạt AA 4.59:1), cùng kiểu với admin */
body.kcc-resident .btn-primary,
body.kcc-resident .btn-success,
body.kcc-resident .btn-warning,
body.kcc-resident .btn-info {
  background: var(--app-cta) !important;
  border-color: var(--app-cta) !important;
  color: var(--app-on-cta) !important;
}
body.kcc-resident .btn-primary:hover,
body.kcc-resident .btn-primary:focus,
body.kcc-resident .btn-success:hover,
body.kcc-resident .btn-warning:hover,
body.kcc-resident .btn-info:hover {
  background: var(--app-cta-hover) !important;
  border-color: var(--app-cta-hover) !important;
  color: var(--app-on-cta) !important;
}
body.kcc-resident .btn-default {
  background: #fff;
  border: 1px solid var(--kcc-border);
  color: var(--app-text);
}
/* Nút có nền cam đặt inline -> cam đậm + chữ trắng */
body.kcc-resident .btn[style*="f79320"],
body.kcc-resident .btn[style*="F79320"],
body.kcc-resident button.button.clear.btn {
  background: var(--app-cta) !important;
  border-color: var(--app-cta) !important;
  color: var(--app-on-cta) !important;
}
body.kcc-resident .btn-danger {
  background: var(--kcc-danger);
  border-color: var(--kcc-danger);
  color: #fff;
}
body.kcc-resident .btn[disabled],
body.kcc-resident .btn.disabled { opacity: .55; }
body.kcc-resident .btn:focus,
body.kcc-resident a:focus,
body.kcc-resident button:focus {
  outline: 3px solid rgba(247, 147, 32, .55);
  outline-offset: 2px;
}

/* Link + checkbox/radio */
body.kcc-resident .text-primary,
body.kcc-resident a.text-primary { color: var(--kcc-primary-text) !important; }
body.kcc-resident a { color: var(--kcc-primary-text); }
body.kcc-resident a:hover { color: #7C3A04; }
body.kcc-resident a.btn { color: inherit; }
body.kcc-resident input[type="checkbox"],
body.kcc-resident input[type="radio"] { accent-color: var(--kcc-primary); }

/* Cảnh báo */
body.kcc-resident .alert { border-radius: 12px; border: 1px solid transparent; }
body.kcc-resident .alert-success { background: #F0FDF4; border-color: #BBF7D0; color: #166534; }
body.kcc-resident .alert-danger { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
body.kcc-resident .alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
body.kcc-resident .alert-info { background: #ECFEFF; border-color: #A5F3FC; color: #155E75; }

/* Bảng */
body.kcc-resident .table { color: var(--kcc-text); }
body.kcc-resident .table > thead > tr > th {
  background: #F9FAFB;
  border-bottom: 1px solid var(--kcc-line);
  color: var(--app-text);
}
body.kcc-resident .table > tbody > tr > td { border-top: 1px solid var(--kcc-line); }

/* Vùng kéo thả / tải ảnh */
body.kcc-resident .my-drop-zone {
  border: 2px dashed var(--kcc-border);
  border-radius: var(--kcc-radius);
  color: var(--kcc-text);
}

/* Di động */
@media (max-width: 575px) {
  body.kcc-resident .container { padding-left: 12px; padding-right: 12px; }
  body.kcc-resident .btn-block-xs { display: block; width: 100%; }
}

/* Chữ cam đặt inline trong nội dung nhập từ DB (ghi chú...) -> màu chữ AA */
body.kcc-resident [style*="color: #f79320" i]:not([style*="background"]),
body.kcc-resident [style*="color:#f79320" i]:not([style*="background"]),
body.kcc-resident [style*="color: rgb(247, 147, 32)" i]:not([style*="background"]) {
  color: var(--kcc-primary-text) !important;
}

/*
 * Cột điện thoại cố định 430px: lưới Bootstrap 3 theo bề rộng cửa sổ nên trên màn hình
 * rộng sẽ bung cột desktop (col-md/lg/sm). Ép về bố cục mobile: col-sm/md/lg thành khối
 * toàn chiều rộng, col-xs-* giữ đúng tỉ lệ.
 */
body.kcc-resident .container,
body.kcc-resident .container-fluid {
  width: 100% !important;
  max-width: 100% !important;
}
body.kcc-resident [class*="col-sm-"],
body.kcc-resident [class*="col-md-"],
body.kcc-resident [class*="col-lg-"] {
  float: none;
  width: auto;
  margin-left: 0;
  left: auto;
  right: auto;
}
body.kcc-resident [class*="col-xs-"] { float: left; }
body.kcc-resident .col-xs-12 { width: 100%; }
body.kcc-resident .col-xs-11 { width: 91.66666667%; }
body.kcc-resident .col-xs-10 { width: 83.33333333%; }
body.kcc-resident .col-xs-9 { width: 75%; }
body.kcc-resident .col-xs-8 { width: 66.66666667%; }
body.kcc-resident .col-xs-7 { width: 58.33333333%; }
body.kcc-resident .col-xs-6 { width: 50%; }
body.kcc-resident .col-xs-5 { width: 41.66666667%; }
body.kcc-resident .col-xs-4 { width: 33.33333333%; }
body.kcc-resident .col-xs-3 { width: 25%; }
body.kcc-resident .col-xs-2 { width: 16.66666667%; }
body.kcc-resident .col-xs-1 { width: 8.33333333%; }

/* Lề trái/phải gọn trong cột 430px: ô nhập và nút rộng gần hết cột */
body.kcc-resident .container,
body.kcc-resident .container-fluid {
  padding-left: 12px !important;
  padding-right: 12px !important;
}
body.kcc-resident .row {
  margin-left: 0 !important;
  margin-right: 0 !important;
}
body.kcc-resident [class*="col-"] {
  padding-left: 0 !important;
  padding-right: 0 !important;
}
body.kcc-resident [ng-form] {
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
body.kcc-resident .page-header h1 {
  padding: 0 !important;
}
/* Hàng nút Lưu / Bước tiếp theo: trải đều hết chiều ngang */
body.kcc-resident p:has(> .btn),
body.kcc-resident div:has(> .btn):not(.form-group):not(.modal-footer) {
  display: flex;
  gap: 8px;
}
body.kcc-resident p:has(> .btn) > .btn,
body.kcc-resident div:has(> .btn):not(.form-group):not(.modal-footer) > .btn {
  flex: 1 1 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* .body-wrapper (assets/style.css) chừa lề 45px mỗi bên: thu về 10px */
body.kcc-resident .body-wrapper {
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
body.kcc-resident .container,
body.kcc-resident .container-fluid {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Tiết kiệm không gian dọc */
body.kcc-resident hr { margin: 8px 0 !important; }
body.kcc-resident p { margin: 0 0 8px; font-size: 14px; }
body.kcc-resident .form-group { margin-bottom: 12px; }
body.kcc-resident .page-header { margin: 4px 0 8px !important; }
body.kcc-resident .page-header::before,
body.kcc-resident .page-header::after { content: none; }
body.kcc-resident [class*="col-"] > h4,
body.kcc-resident [class*="col-"] > h5 { margin-top: 8px !important; }

/* View cũ kéo nội dung lên 50px (margin-top:-50px) làm tiêu đề dính mép thanh trên */
body.kcc-resident [style*="margin-top: -50px"],
body.kcc-resident [style*="margin-top:-50px"] { margin-top: 0 !important; }
body.kcc-resident .page-header { margin-top: 12px !important; }
body.kcc-resident .site-content { padding-top: 0; }

/* Màn hình chờ khi tải trang: bỏ ảnh động chứa logo thương hiệu, dùng vòng quay trung tính */
body.kcc-resident .doc-loader { background: var(--app-bg) !important; }
body.kcc-resident .doc-loader img { display: none; }
body.kcc-resident .doc-loader td::after {
  content: "";
  display: block;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 4px solid var(--app-border);
  border-top-color: var(--app-primary);
  border-radius: 50%;
  animation: kcc-spin .8s linear infinite;
}
@keyframes kcc-spin { to { transform: rotate(360deg); } }
