/* Thêm vào đầu file */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Chỉ cho phép select text trong input/textarea */
input, textarea {
  -webkit-user-select: text !important;
  -moz-user-select: text !important;
  -ms-user-select: text !important;
  user-select: text !important;
}

/* Biến màu theo hệ thống Ant Design */
:root {
    --color-primary: #1677ff;
    --color-primary-hover: #4096ff;
    --color-primary-active: #0958d9;
    --color-success: #52c41a;
    --color-error: #ff4d4f;
    --color-error-hover: #d9363e;
    --color-text-primary: rgba(0, 0, 0, 0.85);
    --color-text-secondary: rgba(0, 0, 0, 0.45);
    --color-bg: #fff;
    --color-bg-hover: #f5f5f5;
    --border-radius: 6px;
    --font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --transition-speed: 0.3s;
  }
  /* Reset cơ bản */
  * {
    box-sizing: border-box;
  }
  body {
    margin: 0; padding: 24px;
    font-family: var(--font-family);
    background: #f0f2f5;
    color: var(--color-text-primary);
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -webkit-touch-callout: none;
  }
  .container {
    margin: 0 auto;
    background: var(--color-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 30px 40px;
    margin-top: 50px;
  }
  h2 {
    margin-bottom: 0;
    font-weight: 600;
    font-size: 20px;
    color: var(--color-text-primary);
    text-align: center;
    position: relative;
  }
  h2::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--color-primary);
    border-radius: 2px;
  }
  label {
    font-weight: 500;
    color: var(--color-text-secondary);
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
  }
  textarea#importData {
    width: 100%;
    height: 100px;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    font-family: monospace;
    resize: vertical;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  }
  textarea#importData:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
    transform: translateY(-1px);
  }
  .buttons {
    margin-top: 12px;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
  }
  button {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
    box-shadow: 0 2px 6px rgb(22 119 255 / 0.3);
    background-color: var(--color-primary);
    color: white;
    user-select: none;
  }
  button:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
    box-shadow: 0 4px 12px rgb(22 119 255 / 0.5);
  }
  button:disabled {
    background-color: #d9d9d9;
    color: #bfbfbf;
    box-shadow: none;
    cursor: not-allowed;
  }
  table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
    font-size: 14px;
  }
  thead tr {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-active));
    box-shadow: 0 4px 12px rgba(22, 119, 255, 0.2);
    color: white;
    font-weight: 600;
    border-radius: var(--border-radius);
  }
  thead th:first-child {
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
  }
  thead th:last-child {
    border-top-right-radius: var(--border-radius);
    border-bottom-right-radius: var(--border-radius);
  }
  thead th {
    padding: 14px 16px;
    text-align: center;
    user-select: none;
  }
  tbody tr {
    background: var(--color-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
    border-radius: var(--border-radius);
  }
  tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  }
  tbody td {
    padding: 10px 12px;
    text-align: center;
    vertical-align: middle;
    border: none;
    border-radius: var(--border-radius);
  }
  input[type="email"],
  input[type="password"],
  input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--color-text-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  }
  input[type="email"]:focus,
  input[type="password"]:focus,
  input[type="text"]:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
    transform: translateY(-1px);
  }
  input[readonly] {
    background-color: #fafafa;
    color: var(--color-text-secondary);
    cursor: default;
  }
  .delete-icon {
    color: var(--color-error);
    font-weight: 700;
    font-size: 20px;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    transition: background-color var(--transition-speed), color var(--transition-speed);
    display: inline-block;
  }
  .delete-icon:hover {
    background-color: #fff1f0;
    color: var(--color-error-hover);
  }
  .action-btn {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-active));
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.3px;
    border-radius: var(--border-radius);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
  }
  .action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(22, 119, 255, 0.4);
  }
  .action-btn:disabled {
    background-color: #d9d9d9;
    color: #bfbfbf;
    box-shadow: none;
    cursor: not-allowed;
  }
  .message {
    padding: 12px;
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
    margin-top: 16px;
    min-height: 20px;
    user-select: none;
  }
  .message.error {
    background-color: #fff2f0;
    border: 1px solid #ffccc7;
    color: var(--color-error);
  }
  .message.success {    
    background-color: #f6ffed;
    border: 1px solid #b7eb8f;
    color: var(--color-success);
  }
  #toast-container {
    position: fixed;
    top: 8px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .toast {
    min-width: 300px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(-100%);
    animation: slideDown 0.3s ease forwards, fadeOut 0.3s ease 2.7s forwards;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12);
    background: #ffffff;
  }
  .toast.success {
    background-color: #ffffff;
    border: 1px solid #f0f0f0;
    color: rgba(0, 0, 0, 0.88);
  }
  .toast.error {
    background-color: #ffffff;
    border: 1px solid #f0f0f0;
    color: rgba(0, 0, 0, 0.88);
  }
  .toast-icon {
    margin-right: 8px;
  }
  .toast.success .toast-icon {
    color: #52c41a;
  }
  .toast.error .toast-icon {
    color: #ff4d4f;
  }
  @keyframes slideDown {
    from {
      transform: translateY(-100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  @keyframes fadeOut {
    from {
      transform: translateY(0);
      opacity: 1;
    }
    to {
      transform: translateY(-100%);
      opacity: 0;
    }
  }
  .nav {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-active));
    color: white;
    padding: 12px 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
  .nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .nav-brand {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
  }
  .nav-item {
    font-size: 14px;
    opacity: 0.9;
  }
  /* Style cho OTP cell */
  #emailTable tbody td:nth-child(4) {  /* Cột OTP */
    transition: background-color 0.3s ease;
    cursor: pointer;
  }

  #emailTable tbody td:nth-child(4):not(:empty):hover {
    background-color: rgba(24, 144, 255, 0.1);
  }

  #emailTable tbody td:nth-child(4):active:not(:empty) {
    background-color: rgba(24, 144, 255, 0.2);
  }

  /* Style cho tooltip */
  #emailTable tbody td:nth-child(4) {
    position: relative;
    transition: background-color 0.3s ease;
    cursor: pointer;
  }

  #emailTable tbody td:nth-child(4)::after {
    content: 'Click để copy';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  #emailTable tbody td:nth-child(4):hover::after {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 5px);
  }

  /* Giữ nguyên các style khác */
  #emailTable tbody td:nth-child(4):not(:empty):hover {
    background-color: rgba(24, 144, 255, 0.1);
  }

  #emailTable tbody td:nth-child(4):active:not(:empty) {
    background-color: rgba(24, 144, 255, 0.2);
  }

  /* Style cho thông báo không có dữ liệu */
  .empty-message {
    text-align: center;
    padding: 24px;
    color: var(--color-text-secondary);
    font-size: 14px;
    background: #fafafa;
    border-radius: var(--border-radius);
  }

  /* Style cho phần đếm số dòng */
  .table-header {
    display: flex;
    justify-content: flex-end;
  }

  .row-count {
    font-size: 14px;
    color: var(--color-text-secondary);
    font-weight: 500;
  }

  .row-count span {
    color: var(--color-primary);
    margin: 0 4px;
  }

  /* Style cho các ô có thể copy */
  #emailTable tbody td {
    transition: background-color 0.3s ease;
    position: relative;
    cursor: pointer;
  }

  #emailTable tbody td::after {
    content: 'Click để copy';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  #emailTable tbody td:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 5px);
  }

  #emailTable tbody td:hover {
    background-color: rgba(24, 144, 255, 0.1);
  }

  #emailTable tbody td:active {
    background-color: rgba(24, 144, 255, 0.2);
  }

  /* Loại trừ cột STT và cột có nút action/delete */
  #emailTable tbody td:first-child,
  #emailTable tbody td:nth-last-child(2),
  #emailTable tbody td:last-child {
    cursor: default;
  }

  #emailTable tbody td:first-child::after,
  #emailTable tbody td:nth-last-child(2)::after,
  #emailTable tbody td:last-child::after {
    display: none;
  }

  #emailTable tbody td:first-child:hover,
  #emailTable tbody td:nth-last-child(2):hover,
  #emailTable tbody td:last-child:hover {
    background-color: transparent;
  }

  /* Style cho cột nội dung email */
  #emailTable tbody td:nth-child(5) { /* Cột nội dung */
    max-width: 250px;
    white-space: normal; /* Cho phép wrap text */
    word-wrap: break-word; /* Cho phép break word khi quá dài */
    word-break: break-all; /* Đảm bảo break ở mọi ký tự nếu cần */
  }

  /* Style cho import options */
  .import-options {
    margin-bottom: 12px;
    display: flex;
    gap: 16px;
  }

  .radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-secondary);
  }

  .radio-label input[type="radio"] {
    cursor: pointer;
  }

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

  /* Style cho cột nội dung email */
  #emailTable tbody td:nth-child(6) {
    max-width: 200px;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-all;
  }