/* Container */
.mha-upload-container {
    /*background: #f9f9f9;*/
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #ddd;
    max-width: 600px;
    margin: 0 auto;
    font-family: 'Tajawal', sans-serif; /* If available */
}

/* Labels */
.mha-form-group {
    margin-bottom: 20px;
}
.mha-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
    font-size: 16px;
}

/* Inputs & Selects - Big for Mobile */
.mha-upload-container input[type="text"],
.mha-upload-container textarea,
.mha-select-big {
    width: 100%;
    padding: 9px 10px 9px 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
}

/* File Upload Customization */
.mha-file-upload-wrapper {
    position: relative;
    text-align: center;
    border: 2px dashed #0073aa; /* dashed border makes it look like a drop zone */
    border-radius: 10px;
    padding: 20px;
    background: #fff;
    cursor: pointer;
}
.mha-file-upload-wrapper input[type="file"] {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
}
.mha-file-custom-btn {
    font-size: 18px;
    color: #0073aa;
    font-weight: bold;
}
.mha-file-custom-btn.selected {
    color: green;
}
#mha-file-name {
    display: block;
    margin-top: 10px;
    color: #666;
    font-size: 14px;
}

/* Submit Button */
.mha-btn-primary {
    width: 100%;
    padding: 15px;
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}
.mha-btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Alerts */
.mha-alert {
    padding: 15px;
    margin-top: 15px;
    border-radius: 8px;
    text-align: center;
}
.mha-alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.mha-alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* --- Gallery Grid (Mobile First) --- */

.mha-gallery-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    font-family: 'Tajawal', sans-serif;
}

/* Filter Bar */
.mha-filter-bar {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}
.mha-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.mha-filter-row input, 
.mha-filter-row select {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
}
.mha-filter-row button {
    background: #333;
    color: #fff;
    border: none;
    padding: 0 20px;
    border-radius: 6px;
    cursor: pointer;
}

/* The Grid */
.mha-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Small columns for mobile */
    gap: 15px;
}

/* Desktop Adjustment */
@media (min-width: 768px) {
    .mha-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 20px;
    }
}

/* Card Design */
.mha-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    text-decoration: none;
}
.mha-card:hover {
    transform: translateY(-5px);
}
.mha-card a {
    text-decoration: none;
    
}

/* Image Area */
.mha-card-image {
    position: relative;
    height: 160px; /* Fixed height for uniformity */
    background: #eee;
    overflow: hidden;
}
.mha-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Crops image nicely */
}

/* Confidence Badge */
.mha-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.badge-verified { background-color: #28a745; } /* Green */
.badge-estimated { background-color: #ffc107; color: #333; } /* Yellow */
.badge-unknown { background-color: #6c757d; } /* Grey */

/* Card Body */
.mha-card-body {
    padding: 12px;
}
.mha-card-body h3 {
    margin: 0 0 5px 0;
    font-size: 16px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tag-decade {
    display: inline-block;
    background: #f0f0f1;
    color: #555;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Pagination */
.mha-pagination {
    margin-top: 30px;
    text-align: center;
}
.mha-pagination .page-numbers {
    padding: 8px 12px;
    border: 1px solid #ddd;
    margin: 0 2px;
    text-decoration: none;
    border-radius: 4px;
    color: #333;
}
.mha-pagination .current {
    background: #2f433e;
    color: #fff;
    border-color: #4b5f5c;
}

/* --- Tag Input System (WooCommerce Style) --- */

.mha-tags-input-box {
    
    padding: 5px 8px; /* Added slight horizontal padding */
    border-radius: 8px;
    
    /* FORCE HORIZONTAL LAYOUT */
    display: flex;
    flex-direction: row; /* Forces left-to-right flow */
    flex-wrap: wrap;     /* Wraps to next line only if full */
    align-items: center; /* Vertically centers tags and input */
    gap: 6px;            /* Space between tags */
    
    cursor: text;
    min-height: 45px;
    width: 100%;         /* Ensure container is full width */
    box-sizing: border-box;
}

.mha-tags-input-box:focus-within {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

/* The selected Tag (Green Box) */
.mha-tag-item {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 2px 8px;    /* Compact padding */
    margin-left: 5px;
    font-size: 14px;
    
    /* FORCE INLINE BEHAVIOR */
    display: inline-flex; 
    align-items: center;
    width: auto;         /* Prevents full width */
    white-space: nowrap; /* Prevents text breaking inside tag */
    cursor: default;
}

/* The 'X' remove button */
.mha-tag-remove {
    margin-right: 6px; /* Space between X and text (RTL) */
    cursor: pointer;
    font-weight: bold;
    color: #155724;
    opacity: 0.6;
    font-size: 16px;
    line-height: 1;
}

.mha-tag-remove:hover {
    opacity: 1;
    color: #721c24;
}

/* The typing input inside the box */
#mha-tag-entry {
    border: none;
    outline: none;
    background: transparent;
    padding: 5px;
    font-size: 15px;
    color: #333;
    
    /* FLEX BEHAVIOR */
    flex-grow: 1;        /* Takes up remaining space */
    width: auto;         /* Prevents fixed width issues */
    min-width: 80px;     /* Ensure it's not too small to click */
    margin: 0;
    height: auto;        /* Fix for some themes setting fixed height */
    box-shadow: none;    /* Remove theme shadows */
}

/* Suggestions Dropdown */
.mha-suggestions-dropdown {
    list-style: none !important; /* Force remove bullets */
    margin: 0;
    padding: 0;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;       /* Ensure it floats above everything */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.mha-suggestions-dropdown li {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    color: #333;
    display: block;      /* Ensure list items are blocks */
    width: 100%;
}

.mha-suggestions-dropdown li:hover {
    background-color: #f0f0f1;
    color: #0073aa;
}

/* --- Single Artifact Page --- */

.mha-single-container {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
    font-family: 'Tajawal', sans-serif;
}

.mha-single-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
}

/* Image Column */
.mha-single-image-box {
    flex: 1 1 500px; /* Takes up 60% of width on desktop */
}
.mha-single-image-box img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid #eee;
}

/* Details Column */
.mha-single-details {
    flex: 1 1 300px; /* Takes up 40% of width */
}

.mha-single-title {
    margin-top: 0;
    font-size: 32px;
    color: #222;
    line-height: 1.3;
}

.mha-description-box {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border-right: 4px solid #0073aa;
}

.mha-description-box h3 { margin-top: 0; font-size: 18px; color: #555; }
.mha-content { font-size: 16px; line-height: 1.8; color: #444; }

/* Tags */
.mha-tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.mha-tag-link {
    background: #eef2f5;
    color: #0073aa;
    padding: 5px 12px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}
.mha-tag-link:hover {
    background: #0073aa;
    color: #fff;
}

/* Download Button */
.mha-btn-download {
    display: block;
    background-color: #28a745;
    color: white;
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
    transition: transform 0.2s;
    margin-top: 30px;
    box-shadow: 0 4px 6px rgba(40, 167, 69, 0.2);
}
.mha-btn-download:hover {
    transform: translateY(-2px);
    background-color: #218838;
    color: white;
}
.mha-btn-download small {
    display: block;
    font-size: 12px;
    font-weight: normal;
    opacity: 0.9;
}


/* Container & Global */
:root {
    --mha-primary: #39624c;
    --mha-bg-light: #f8f9fa;
    --mha-border: #e9ecef;
    --mha-text-muted: #6c757d;
}
.mha-container {
    max-width: 1130px;
    margin: 2rem auto;
    font-family: inherit;
    direction: rtl;
    text-align: right;
}
.mha-card {
    background: #fff;
    border: 1px solid var(--mha-border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* Image Section */
.mha-image-wrapper {
    background-color: #f0f2f5;
    text-align: center;
    position: relative;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.mha-image-wrapper img {
    max-width: 100%;
    max-height: 600px;
    height: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border-radius: 4px;
}

/* Download Button */
.mha-action-bar { margin-top: 15px; }
.mha-drive-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #198754;
    color: #fff;
    border: 1px solid #198754;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.mha-drive-btn:hover {
    background: #146c43;
    color: #fff;
    transform: translateY(-1px);
}

/* Layout Elements */
.mha-body { padding: 2rem; }
.mha-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.mha-title { margin: 0; font-size: 1.8rem; font-weight: 700; line-height: 1.2; }

/* Badges */
.mha-badge {
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid transparent;
}
.mha-badge-verified { background: #d1e7dd; color: #0f5132; border-color: #badbcc; }
.mha-badge-estimated { background: #fff3cd; color: #664d03; border-color: #ffecb5; }
.mha-badge-unknown { background: #e2e3e5; color: #41464b; border-color: #d3d6d8; }

/* Metadata Grid */
.mha-grid {
    display: grid;
    /* Desktop: 2 columns */
    grid-template-columns: 1fr 1fr; 
    gap: 15px;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--mha-border);
}
/* CORRECTED INFO ITEM (Fixes Vertical Family List) */
.mha-info-item {
    background-color: var(--mha-bg-light);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.03);
    margin-bottom: 0; /* Reset */
    
    /* CRITICAL CHANGE: Use block instead of flex-column */
    display: block; 
    line-height: 1.6; /* Improves readability of text wrapping */
}

/* Style the Label & Icon to sit nicely inline */
.mha-info-item strong { 
    display: inline-block;
    color: #555; 
    font-size: 0.95rem;
    margin-left: 5px; /* Space between label and first name */
}

/* Icon adjustments */
.mha-info-item i { 
    color: var(--mha-primary); 
    font-size: 1rem;
    vertical-align: middle;
    margin-left: 5px;
    position: relative;
    top: -2px; /* Slight alignment fix */
}

/* Ensure links stand out but stay inline */
.mha-info-item .mha-link {
    font-weight: 400;
    color: #333;
    background-color:rgba(47, 132, 91, 0.2);
    padding: 4px 6px 4px 6px;
    border-radius: 7px;
    display: inline; /* Forces them to sit next to each other */
    text-decoration: none;
}

.mha-link:hover {
    background-color: var(--mha-primary); 
    color: white;
}

/* Add hover effect for better UI */
.mha-info-item:hover {
    background-color: #f1f3f5;
    border-color: rgba(0,0,0,0.08);
}

.mha-tag {
    background: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--mha-primary);
    display: inline-block;
    border: 1px solid #e1e4e8;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.mha-link { color: var(--mha-primary); text-decoration: none; }
.mha-link:hover { text-decoration: underline; }

/* Footer */
.mha-footer {
    background: var(--mha-bg-light);
    padding: 1rem 2rem;
    border-top: 1px solid var(--mha-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mha-btn-back { text-decoration: none; color: var(--mha-text-muted); font-weight: 500; }
.mha-btn-back:hover { color: #333; }







/* 5. Mobile Optimization (Max Width 768px) */
@media (max-width: 768px) {
    /* Reduce padding on mobile to save space */
    .mha-body { 
        padding: 1.25rem; 
    }

    /* Stack Header elements vertically */
    .mha-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    /* Force Grid to 1 column (Stack items) */
    .mha-grid {
        grid-template-columns: 1fr; 
        gap: 12px;
    }

    /* Adjust font sizes for mobile */
    .mha-title {
        font-size: 1.5rem;
    }
    
    /* Ensure buttons in header span full width on mobile for easier tapping */
    /* ✅ NEW CODE: Stack buttons vertically */
    .mha-action-bar {
        width: 100%;
        display: flex;
        flex-direction: column !important; /* Stack buttons top-to-bottom */
        align-items: stretch !important;   /* Stretch them to fill width */
        gap: 10px !important;              /* Add space between buttons */
    }
    
    .mha-action-bar .btn {
        width: 100% !important;            /* Force full width */
        justify-content: center;           /* Center the text/icon */
        margin: 0 !important;
    }
    
    /* Fix for the "People" tag input box on mobile */
    #mha-tag-suggestion-box {
        width: 100%;
    }
}





/* --- PHASE 4: ARCHIVE GALLERY STYLES --- */

.mha-archive-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    font-family: inherit;
    direction: rtl;
}

/* Header */
.mha-archive-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #eee;
}
.mha-header-content h1 { font-size: 2.5rem; color: #333; margin-bottom: 0.5rem; }
.mha-header-content p { color: #777; font-size: 1.1rem; }

/* Search Box */
.mha-search-box {
    max-width: 600px;
    margin: 20px auto 0;
    position: relative;
}
.mha-search-box input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 50px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    font-size: 1rem;
}
.mha-search-box button {
    position: absolute;
    left: 5px;
    top: 5px;
    background: var(--mha-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

/* Layout (Sidebar + Grid) */
.mha-archive-layout {
    display: flex;
    gap: 30px;
}
.mha-sidebar {
    width: 250px;
    flex-shrink: 0;
}
.mha-main-grid {
    flex-grow: 1;
}

/* Filters */
.mha-filter-group { margin-bottom: 20px; }
.mha-filter-group h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}
.mha-filter-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}
.mha-reset-btn {
    display: block;
    text-align: center;
    font-size: 0.9rem;
    color: #d63384;
    text-decoration: none;
    margin-top: 10px;
}

/* Grid */
.mha-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}
.mha-grid-item {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    text-decoration: none;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}
.mha-grid-item:hover { transform: translateY(-5px); }

.mha-thumb {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: #f0f2f5;
}
.mha-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.3s;
}
.mha-no-thumb {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 2rem;
}
.mha-overlay {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: 0.2s;
}
.mha-grid-item:hover .mha-overlay { opacity: 1; }
.mha-view-btn {
    background: #fff;
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
}

.mha-item-details { padding: 15px; }
.mha-item-details h2 {
    font-size: 1.1rem;
    margin: 0 0 10px;
    color: #333;
    line-height: 1.4;
}
.mha-mini-tag {
    background: #eef2ff;
    color: var(--mha-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Pagination */
.mha-pagination {
    margin-top: 40px;
    text-align: center;
}
.mha-pagination .page-numbers {
    padding: 8px 12px;
    border: 1px solid #ddd;
    margin: 0 3px;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
}
.mha-pagination .current {
    background: var(--mha-primary);
    color: #fff;
    border-color: var(--mha-primary);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mha-archive-layout { flex-direction: column; }
    .mha-sidebar { width: 100%; margin-bottom: 20px; }
    .mha-grid-container { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .mha-thumb { height: 150px; }
}




/* --- Fix Bootstrap Link Override --- */
/* Force all links inside your plugin wrapper to inherit Blocksy's color */
.mha-upload-container a,
.mha-gallery-wrapper a,
.mha-single-container a {
    color: var(--paletteColor1, inherit); /* Blocksy usually uses this var */
    text-decoration: none;
}

.mha-upload-container a:hover,
.mha-gallery-wrapper a:hover,
.mha-single-container a:hover {
    color: var(--paletteColor2, #2b3835); /* Hover color */
}

/* If you want to fix it GLOBALLY for the whole page where Bootstrap is loaded: */
body a {
    color: inherit !important;
    text-decoration: none !important;
}


/* --- Lightbox Fix --- */
#mha-lightbox-overlay {
    display: none; /* 1. Hidden by default so it takes 0 space */
    position: fixed; /* 2. Float above everything else */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999; /* Ensure it is on top of the menu */
    align-items: center;
    justify-content: center;
}

/* When active (added by JS), we use flex to center the image */
#mha-lightbox-overlay.active {
    display: flex;
}