/* Wardens Journal Frontend Styles */

/* General Styles */
.wj-journals-list,
.wj-journal-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        sans-serif;
    line-height: 1.6;
    color: #333;
}

/* Increase specificity and use !important sparingly to override theme defaults */
.wj-journals-list *,
.wj-journal-page * {
    box-sizing: border-box;
}

/* Buttons override common theme button styles */
.wj-journal-page .wj-btn,
.wj-journals-list .wj-btn {
    text-transform: none !important;
    letter-spacing: normal !important;
}

.wj-journal-page {
    max-width: 1400px;
    margin: 0 auto;
    background: none;
    min-height: 100vh;
    padding: 0rem;
    border-radius: 0px;
    box-shadow: 0 0px 0px rgba(0, 0, 0, 0.08);
}

/* Header Styles */
.wj-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0rem;
    padding-bottom: 0rem;
    border-bottom: 0px solid #333333;
}

.wj-header h2 {
    color: var(--ast-global-color-0);
    margin: 0;
    font-size: 2.625rem;
}

/* Button Styles */
.wj-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    font-size: 1rem;
}

.wj-btn-primary {
    background-color: #c85c34;
    color: white;
}

.wj-btn-primary:hover {
    background-color: #000000;
    color: white;
}

.wj-btn-primary_accent {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    font-size: 1.2rem;
    background-color: white;
    color: black;
}

.wj-btn-primary_accent::after {
    content: url(https://gameholepublishing.com/wp-content/uploads/2024/08/EM_Icon.png);
    vertical-align: -100%;
}

.wj-btn-primary_accent:hover {
    background-color: white;
    color: #c85c34;
}

.wj-btn-secondary {
    background-color: #c85c34;
    color: white;
}

.wj-btn-secondary:hover {
    background-color: #000000;
    color: white;
}

.wj-btn-danger {
    background-color: #e3e3e3;
    color: #999;
}

.wj-btn-danger:hover {
    background-color: #000000;
    color: white;
}

/* Journal List Styles */
.wj-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    font-style: italic;
}

.wj-journals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.wj-journal-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.wj-journal-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wj-journal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.wj-journal-header h3 {
    margin: 0;
    color: #8b4513;
    font-size: 1.2rem;
}

.wj-journal-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.wj-journal-actions .wj-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.wj-journal-details {
    margin-bottom: 1rem;
}

.wj-detail-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.wj-detail-row:last-child {
    margin-bottom: 0;
}

.wj-detail {
    font-size: 0.9rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    min-width: 140px;
}

.wj-detail strong {
    color: #8b4513;
    font-weight: 600;
    white-space: nowrap;
}

.wj-detail .wj-value {
    color: #333;
    font-weight: 500;
}

.wj-detail.wj-empty .wj-value.wj-not-set {
    color: #999;
    font-style: italic;
    font-weight: normal;
}

/* Specific detail styling */
.wj-detail.wj-level .wj-value {
    background: #8b4513;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

.wj-detail.wj-class .wj-value {
    background: #f8f9fa;
    color: #8b4513;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.wj-detail.wj-alliance .wj-value {
    background: linear-gradient(135deg, #8b4513, #a0522d);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.wj-detail-row.wj-stats {
    border-top: 1px solid #eee;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.wj-detail-row.wj-stats .wj-detail {
    min-width: auto;
    flex: 0 0 auto;
}

.wj-detail-row.wj-stats .wj-value {
    background: #e9ecef;
    color: #495057;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 25px;
    text-align: center;
}

.wj-journal-meta {
    border-top: 1px solid #eee;
    padding-top: 0.75rem;
    color: #888;
    font-size: 0.8rem;
}

/* Journal Page Styles */
.wj-journal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding: 0rem 0;
    border-bottom: 0px solid #8b4513;
    background: linear-gradient(
        135deg,
        rgba(139, 69, 19, 0.05),
        rgba(160, 82, 45, 0.05)
    );
    border-radius: 8px 8px 0 0;
    position: relative;
}

.wj-journal-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b4513, #a0522d, #cd853f);
    border-radius: 8px 8px 0 0;
}

.wj-journal-header h2 {
    font-size: 2.625rem;
}

.wj-journal-header .wj-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wj-journal-header .wj-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.wj-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.wj-journal-content {
    margin-top: 0rem;
    margin-bottom: 3rem;
}

@media (max-width: 768px) {
    .wj-journal-page {
        padding: 1rem;
        border-radius: 0;
    }

    .wj-journal-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .wj-journal-header h1 {
        font-size: 1.8rem;
    }

    .wj-journal-sidebar {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-top: 2rem;
    }

    .wj-journal-form {
        padding: 1.5rem;
    }

    .wj-alliance-rewards,
    .wj-rule-helpers {
        padding: 1.5rem;
    }

    .wj-rule-helpers {
        flex-direction: column;
        gap: 1rem;
    }

    .wj-helper-box {
        min-height: auto;
    }

    .wj-counter {
        font-size: 1.6rem;
        padding: 0.5rem;
    }
}

.wj-journal-form {
    background: white;
    padding: 0rem;
    border: 0px solid #e0e0e0;
    border-radius: 0px;
    box-shadow: 0 0px 0px rgba(0, 0, 0, 0.08);
    position: relative;
    /* Allow Select2 dropdowns to escape the container */
    overflow: visible;
    font-family: Gelica, Helvetica, Arial;
}

.wj-journal-form::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0px;
    background: linear-gradient(90deg, #8b4513, #a0522d, #cd853f);
}

.wj-journal-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 3rem;
}

/* Alliance Rewards Styles */
.wj-alliance-rewards {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.wj-alliance-rewards::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b4513, #a0522d, #cd853f);
}

.wj-alliance-rewards h3 {
    margin: 0 0 1.5rem 0;
    color: #8b4513;
    font-size: 1.3rem;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.wj-rewards-table {
    overflow-x: auto;
}

.wj-rewards-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.wj-rewards-table th,
.wj-rewards-table td {
    padding: 0.5rem;
    border: 1px solid #ddd;
    text-align: left;
}

.wj-rewards-table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.wj-rewards-table tr.current-level {
    background-color: #fff3cd;
    font-weight: 500;
}

/* Rule Helpers Styles */
.wj-rule-helpers {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.wj-rule-helpers::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #8b4513, #a0522d, #cd853f);
}

.wj-rule-helpers h3 {
    margin: 0 0 1.5rem 0;
    color: #8b4513;
    font-size: 1.3rem;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.wj-rule-helpers {
    display: flex;
    gap: 1.5rem;
    align-items: stretch;
}

.wj-rule-helpers > h3 {
    display: none; /* Hide the main title since we have individual box titles */
}

.wj-helper-box {
    flex: 1;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    border-radius: 8px;
    border-left: 5px solid #8b4513;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.wj-helper-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.wj-helper-box h4 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: #8b4513;
    font-weight: 600;
}

.wj-counter {
    font-size: 2rem;
    font-weight: 700;
    margin: 1rem 0;
    color: #333;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    text-align: center;
    background: rgba(139, 69, 19, 0.05);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(139, 69, 19, 0.1);
}

.wj-counter .wj-current {
    color: #28a745;
}

.wj-counter.wj-over-limit .wj-current {
    color: #dc3545;
}

.wj-counter .wj-separator {
    color: #666;
    margin: 0 0.25rem;
}

.wj-counter .wj-limit {
    color: #666;
}

.wj-warning {
    color: #dc3545;
    font-weight: 500;
    margin: 0.5rem 0;
    font-size: 0.9rem;
    background: rgba(220, 53, 69, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid #dc3545;
    text-align: center;
}

.wj-helper-note {
    font-size: 0.8rem;
    color: #666;
    margin: 0.5rem 0 0 0;
    font-style: italic;
    background: rgba(139, 69, 19, 0.03);
    padding: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid rgba(139, 69, 19, 0.2);
}

/* Modal Styles */
.wj-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wj-modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.wj-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #ddd;
}

.wj-modal-header h3 {
    margin: 0;
    color: #8b4513;
}

.wj-modal-close-top {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.wj-modal-close:hover {
    background-color: #f0f0f0;
}

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

.wj-modal-body label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.wj-modal-body input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.wj-form-actions {
    display: flex;
    gap: 1em;
    justify-content: center;
    margin-top: 1.5rem;
}

/* ACF Form Overrides */
.wj-journal-form .acf-form {
    background: none;
    border: none;
    padding: 0;
}

.wj-journal-form .acf-form .acf-form-submit {
    border-top: 1px solid #ddd;
    margin-top: 2rem;
    padding-top: 1.5rem;
}

.wj-journal-form .acf-repeater {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.wj-journal-form .acf-repeater .acf-row {
    border-bottom: 1px solid #eee;
}

.wj-journal-form .acf-repeater .acf-row:last-child {
    border-bottom: none;
}

/* ACF Tabs Styling */
.wj-journal-form .acf-tab-wrap {
    background: none;
    border-radius: 0px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group {
    background: none;
    border-bottom: 0px solid #ddd;
    border-radius: 0px 0px 0 0;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

.wj-journal-form .acf-tab-wrap .acf-tab-group::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li {
    margin: 0;
    border-right: 1px solid #ddd;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li:last-child {
    border-right: none;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li a {
    background: transparent;
    color: inherit;
    font-weight: 500;
    padding: 5px 10px;
    border: none;
    border-radius: 0;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li.active a,
.wj-journal-form .acf-tab-wrap .acf-tab-group li a:hover {
    background: none !important;
    color: black !important;
    border-color: transparent !important;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li.active {
    background: none !important;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li.active a {
    background: #c85c34 !important;
    color: white !important;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li:first-child a {
    border-radius: 0px 0 0 0;
}

.wj-journal-form .acf-tab-wrap .acf-tab-group li:last-child a {
    border-radius: 0 0px 0 0;
}

.wj-journal-form .acf-tab-wrap .acf-fields {
    padding: 2rem;
}

/* Repeater field improvements */
.wj-journal-form .acf-repeater .acf-table {
    background: white;
}

/* Ensure ACF Select2 dropdowns appear above other UI */
.acf-field .select2-container {
    z-index: 100000; /* higher than theme headers/blocks */
}
.select2-container .select2-dropdown {
    z-index: 100001;
}

.wj-journal-form .acf-repeater .acf-table thead th {
    background: white;
    color: black;
    font-weight: 500;
    padding: 0.75rem 0.5rem;
}

.wj-journal-form .acf-repeater .acf-table tbody td {
    padding: 0.5rem;
    vertical-align: top;
}

.wj-journal-form .acf-repeater .acf-actions {
    background: white;
    border-top: 0px solid #ddd;
    padding: 1rem;
}

.wj-journal-form .acf-repeater .acf-button {
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-weight: 500;
    background-color: #e3e3e3;
    color: #999;
}

.wj-journal-form .acf-repeater .acf-button:hover {
    background: black;
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wj-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .wj-journals-grid {
        grid-template-columns: 1fr;
    }

    .wj-journal-actions {
        flex-direction: column;
        width: 100%;
    }

    .wj-journal-actions .wj-btn {
        width: 100%;
        text-align: center;
    }

    .wj-rewards-table {
        font-size: 0.75rem;
    }

    .wj-form-actions {
        flex-direction: column;
    }

    .wj-form-actions .wj-btn {
        width: 100%;
    }

    /* Journal card responsive */
    .wj-detail-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .wj-detail {
        min-width: auto;
    }

    .wj-detail-row.wj-stats {
        flex-direction: row;
        justify-content: space-between;
    }
}

/* Loading and Success States */
.wj-loading {
    opacity: 0.6;
    pointer-events: none;
}

.wj-success {
    border-left-color: #28a745 !important;
}

.wj-error {
    border-left-color: #dc3545 !important;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wj-journal-card {
    animation: fadeIn 0.3s ease;
}

/* Print Styles */
@media print {
    .wj-btn,
    .wj-journal-actions,
    .wj-modal {
        display: none !important;
    }

    .wj-journal-content {
        grid-template-columns: 1fr;
    }

    .wj-journal-sidebar {
        break-inside: avoid;
    }
}
