/**
 * سبک های پوسته - حالت تیره و روشن
 *
 * @since 1.0.0
 */

.tbp-theme-transition {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* انیمیشن ها */
@keyframes tbp-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tbp-slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes tbp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.tbp-fade-in { animation: tbp-fade-in 0.4s ease; }
.tbp-slide-in { animation: tbp-slide-in 0.4s ease; }

.tbp-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--tbp-neutral-200);
    border-top-color: var(--tbp-primary);
    border-radius: 50%;
    animation: tbp-spin 0.8s linear infinite;
}

.tbp-loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

body.tbp-dark-mode .tbp-loading-overlay {
    background: rgba(15, 23, 42, 0.7);
}

/* اعلان ها */
.tbp-notice {
    padding: 12px 20px;
    border-radius: 8px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: tbp-fade-in 0.3s ease;
}

.tbp-notice-success { background: var(--tbp-success-light); color: var(--tbp-success); border: 1px solid var(--tbp-success); }
.tbp-notice-error { background: var(--tbp-error-light); color: var(--tbp-error); border: 1px solid var(--tbp-error); }
.tbp-notice-warning { background: var(--tbp-warning-light); color: var(--tbp-warning); border: 1px solid var(--tbp-warning); }
.tbp-notice-info { background: var(--tbp-primary-light); color: var(--tbp-primary); border: 1px solid var(--tbp-primary); }

/* دکمه ها */
.button-primary {
    background: var(--tbp-primary) !important;
    border-color: var(--tbp-primary) !important;
    color: #fff !important;
    border-radius: 8px !important;
    padding: 8px 20px !important;
    font-weight: 600 !important;
    transition: var(--tbp-transition) !important;
}

.button-primary:hover {
    background: var(--tbp-primary-dark) !important;
    border-color: var(--tbp-primary-dark) !important;
    transform: translateY(-1px);
    box-shadow: var(--tbp-shadow) !important;
}

.button {
    border-radius: 8px !important;
    transition: var(--tbp-transition) !important;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: var(--tbp-shadow-sm) !important;
}

/* مدال */
.tbp-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    animation: tbp-fade-in 0.2s ease;
}

.tbp-modal {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: tbp-slide-in 0.3s ease;
}

body.tbp-dark-mode .tbp-modal {
    background: var(--tbp-neutral-800);
    color: var(--tbp-neutral-200);
}

.tbp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--tbp-neutral-100);
}

.tbp-modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.tbp-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--tbp-neutral-500);
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--tbp-transition);
}

.tbp-modal-close:hover {
    background: var(--tbp-error-light);
    color: var(--tbp-error);
}

/* تب ها */
.tbp-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--tbp-neutral-200);
    margin-bottom: 24px;
}

.tbp-tab {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--tbp-neutral-500);
    border-bottom: 3px solid transparent;
    transition: var(--tbp-transition);
    margin-bottom: -2px;
}

.tbp-tab:hover {
    color: var(--tbp-primary);
}

.tbp-tab.active {
    color: var(--tbp-primary);
    border-bottom-color: var(--tbp-primary);
    font-weight: 600;
}

.tbp-tab-content {
    display: none;
    animation: tbp-fade-in 0.3s ease;
}

.tbp-tab-content.active {
    display: block;
}

/* آیکون ها */
.tbp-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: var(--tbp-neutral-50);
    border-radius: 8px;
}

.tbp-icon-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--tbp-transition);
    border: 2px solid transparent;
    font-size: 24px;
}

.tbp-icon-item:hover {
    background: var(--tbp-primary-light);
    border-color: var(--tbp-primary);
}

.tbp-icon-item.selected {
    background: var(--tbp-primary-light);
    border-color: var(--tbp-primary);
}

/* گالری */
.tbp-gallery-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0;
    min-height: 60px;
    padding: 8px;
    background: var(--tbp-neutral-50);
    border-radius: 8px;
    border: 1px dashed var(--tbp-neutral-300);
}

.tbp-gallery-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
}

/* آپلود آیکون */
.tbp-icon-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tbp-icon-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    padding: 4px;
    background: var(--tbp-neutral-50);
    border: 1px solid var(--tbp-neutral-200);
    border-radius: 6px;
}

.tbp-icon-preview .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: var(--tbp-primary);
}

.tbp-icon-upload {
    background: var(--tbp-success) !important;
    color: #fff !important;
    border-color: var(--tbp-success) !important;
}

.tbp-icon-upload:hover {
    background: #15803d !important;
    border-color: #15803d !important;
}

/* نمایش فیلدهای سفارشی در صفحات ترم */
.tbp-term-custom-fields {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.tbp-field-display {
    margin-bottom: 16px;
}

.tbp-field-display:last-child {
    margin-bottom: 0;
}

.tbp-field-image img,
.tbp-term-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.tbp-field-gallery .tbp-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.tbp-field-gallery .tbp-gallery-item img {
    width: 100%;
    border-radius: 8px;
    aspect-ratio: 1;
    object-fit: cover;
}

.tbp-field-content-value {
    line-height: 1.7;
    color: #475569;
}

.tbp-field-label {
    font-weight: 600;
    color: #334155;
}

.tbp-field-value {
    color: #64748b;
}

.tbp-field-url .tbp-field-link {
    display: inline-block;
    padding: 6px 16px;
    background: var(--tbp-primary, #2563eb);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.3s;
}

.tbp-field-url .tbp-field-link:hover {
    background: var(--tbp-primary-dark, #1d4ed8);
}

.tbp-color-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
}

/* محتوای SEO در صفحات آرشیو */
.tbp-archive-seo-content {
    margin-top: 40px;
    padding: 24px 0;
    border-top: 1px solid #e2e8f0;
}

.tbp-archive-seo-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #1e293b;
}

.tbp-archive-seo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.tbp-archive-seo-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.tbp-archive-seo-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.tbp-archive-seo-thumb {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #f1f5f9;
}

.tbp-archive-seo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tbp-archive-seo-item h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 12px 16px 8px;
    line-height: 1.4;
}

.tbp-archive-seo-item h3 a {
    color: #1e293b;
    text-decoration: none;
}

.tbp-archive-seo-item h3 a:hover {
    color: var(--tbp-primary);
}

.tbp-archive-seo-excerpt {
    font-size: 13px;
    color: #64748b;
    line-height: 1.6;
    padding: 0 16px 16px;
    margin: 0;
}

@media (max-width: 768px) {
    .tbp-archive-seo-grid {
        grid-template-columns: 1fr;
    }
}

/* رسپانسیو */
@media (max-width: 768px) {
    .tbp-modal { padding: 20px; }
    .tbp-tabs { overflow-x: auto; }
    .tbp-tab { white-space: nowrap; padding: 10px 16px; }
}

/* Term Featured Image */
.tbp-term-featured-image { margin-bottom: 16px; }
.tbp-term-featured-image img { max-width: 100%; height: auto; border-radius: 12px; }

/* Term header media max-width (set via inline style from settings) */
.tbp-term-header-media img { max-width: 100%; height: auto; }

/* Term card image max-width (set via inline style from settings) */
.tbp-term-card .tbp-term-image img { max-width: 100%; height: auto; }

/* Term header archive layout (image + text position) */
.tbp-term-header {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin: 24px 0;
}

.tbp-term-header-media {
    flex: 0 0 auto;
    max-width: 100%;
}

.tbp-term-header-content {
    flex: 1 1 auto;
    min-width: 0;
}

/* Image on top (default) */
.tbp-layout-top { flex-direction: column; }
.tbp-layout-top .tbp-term-header-media { order: 1; }
.tbp-layout-top .tbp-term-header-content { order: 2; }

/* Image on bottom */
.tbp-layout-bottom { flex-direction: column; }
.tbp-layout-bottom .tbp-term-header-media { order: 2; }
.tbp-layout-bottom .tbp-term-header-content { order: 1; }

/* Image on the right side (RTL: first flex item = rightmost) */
.tbp-layout-right { flex-direction: row; }
.tbp-layout-right .tbp-term-header-media { order: 1; }
.tbp-layout-right .tbp-term-header-content { order: 2; }

/* Image on the left side */
.tbp-layout-left { flex-direction: row; }
.tbp-layout-left .tbp-term-header-media { order: 2; }
.tbp-layout-left .tbp-term-header-content { order: 1; }

/* Text alignment */
.tbp-text-align-right .tbp-term-header-content,
.tbp-text-align-right .tbp-term-header-content .tbp-field-content-value,
.tbp-text-align-right .tbp-term-header-content .tbp-field-display { text-align: right; }

.tbp-text-align-left .tbp-term-header-content,
.tbp-text-align-left .tbp-term-header-content .tbp-field-content-value,
.tbp-text-align-left .tbp-term-header-content .tbp-field-display { text-align: left; }

.tbp-text-align-center .tbp-term-header-content,
.tbp-text-align-center .tbp-term-header-content .tbp-field-content-value,
.tbp-text-align-center .tbp-term-header-content .tbp-field-display { text-align: center; }

.tbp-text-align-justify .tbp-term-header-content,
.tbp-text-align-justify .tbp-term-header-content .tbp-field-content-value,
.tbp-text-align-justify .tbp-term-header-content .tbp-field-display { text-align: justify; }

@media (max-width: 768px) {
    .tbp-layout-right,
    .tbp-layout-left {
        flex-direction: column;
    }
    .tbp-layout-right .tbp-term-header-media,
    .tbp-layout-right .tbp-term-header-content,
    .tbp-layout-left .tbp-term-header-media,
    .tbp-layout-left .tbp-term-header-content {
        order: 0;
    }
}

