/**
 * Posts Module — "โพสต์ของฉัน"
 * Design system: DGA blue-orange
 * Shared classes from dashboard.css: dga-badge, dga-btn-sm, dga-toast, dga-modal-*
 */

/* ========== Wrapper ========== */
.dga-posts-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Sarabun', sans-serif;
}

/* ========== Header ========== */
.dga-posts-header {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-left: 4px solid #2563eb;
    background: linear-gradient(to right, #dbeafe, transparent);
    border-radius: 6px;
}

.dga-posts-header h2 {
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
}

.dga-posts-header p {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

/* ========== Toolbar ========== */
.dga-posts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.dga-posts-toolbar-left {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.dga-posts-toolbar-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Search box with icon */
.dga-posts-search-box {
    position: relative;
}

.dga-posts-search-box .dashicons {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.dga-posts-search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    background: #fff;
}

.dga-posts-search-box input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Filter selects */
.dga-posts-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 120px;
}

.dga-posts-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ========== Table ========== */
.dga-posts-table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.dga-posts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.dga-posts-table thead {
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.dga-posts-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.dga-posts-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.dga-posts-table tbody tr:hover {
    background: #f9fafb;
}

.dga-posts-table tbody tr.updating {
    opacity: 0.6;
}

.dga-posts-title-cell {
    font-weight: 500;
    color: #111827;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dga-posts-date-cell {
    color: #6b7280;
    font-size: 0.9rem;
    white-space: nowrap;
}

.dga-posts-actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ========== Status & Type Badges ========== */
/* Base .dga-badge is in dashboard.css. Post-specific variants: */

.dga-badge-publish {
    background: #dcfce7;
    color: #166534;
}

.dga-badge-pending {
    background: #ffedd5;
    color: #c2410c;
}

.dga-badge-draft {
    background: #f3f4f6;
    color: #6b7280;
}

.dga-badge-post {
    background: #dbeafe;
    color: #1e40af;
}

.dga-badge-page {
    background: #e0e7ff;
    color: #3730a3;
}

.dga-badge-type-default {
    background: #f3f4f6;
    color: #374151;
}

/* ========== Warning Button Variant (orange, for status toggle) ========== */
.dga-btn-sm.dga-btn-warning {
    background: #fff;
    color: #f97316;
    border: 1px solid #fdba74;
}

.dga-btn-sm.dga-btn-warning:hover {
    background: #f97316;
    color: #fff;
}

/* ========== Loading / Empty States ========== */
.dga-posts-loading,
.dga-posts-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.dga-posts-loading .dashicons {
    display: inline-block;
    margin-right: 6px;
}

/* ========== Pagination ========== */
.dga-posts-pagination {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 20px;
}

.dga-posts-pagination-links {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.dga-posts-page-link {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.dga-posts-page-link:hover:not(.disabled):not(.current) {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.dga-posts-page-link.current {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    cursor: default;
}

.dga-posts-page-link.disabled {
    color: #9ca3af;
    cursor: not-allowed;
    background: #f9fafb;
}

.dga-posts-pagination-ellipsis {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 36px;
    height: 36px;
    color: #6b7280;
}

.dga-posts-pagination-info {
    color: #6b7280;
    font-size: 0.85rem;
}

/* ========== Spinner ========== */
.dga-spin {
    animation: dga-spin 1s linear infinite;
}

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

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .dga-posts-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .dga-posts-toolbar-left {
        max-width: none;
    }

    .dga-posts-toolbar-right {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .dga-posts-select {
        min-width: 100px;
    }

    .dga-posts-table .dga-posts-actions-cell {
        flex-direction: column;
        gap: 4px;
    }

    .dga-posts-title-cell {
        max-width: 180px;
    }

    .dga-posts-page-link {
        min-width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .dga-posts-header {
        padding: 12px 16px;
    }

    .dga-posts-header h2 {
        font-size: 1.25rem;
    }

    .dga-posts-select {
        width: 100%;
    }

    .dga-posts-toolbar-right {
        flex-direction: column;
    }
}

/* ========== Accessibility ========== */
.dga-posts-wrapper input:focus-visible,
.dga-posts-wrapper select:focus-visible,
.dga-posts-wrapper button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .dga-posts-wrapper *,
    .dga-posts-wrapper *::before,
    .dga-posts-wrapper *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
