/* ========================================
   Posts Page Styles - Modern & Responsive
   ======================================== */

/* ===== Variables ===== */
:root {
    --primary-color: #ffdf00;
    --secondary-color: #0b0b0b;
    --text-dark: #0b0b0b;
    --text-gray: #8a8a8e;
    --border-color: #e2e8f0;
    --bg-light: #fffdf0;
    --success-color: #00c853;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Main Container ===== */
.posts-container {
    min-height: 100vh;
    background: var(--bg-light);
    direction: rtl;
}

/* ===== Header/Navbar ===== */
.posts-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.posts-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1920px;
    margin: 0 auto;
}

.posts-logo {
    height: 40px;
    width: auto;
}

.posts-user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.posts-profile-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.posts-profile-img:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* ===== Mobile Header ===== */
.posts-mobile-header {
    display: none;
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
}

.posts-mobile-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.posts-mobile-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.download-app-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.875rem;
    transition: var(--transition);
    cursor: pointer;
}

.download-app-btn:hover {
    background: var(--primary-color);
    color: #0b0b0b;
}

.menu-toggle-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-dark);
    font-size: 1.5rem;
}

/* ===== Main Layout ===== */
.posts-main-layout {
    display: flex;
    flex-direction: row-reverse; /* RTL: Sidebar على اليمين */
    max-width: 1920px;
    margin: 0 auto;
    min-height: calc(100vh - 72px);
}

/* ===== Sidebar ===== */
.posts-sidebar {
    width: 240px;
    background: white;
    border-right: 1px solid var(--border-color); /* تغيير من left إلى right */
    padding: 2rem 1rem;
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    overflow-y: auto;
    direction: rtl; /* RTL للنصوص */
}

.posts-upload-btn {
    display: block;
    width: 100%;
    padding: 0.875rem;
    background: var(--secondary-color);
    color: white;
    text-align: center;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 1.5rem;
}

.posts-upload-btn:hover {
    background: #111111;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: white;
}

.posts-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.posts-nav-item {
    margin-bottom: 0.5rem;
}

.posts-nav-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-dark);
    transition: var(--transition);
    gap: 0.75rem;
}

.posts-nav-link:hover,
.posts-nav-link.active {
    background: #fff6bf;
    color: var(--primary-color);
}

.posts-nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.posts-nav-text {
    font-weight: 500;
}

/* ===== Content Area ===== */
.posts-content {
    flex: 1;
    padding: 2rem;
    overflow-x: hidden;
    direction: rtl; /* RTL للنصوص */
}

/* ===== Page Title ===== */
.posts-page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1.5rem;
}

/* ===== Empty State ===== */
.posts-empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.posts-empty-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem;
    opacity: 0.6;
}

.posts-empty-text {
    font-size: 1.125rem;
    color: var(--text-gray);
    font-weight: 500;
}

/* ===== Loading State ===== */
.posts-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.posts-loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.posts-loading-text {
    margin-top: 1.5rem;
    font-size: 1rem;
    color: var(--text-gray);
}

/* ===== Posts Table - Desktop ===== */
.posts-table-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.posts-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.posts-table thead {
    background: var(--bg-light);
}

.posts-table thead th {
    padding: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.875rem;
    text-align: right;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.posts-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.posts-table tbody tr:last-child {
    border-bottom: none;
}

.posts-table tbody td {
    padding: 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
}

/* ===== Video Cell ===== */
.posts-video-cell {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.posts-video-wrapper {
    position: relative;
    width: 100px;
    height: 150px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    background: #000;
}

.posts-video-wrapper video,
.posts-video-wrapper > div {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.posts-video-player {
    width: 100% !important;
    height: 100% !important;
}

.posts-video-player video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.posts-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.posts-play-btn:hover {
    background: white;
    transform: translate(-50%, -50%) scale(1.1);
}

.posts-play-btn svg {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

.posts-video-info {
    flex: 1;
    min-width: 0;
}

.posts-video-title {
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 0.5rem 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.posts-video-date {
    font-size: 0.813rem;
    color: var(--text-gray);
    margin: 0;
}

/* ===== Status Badge ===== */
.posts-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.813rem;
    font-weight: 600;
    white-space: nowrap;
}

.posts-status-badge.active {
    background: #e8f5e9;
    color: var(--success-color);
}

.posts-status-badge.inactive {
    background: #fff3e0;
    color: var(--warning-color);
}

/* ===== Stats Cell ===== */
.posts-stat {
    font-weight: 600;
    color: var(--text-dark);
}

/* ===== Actions Cell ===== */
.posts-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.posts-action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-light);
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.posts-action-btn:hover {
    background: #fee;
    transform: translateY(-2px);
}

.posts-action-btn img,
.posts-action-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== Dropdown Menu Items ===== */
.posts-actions .dropdown-menu .dropdown-item,
.posts-card-actions .dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    transition: var(--transition);
}

.posts-actions .dropdown-menu .dropdown-item svg,
.posts-card-actions .dropdown-menu .dropdown-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.posts-actions .dropdown-menu .dropdown-item:hover,
.posts-card-actions .dropdown-menu .dropdown-item:hover {
    background: var(--bg-light);
}

.posts-actions .dropdown-menu .dropdown-item.text-danger:hover,
.posts-card-actions .dropdown-menu .dropdown-item.text-danger:hover {
    background: #fee;
}

/* ===== Edit Modal ===== */
.posts-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.posts-modal {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.posts-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.posts-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.posts-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-light);
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--text-gray);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.posts-modal-close:hover {
    background: #fee;
    color: var(--danger-color);
}

.posts-modal-body {
    padding: 2rem;
}

.posts-form-group {
    margin-bottom: 1.5rem;
}

.posts-form-label {
    display: block;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.posts-form-input,
.posts-form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: var(--transition);
    font-family: inherit;
}

.posts-form-input:focus,
.posts-form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 223, 0, 0.2);
}

.posts-form-textarea {
    resize: vertical;
    min-height: 120px;
}

.posts-form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.posts-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.posts-btn-primary {
    background: var(--secondary-color);
    color: white;
}

.posts-btn-primary:hover {
    background: #111111;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.posts-btn-secondary {
    background: var(--bg-light);
    color: var(--text-dark);
}

.posts-btn-secondary:hover {
    background: #e9ecef;
}

/* ===== Mobile Cards View ===== */
.posts-cards-container {
    display: none;
    gap: 1rem;
}

.posts-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.posts-card:hover {
    box-shadow: var(--shadow-md);
}

.posts-card-header {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.posts-card-video {
    position: relative;
    width: 80px;
    height: 120px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    background: #000;
}

.posts-card-info {
    flex: 1;
    min-width: 0;
}

.posts-card-title {
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    font-size: 0.938rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.posts-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.posts-card-id {
    font-size: 0.813rem;
    color: var(--text-gray);
}

.posts-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-light);
}

.posts-card-stat {
    text-align: center;
}

.posts-card-stat-label {
    font-size: 0.75rem;
    color: var(--text-gray);
    margin-bottom: 0.25rem;
}

.posts-card-stat-value {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1rem;
}

.posts-card-actions {
    display: flex;
    padding: 1rem;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ===== Responsive Design ===== */

/* Tablet */
@media (max-width: 1024px) {
    .posts-sidebar {
        width: 200px;
    }

    .posts-content {
        padding: 1.5rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Hide desktop header */
    .posts-header {
        display: none;
    }

    /* Show mobile header */
    .posts-mobile-header {
        display: block;
    }

    /* Hide sidebar */
    .posts-sidebar {
        display: none;
    }

    /* Full width content */
    .posts-content {
        padding: 1rem;
    }

    /* Hide desktop table */
    .posts-table-container {
        display: none;
    }

    /* Show mobile cards */
    .posts-cards-container {
        display: flex;
        flex-direction: column;
    }

    /* Modal adjustments */
    .posts-modal {
        max-width: 100%;
        max-height: 95vh;
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .posts-modal-body {
        padding: 1.5rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .posts-header-content {
        padding: 0.75rem 1rem;
    }

    .download-app-btn span {
        display: none;
    }

    .posts-card-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
}

/* ===== Dropdown Menu ===== */
.posts-dropdown {
    position: relative;
}

.posts-dropdown-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
}

.posts-dropdown-menu {
    position: absolute;
    left: 0;
    top: 100%;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 0.5rem 0;
    z-index: 10;
    margin-top: 0.25rem;
}

.posts-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.posts-dropdown-item:hover {
    background: var(--bg-light);
}

.posts-dropdown-item img {
    width: 18px;
    height: 18px;
}

/* ===== Pagination ===== */
.posts-pagination {
    margin-top: 2rem;
}

/* ===== Utility Classes ===== */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
