/**
 * News Posts Table Styles
 * 
 * สไตล์สำหรับตารางจัดการโพสต์ข่าวและ Modal Dialog
 * ใช้ธีมสีน้ำเงินและสีส้มที่สอดคล้องกับแดชบอร์ดสถิติ
 * อัพเดตการออกแบบปุ่มให้ทันสมัยและใช้งานง่าย
 */

/* ตัวแปรสีหลัก */
:root {
    --primary-color: #007bff;
    --primary-hover: #0069d9;
    --secondary-color: #fd7e14;
    --secondary-hover: #e36c0a;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --success-color: #28a745;
    --success-hover: #218838;
    --background-light: #f8f9fa;
    --border-color: #dee2e6;
    --text-dark: #333333;
    --text-light: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 15px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.2s;
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
  }
  
  /* ใช้ฟอนต์ Sarabun สำหรับแสดงผลภาษาไทยที่สวยงาม */
  @import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');
  
  /* Main container */
  .news-posts-management {
    font-family: 'Sarabun', sans-serif;
    max-width: 1200px;
    margin: 0 auto 30px;
    padding: 20px;
    background-color: var(--background-light);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
  }
  
  .news-posts-management h2 {
    color: #004085;
    font-size: 28px;
    margin-bottom: 20px;
    text-align: center;
  }
  
  /* Filters */
  .news-posts-filters {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #fff;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-speed);
  }
  
  .news-posts-filters:hover {
    box-shadow: var(--shadow-md);
  }
  
  .news-posts-filters form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .news-posts-filters label {
    font-weight: 600;
    color: var(--text-dark);
    margin-right: 8px;
  }
  
  .news-posts-filters select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    min-width: 200px;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
  }
  
  .news-posts-filters select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    outline: none;
  }
  
  .filter-button {
    background-color: var(--primary-color);
    color: var(--text-light);
    border: none;
    border-radius: var(--border-radius-md);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform var(--transition-speed), box-shadow var(--transition-speed);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .filter-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }
  
  .filter-button:active {
    transform: translateY(0);
  }
  
  .filter-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
  }
  
  /* Date filter badge */
  .date-filter-badge {
    display: inline-flex;
    align-items: center;
    background-color: #e2f0fd;
    color: #0056b3;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin: 0 10px;
  }
  
  .clear-date-filter {
    margin-left: 8px;
    color: #0056b3;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: rgba(0, 123, 255, 0.1);
    transition: background-color var(--transition-speed);
  }
  
  .clear-date-filter:hover {
    background-color: rgba(0, 123, 255, 0.2);
    text-decoration: none;
  }
  
  /* Table */
  .news-posts-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    background-color: #fff;
  }
  
  .news-posts-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--border-radius-md);
    overflow: hidden;
  }
  
  .news-posts-table th,
  .news-posts-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
  }
  
  .news-posts-table th {
    background-color: var(--primary-color);
    color: var(--text-light);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
  }
  
  .news-posts-table tr:last-child td {
    border-bottom: none;
  }
  
  .news-posts-table tr:nth-child(even) {
    background-color: rgba(0, 123, 255, 0.03);
  }
  
  .news-posts-table tr:hover {
    background-color: rgba(0, 123, 255, 0.06);
  }
  
  .news-posts-table .col-title {
    width: 30%;
    position: relative;
  }
  
  .news-posts-table .col-date,
  .news-posts-table .col-modified {
    width: 15%;
  }
  
  .news-posts-table .col-category {
    width: 20%;
  }
  
  .news-posts-table .col-actions {
    width: 20%;
    text-align: center;
    padding: 10px !important;
  }
  
  .news-posts-table a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
  }
  
  .news-posts-table a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
  }
  
  /* Post views count badge */
  .post-views-count {
    display: inline-flex;
    align-items: center;
    color: #6c757d;
    font-size: 12px;
    font-weight: 500;
    margin-left: 10px;
    background-color: #f8f9fa;
    padding: 3px 8px;
    border-radius: 30px;
    white-space: nowrap;
  }
  
  .post-views-count .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin-right: 5px;
  }
  
  /* ========== ปุ่มการจัดการ (ดีไซน์ใหม่ที่แก้ไขแล้ว) ========== */
  
  /* Container สำหรับปุ่ม */
  .action-buttons-container {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    justify-content: center;
  }
  
  /* สไตล์พื้นฐานสำหรับทุกปุ่ม */
  .action-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-width: 120px;
    height: 36px;
    color: white !important;
    flex: 1;
    margin: 0 !important;
    line-height: normal !important;
    text-transform: none !important;
  }
  
  /* ปุ่มแก้ไขหมวดหมู่ */
  .edit-category-btn {
    background-color: #fd7e14 !important;
    background-image: none !important;
  }
  
  .edit-category-btn:hover, 
  .edit-category-btn:focus {
    background-color: #e36c0a !important;
    box-shadow: 0 4px 8px rgba(253, 126, 20, 0.25);
    transform: translateY(-1px);
    opacity: 1 !important;
  }
  
  /* ปุ่มลบโพสต์ */
  .delete-post-btn {
    background-color: #dc3545 !important;
    background-image: none !important;
  }
  
  .delete-post-btn:hover, 
  .delete-post-btn:focus {
    background-color: #c82333 !important;
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.25);
    transform: translateY(-1px);
    opacity: 1 !important;
  }
  
  /* ไอคอนใน dashicons */
  .action-btn i,
  .action-btn .dashicons {
    margin-right: 6px !important;
    font-size: 16px !important;
    width: 16px !important;
    height: 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    vertical-align: text-top !important;
  }
  
  /* เอฟเฟกต์เบลอเมื่อปุ่มถูกปิดการใช้งาน */
  .action-btn:disabled {
    opacity: 0.65 !important;
    cursor: not-allowed;
    box-shadow: none;
  }
  
  /* เอฟเฟกต์เตือนสำหรับปุ่มลบ */
  .delete-post-btn.warning-pulse {
    animation: warningPulse 1.5s infinite;
  }
  
  @keyframes warningPulse {
    0% {
      background-color: var(--danger-color);
    }
    50% {
      background-color: var(--danger-hover);
    }
    100% {
      background-color: var(--danger-color);
    }
  }
  
  /* Pagination */
  .news-posts-pagination {
    margin-top: 24px;
    text-align: center;
    padding: 10px;
  }
  
  .news-posts-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    margin: 0 3px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--primary-color);
    text-decoration: none;
    transition: all var(--transition-speed);
    font-weight: 500;
  }
  
  .news-posts-pagination .page-numbers.current {
    background-color: var(--primary-color);
    color: var(--text-light);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
  }
  
  .news-posts-pagination .page-numbers:hover {
    background-color: var(--background-light);
    border-color: var(--primary-color);
  }
  
  .news-posts-pagination .page-numbers.prev,
  .news-posts-pagination .page-numbers.next {
    padding: 0 15px;
  }
  
  .news-posts-pagination .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    display: inline-flex;
    vertical-align: middle;
  }
  
  /* Posts summary */
  .news-posts-summary {
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    margin-top: 10px;
  }
  
  /* Modal */
  .news-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    animation: fadeInModal 0.3s;
  }
  
  @keyframes fadeInModal {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
  
  .news-modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 25px;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalSlideDown 0.4s ease-out;
    transform-origin: top center;
  }
  
  @keyframes modalSlideDown {
    from {
      opacity: 0;
      transform: translateY(-50px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .news-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color var(--transition-speed);
    line-height: 1;
  }
  
  .news-modal-close:hover {
    color: var(--text-dark);
  }
  
  .news-modal h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
  }
  
  .form-group {
    margin-bottom: 20px;
  }
  
  .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
  }
  
  .form-group select,
  .form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
    background-color: #fff;
  }
  
  .form-group select:focus,
  .form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
    outline: none;
  }
  
  .form-description {
    font-size: 13px;
    color: #6c757d;
    margin-top: 8px;
    margin-bottom: 0;
  }
  
  .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
  }
  
  .update-category-submit,
  .confirm-delete-btn,
  .cancel-modal {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-speed), transform var(--transition-speed), box-shadow var(--transition-speed);
  }
  
  .update-category-submit,
  .confirm-delete-btn {
    color: var(--text-light);
  }
  
  .update-category-submit {
    background-color: var(--primary-color);
  }
  
  .update-category-submit:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
  }
  
  .confirm-delete-btn {
    background-color: var(--danger-color);
  }
  
  .confirm-delete-btn:hover {
    background-color: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(220, 53, 69, 0.3);
  }
  
  .cancel-modal {
    background-color: #f8f9fa;
    color: #495057;
    border: 1px solid #ddd;
  }
  
  .cancel-modal:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
  }
  
  /* Delete confirmation */
  .delete-confirmation-message {
    color: #721c24;
    background-color: #f8d7da;
    padding: 15px;
    border-radius: var(--border-radius-sm);
    margin: 20px 0;
    border-left: 4px solid var(--danger-color);
    font-size: 15px;
    line-height: 1.5;
  }
  
  .delete-confirmation-message .dashicons {
    font-size: 18px;
    color: var(--danger-color);
    margin-right: 8px;
    vertical-align: middle;
  }
  
  /* Notification */
  .news-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 350px;
    padding: 15px 20px;
    background-color: #fff;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    transform: translateY(-100%);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1100;
    animation: slideInNotification 0.4s forwards;
    display: none;
  }
  
  .news-notification.show {
    display: block;
  }
  
  @keyframes slideInNotification {
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  
  .news-notification.success {
    border-left: 4px solid var(--success-color);
  }
  
  .news-notification.error {
    border-left: 4px solid var(--danger-color);
  }
  
  .news-notification-message {
    color: var(--text-dark);
    font-size: 14px;
    display: flex;
    align-items: center;
  }
  
  .news-notification-message:before {
    font-family: 'dashicons';
    margin-right: 10px;
    font-size: 20px;
  }
  
  .news-notification.success .news-notification-message:before {
    content: "\f147"; /* Dashicons check icon */
    color: var(--success-color);
  }
  
  .news-notification.error .news-notification-message:before {
    content: "\f335"; /* Dashicons warning icon */
    color: var(--danger-color);
  }
  
  /* Error messages */
  .news-posts-error,
  .news-posts-no-results {
    padding: 15px;
    margin: 15px 0;
    background-color: var(--background-light);
    border-left: 4px solid #6c757d;
    color: var(--text-dark);
    border-radius: var(--border-radius-sm);
  }
  
  .news-posts-error {
    background-color: #f8d7da;
    border-color: var(--danger-color);
    color: #721c24;
  }
  
  .news-posts-no-results {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    font-size: 15px;
    color: #6c757d;
    border-left: none;
    border: 1px dashed #dee2e6;
    border-radius: var(--border-radius-md);
  }
  
  .news-posts-no-results:before {
    content: "\f169"; /* Dashicons info icon */
    font-family: 'dashicons';
    margin-right: 10px;
    font-size: 20px;
    color: #6c757d;
  }
  
  /* Ripple effect */
  .ripple {
    position: absolute;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
  }
  
  @keyframes ripple {
    to {
      transform: scale(4);
      opacity: 0;
    }
  }
  
  /* Tooltip */
  .button-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  
  /* Action feedback */
  .action-feedback {
    position: fixed;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    z-index: 1200;
    pointer-events: none;
  }
  
  /* Focus visible */
  .action-btn:focus-visible,
  .filter-button:focus-visible,
  .update-category-submit:focus-visible,
  .confirm-delete-btn:focus-visible,
  .cancel-modal:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }
  
  /* Integration with existing news-statistics styles */
  .news-posts-management + .news-statistics-dashboard {
    margin-top: 30px;
  }
  
  /* Chart Date Filter Button */
  .chart-date-filter-btn {
    margin: 20px auto;
    display: block;
    background-color: var(--primary-color);
    color: var(--text-light);
    border: none;
    border-radius: var(--border-radius-md);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-sm);
  }
  
  .chart-date-filter-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }
  
  .chart-date-filter-btn:before {
    content: "\f508"; /* Dashicons calendar icon */
    font-family: 'dashicons';
    margin-right: 8px;
    vertical-align: middle;
  }
  
  /* Animation for button interaction */
  .clicked {
    animation: buttonClick 0.4s ease;
  }
  
  @keyframes buttonClick {
    0% {
      transform: scale(1);
    }
    50% {
      transform: scale(0.95);
    }
    100% {
      transform: scale(1);
    }
  }
  
  /* Hover effect for buttons */
  .hover-effect {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
  }
  
  /* Focus visible style */
  .focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5);
  }
  
  /* Responsive styles */
  @media (max-width: 768px) {
    .news-posts-table .col-date,
    .news-posts-table .col-modified {
      display: none;
    }
    
    .news-posts-filters form {
      flex-direction: column;
      align-items: flex-start;
    }
    
    .news-posts-filters select,
    .filter-button {
      width: 100%;
    }
    
    .news-modal-content {
      width: 95%;
      margin: 20% auto;
      padding: 20px;
    }
    
    .form-actions {
      flex-direction: column;
    }
    
    .form-actions button {
      width: 100%;
      margin-bottom: 10px;
    }
    
    .action-buttons-container {
      flex-direction: column;
      width: 100%;
    }
    
    .action-btn {
      width: 100%;
      margin: 3px 0 !important;
    }
  }
  
  @media (max-width: 576px) {
    .news-posts-management {
      padding: 15px;
    }
    
    .news-posts-management h2 {
      font-size: 22px;
    }
    
    .news-posts-table th,
    .news-posts-table td {
      padding: 10px;
      font-size: 13px;
    }
    
    .news-notification {
      max-width: 280px;
      left: 50%;
      right: auto;
      transform: translate(-50%, -100%);
    }
    
    .news-notification.show {
      transform: translate(-50%, 0);
    }
  }
  
  /* Fix for specific theme conflicts */
  .news-posts-table button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    border-radius: 6px !important;
    text-transform: none !important;
    font-family: 'Sarabun', sans-serif !important;
    line-height: normal !important;
  }
  
  .news-posts-table .edit-category-btn::before,
  .news-posts-table .delete-post-btn::before {
    content: none !important;
  }
  
  /* Fix for WordPress admin bar overlap */
  body.admin-bar .news-modal {
    top: 32px;
  }
  
  @media screen and (max-width: 782px) {
    body.admin-bar .news-modal {
      top: 46px;
    }
  }
  
  /* Fix for RTL languages */
  html[dir="rtl"] .action-buttons-container {
    flex-direction: row-reverse;
  }
  
  html[dir="rtl"] .action-btn i,
  html[dir="rtl"] .action-btn .dashicons {
    margin-right: 0 !important;
    margin-left: 6px !important;
  }