/*
 * Hopino Role Ads Stylesheet
 *
 * Provides the golden, dark and elegant visual identity for the plugin. The
 * variables at the top can be overridden via inline CSS or theme integration.
 */
:root {
    --hopx-gold: #C7A144;
    --hopx-gold-light: #D4AF37;
    --hopx-black: #0F0F12;
    --hopx-surface: #FFFFFF;
    --hopx-muted: #8B8B92;
    --hopx-radius: 14px;
    --hopx-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

/* Reset for plugin elements */
.hopx-form, .hopx-ads-grid, .hopx-table {
    direction: rtl;
    font-family: inherit;
    box-sizing: border-box;
}

.hopx-form-group {
    margin-bottom: 1rem;
}

.hopx-form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.hopx-input,
.hopx-textarea,
.hopx-input-small,
.hopx-select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--hopx-radius);
    background-color: #f9f9f9;
    color: var(--hopx-black);
    font-size: 0.95rem;
    line-height: 1.5;
}

.hopx-textarea {
    resize: vertical;
}

.hopx-input-small {
    width: auto;
    display: inline-block;
}

/* Buttons */
.hopx-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: var(--hopx-radius);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.hopx-btn-primary {
    background-image: linear-gradient(45deg, var(--hopx-gold), var(--hopx-gold-light));
    color: #fff;
}

.hopx-btn-secondary {
    background-color: var(--hopx-muted);
    color: #fff;
}

.hopx-btn-danger {
    background-color: #e74c3c;
    color: #fff;
}

.hopx-btn:hover {
    box-shadow: 0 0 8px var(--hopx-gold-light);
}

/* Alerts */
.hopx-alert {
    padding: 0.75rem;
    border-radius: var(--hopx-radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.hopx-alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

.hopx-alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.hopx-alert-success {
    background-color: #d4edda;
    color: #155724;
}

.hopx-alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Ads grid and cards */
.hopx-ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.hopx-ad-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--hopx-muted);
    border-radius: var(--hopx-radius);
    box-shadow: var(--hopx-shadow);
    overflow: hidden;
    background-color: var(--hopx-surface);
    position: relative;
}

/* Label for main category shown at top-left of ad card */
.hopx-ad-main-cat {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background-color: rgba(199, 161, 68, 0.9);
    color: #fff;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    border-radius: var(--hopx-radius);
    z-index: 4;
}

/* Location text at bottom-left of ad card body */
.hopx-ad-location {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--hopx-muted);
}

.hopx-ad-thumb {
    width: 100%;
    height: 160px;
    overflow: hidden;
    background-color: #f5f5f5;
}

.hopx-ad-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Bookmark icon in ad cards and modal */
.hopx-bookmark-icon {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.4rem;
    color: #d0d0d0;
    cursor: pointer;
    z-index: 5;
    transition: color 0.2s ease;
    user-select: none;
}
.hopx-bookmark-icon:hover {
    color: var(--hopx-gold);
}
.hopx-bookmark-icon.bookmarked {
    color: var(--hopx-gold);
}

/* Loading spinner inside modal */
.hopx-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
    font-size: 1rem;
    color: var(--hopx-black);
}
.hopx-loading .hopx-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--hopx-gold);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: hopx-spin 1s linear infinite;
    margin-bottom: 0.5rem;
}
@keyframes hopx-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Layout for ad view modal */
.hopx-ad-view-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
@media (min-width: 768px) {
    .hopx-ad-view-container {
        flex-direction: row;
    }
    .hopx-ad-view-left,
    .hopx-ad-view-right {
        flex: 1;
    }
}
.hopx-ad-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.hopx-ad-view-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--hopx-black);
}
.hopx-ad-view-meta p,
.hopx-ad-view-meta .hopx-ad-view-custom {
    margin: 0.25rem 0;
    font-size: 0.95rem;
    color: var(--hopx-black);
}
.hopx-ad-view-description {
    margin-top: 1rem;
    line-height: 1.6;
    color: var(--hopx-black);
}
.hopx-ad-view-contact {
    margin-top: 1rem;
    font-weight: 600;
    color: var(--hopx-black);
}

/* Selected images preview */
.hopx-selected-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--hopx-radius);
    border: 1px solid #e0e0e0;
}

.hopx-ad-body {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
}

.hopx-ad-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--hopx-black);
}

.hopx-ad-title a {
    color: inherit;
    text-decoration: none;
}

.hopx-ad-title a:hover {
    text-decoration: underline;
}

.hopx-ad-price {
    margin-top: 0.25rem;
    font-weight: 700;
    color: var(--hopx-gold-light);
}

.hopx-ad-cats,
.hopx-ad-groups {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--hopx-muted);
}

/* Tables */
.hopx-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background-color: var(--hopx-surface);
    box-shadow: var(--hopx-shadow);
    border-radius: var(--hopx-radius);
    overflow: hidden;
}

.hopx-table th,
.hopx-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--hopx-muted);
    text-align: right;
    direction: rtl;
}

.hopx-table th {
    background-color: var(--hopx-black);
    color: #fff;
    font-weight: 600;
}

.hopx-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* Moderator dashboard controls */
.hopx-mod-actions button {
    margin-left: 0.25rem;
}

.hopx-input-small {
    width: 120px;
    margin-right: 0.25rem;
}

.hopx-checkbox {
    margin-bottom: 0.25rem;
}

/* RTL adjustments */
.hopx-form-group {
    text-align: right;
}

.hopx-form-group input,
.hopx-form-group select,
.hopx-form-group textarea {
    text-align: right;
}

/* Modal overlay and content */
.hopx-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.6);
}

.hopx-modal-content {
    position: relative;
    background: var(--hopx-surface);
    border-radius: var(--hopx-radius);
    padding: 1.5rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--hopx-shadow);
}

.hopx-modal-close {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 2rem;
    color: #ffffff;
    cursor: pointer;
}

/* Employment-only fields hidden by default */
.hopx-employment-only {
    display: none;
}

/* Gallery styles for ad view modal */
.hopx-ad-view-gallery {
    width: 100%;
    margin-bottom: 1rem;
}
.hopx-gallery-main {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--hopx-radius);
    border: 1px solid #e0e0e0;
}
.hopx-gallery-main img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}
.hopx-gallery-prev,
.hopx-gallery-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    color: var(--hopx-gold);
    background: rgba(255, 255, 255, 0.8);
    width: 32px;
    height: 32px;
    line-height: 30px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
}
.hopx-gallery-prev {
    right: auto;
    left: 0.5rem;
}
.hopx-gallery-next {
    left: auto;
    right: 0.5rem;
}
.hopx-gallery-thumbs {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}
.hopx-gallery-thumbs img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--hopx-radius);
    border: 2px solid transparent;
    cursor: pointer;
}
.hopx-gallery-thumbs img.active {
    border-color: var(--hopx-gold);
}

/* ------------------------------------------------------------------ */
/* Gallery modal styles */
/*
 * The gallery modal is used when users choose images or videos from their
 * personal library. It overlays the page and displays a searchable grid
 * of media items. Selected items are highlighted, and users can upload
 * new files via the upload field in the main form. The modal uses flex
 * to center its content and ensures responsive sizing on various screens.
 */
.hopx-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.hopx-gallery-modal-content {
    background: #fff;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--hopx-radius);
    overflow: hidden;
    box-shadow: var(--hopx-shadow);
}
.hopx-gallery-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}
.hopx-gallery-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}
.hopx-gallery-modal-close {
    cursor: pointer;
    font-size: 1.5rem;
    color: #666;
}
.hopx-gallery-modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}
.hopx-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
}
.hopx-gallery-item {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 aspect ratio */
    background: #f7f7f7;
    border-radius: var(--hopx-radius);
    cursor: pointer;
    overflow: hidden;
}
.hopx-gallery-item img,
.hopx-gallery-item video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--hopx-radius);
}
.hopx-gallery-item.selected {
    outline: 3px solid var(--hopx-gold);
    outline-offset: -3px;
}
.hopx-gallery-modal-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    border-top: 1px solid #eee;
    gap: 0.5rem;
}
.hopx-gallery-modal-actions .hopx-btn {
    margin: 0;
}

/* Improved form container styling */
.hopx-form-ad-submit {
    background: var(--hopx-surface);
    padding: 1.5rem;
    border-radius: var(--hopx-radius);
    box-shadow: var(--hopx-shadow);
    margin-bottom: 1.5rem;
    border: 1px solid #e5e5e5;
}

/* Accordion styles for province/city selection */
.hopx-accordion {
    border: 1px solid #e5e5e5;
    border-radius: var(--hopx-radius);
    background: #f5f5f5;
}
.hopx-accordion-header {
    padding: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    position: relative;
}
.hopx-accordion-header::after {
    content: '\25BE'; /* downward arrow */
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s ease;
}
.hopx-accordion.active .hopx-accordion-header::after {
    transform: translateY(-50%) rotate(180deg);
}
.hopx-accordion-content {
    padding: 0.75rem;
    border-top: 1px solid #e5e5e5;
    background: #fff;
}

/* Input backgrounds and focus styles */
.hopx-form-group .hopx-input,
.hopx-form-group .hopx-textarea,
.hopx-form-group select {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
}

.hopx-form-group .hopx-input:focus,
.hopx-form-group .hopx-textarea:focus,
.hopx-form-group select:focus {
    border-color: var(--hopx-gold);
    box-shadow: 0 0 0 3px rgba(199, 161, 68, 0.25);
    outline: none;
}

/* User personal gallery page */
.hopx-user-gallery-page {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.hopx-user-gallery-item {
    position: relative;
    width: 120px;
    height: 120px;
    border: 1px solid #e0e0e0;
    border-radius: var(--hopx-radius);
    overflow: hidden;
}
.hopx-user-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.hopx-user-img-delete {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    color: #fff;
    background-color: rgba(231, 76, 60, 0.8);
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    z-index: 10;
}

/* ------------------------------------------------------------------ */
/* Filter form styles */
/* Use a responsive grid layout for the search/filter controls to improve
   alignment on wider screens and wrap gracefully on smaller devices. */
.hopx-filter-form {
    display: grid;
    /* Use auto-fill to distribute items evenly and allow smaller widths on very wide screens. */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

/* Group price inputs together horizontally within the grid */
.hopx-price-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: nowrap;
}
.hopx-filter-input,
.hopx-filter-select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--hopx-radius);
    background-color: #f9f9f9;
    color: var(--hopx-black);
    font-size: 0.9rem;
}
.hopx-price-input {
    max-width: 120px;
}
.hopx-filter-btn {
    background-image: linear-gradient(45deg, var(--hopx-gold), var(--hopx-gold-light));
    color: #fff;
    border: none;
    border-radius: var(--hopx-radius);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: box-shadow 0.2s ease;
}
.hopx-filter-btn:hover {
    box-shadow: 0 0 6px var(--hopx-gold-light);
}