/**
 * پنل کاربری پیشرفته - استایل‌های فرانت
 */

 :root {
    --aup-primary: #395EA2;
    --aup-secondary: #BCAE7F;
    --aup-text: #333;
    --aup-bg: #f4f6f9;
    --aup-sidebar-width: 280px;
}

.aup-container {
    max-width: 98%;
    margin: 40px auto;
    padding: 0 20px;
    direction: rtl;
    font-family: inherit;
    box-sizing: border-box;
    background: var(--aup-panel-page-bg, transparent);
}
.aup-container * { box-sizing: border-box; }
.aup-wrapper { display: flex; gap: 30px; align-items: flex-start; }

/* --- SIDEBAR (DESKTOP) --- */
.aup-sidebar {
    flex: 0 0 var(--aup-sidebar-width);
    background: var(--aup-panel-sidebar-bg, #fff);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 550px;
    position: sticky;
    top: 20px;
}

.aup-user-info {
    background: var(--aup-panel-user-info-bg, linear-gradient(135deg, var(--aup-primary) 0%, #243b66 100%));
    padding: 40px 20px;
    text-align: center;
    color: var(--aup-panel-user-info-text, #fff);
    position: relative;
}

/* Bell icon + dropdown */
.aup-announcements-bell-wrap {
    position: absolute;
    top: 15px;
    inset-inline-end: 15px;
}
.aup-announcements-bell {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background 0.2s;
}
.aup-announcements-bell:hover { background: rgba(255,255,255,0.35); }
.aup-nav-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-inline-start: 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    background: #e74c3c;
    color: #fff;
    border-radius: 9px;
}
.aup-announcements-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    background: #e74c3c;
    color: #fff;
    border-radius: 9px;
}
/* Full-page announcements modal */
.aup-announcements-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.aup-announcements-overlay.is-open {
    display: flex;
    opacity: 1;
    visibility: visible;
}
.aup-announcements-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}
.aup-announcements-modal-box {
    position: relative;
    width: 100%;
    max-width: 540px;
    max-height: 85vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.aup-announcements-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.aup-announcements-modal-head h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}
.aup-announcements-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    transition: background 0.2s, color 0.2s;
}
.aup-announcements-close:hover {
    background: #e0e0e0;
    color: #333;
}
.aup-announcements-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.aup-user-avatar {
    width: 90px; height: 90px; margin: 0 auto 15px;
    border-radius: 50%; border: 4px solid rgba(255,255,255,0.2);
    overflow: hidden;
}
.aup-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.aup-user-name { font-size: 18px; font-weight: bold; margin-bottom: 5px; }
.aup-user-email { font-size: 13px; opacity: 0.8; }
.aup-user-info-actions { display: none; }
.aup-mobile-overlay { display: none !important; }
.aup-mobile-only { display: none !important; }

/* Navigation List */
.aup-nav { list-style: none; margin: 0; padding: 15px 0; flex-grow: 1; }
.aup-nav li { margin: 0; }
.aup-nav a {
    display: flex; align-items: center;
    padding: 14px 25px;
    text-decoration: none; color: var(--aup-panel-nav-text, #666);
    transition: all 0.2s; font-size: 15px;
    border-right: 4px solid transparent;
}
.aup-nav a:hover { background: #f9f9f9; color: var(--aup-primary); }
.aup-nav a.active {
    background: var(--aup-panel-nav-active-bg, #f0f4ff); color: var(--aup-panel-nav-active-text, var(--aup-primary)); font-weight: 600;
    border-right-color: var(--aup-panel-nav-active-text, var(--aup-primary));
}
.aup-nav-icon { width: 25px; margin-left: 10px; font-size: 18px; text-align: center; }
[data-royal-icon]::before { content: attr(data-royal-icon); }
.aup-nav-icon img.emoji { display: none !important; }

.aup-nav-levels { position: relative; min-height: 200px; }
.aup-nav-level { display: none; }
.aup-nav-level[data-level="0"] { display: block; }
.aup-nav-back { margin: 0; border-bottom: 1px solid #eee; }
.aup-nav-back a, .aup-nav-back .aup-nav-back-link {
    display: flex; align-items: center; padding: 14px 25px;
    color: var(--aup-primary); font-weight: 600; text-decoration: none;
}
.aup-nav-back a:hover { background: #f0f4ff; }

/* Logout Button (Desktop) */
.aup-sidebar-footer { padding: 20px; border-top: 1px solid #eee; margin-top: auto; }
.aup-logout-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 12px;
    background: #fff5f5; color: #dc3545 !important;
    border-radius: 10px; font-weight: 600;
    text-decoration: none; transition: all 0.2s;
    border: 1px solid #ffebeb;
}
.aup-logout-btn:hover { background: #dc3545; color: #fff !important; border-color: #dc3545; }

/* --- CONTENT AREA --- */
.aup-content {
    flex: 1; min-width: 0;
    background: var(--aup-panel-content-bg, #fff); border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.04);
    padding: 40px;
    color: var(--aup-panel-content-text, #333);
}

.aup-tab-content { display: none; animation: fadeIn 0.3s ease-in-out; }
.aup-tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.aup-tab-title {
    font-size: 24px; color: var(--aup-panel-content-text, #333); margin: 0 0 30px;
    padding-bottom: 20px; border-bottom: 1px solid #eee;
    display: flex; align-items: center;
}

/* --- MOBILE & RESPONSIVE --- */
@media (max-width: 900px) {
    .aup-container {
        margin: 20px auto;
        padding: 0 15px;
        max-width: 100%;
        overflow-x: hidden;
    }
    .aup-wrapper {
        flex-direction: column;
        gap: 20px;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
    }

    .aup-sidebar {
        width: 100%;
        max-width: 100%;
        min-height: auto;
        flex: none;
        position: static;
        display: block;
        overflow: visible;
        padding-top: 92px;
    }
    .aup-user-info {
        display: flex;
        align-items: center;
        text-align: right;
        padding: 15px 20px;
        gap: 15px;
        border-radius: 0 0 15px 15px;
        position: fixed;
        top: 0;
        left: 15px;
        right: 15px;
        z-index: 100;
        max-width: calc(100% - 30px);
        margin: 0 auto;
    }
    .aup-mobile-only {
        display: flex !important;
        flex-shrink: 0;
    }
    .aup-user-info-middle {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 15px;
        min-width: 0;
    }
    .aup-icon-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255,255,255,0.2);
        border: none;
        border-radius: 10px;
        color: #fff;
        font-size: 20px;
        text-decoration: none;
        cursor: pointer;
        transition: background 0.2s;
        flex-shrink: 0;
    }
    .aup-icon-btn:hover {
        background: rgba(255,255,255,0.35);
        color: #fff;
    }
    .aup-hamburger { font-size: 24px; }
    .aup-user-avatar { width: 60px; height: 60px; margin: 0; flex-shrink: 0; border-width: 2px; }
    .aup-user-details { flex-grow: 1; min-width: 0; }
    .aup-user-name { font-size: 16px; margin-bottom: 2px; }
    .aup-user-email { font-size: 12px; opacity: 0.9; }

    .aup-sidebar .aup-nav-levels,
    .aup-sidebar .aup-nav,
    .aup-sidebar .aup-sidebar-footer {
        display: none !important;
    }
    .aup-logout-btn {
        background: #fff;
        border: 1px solid #eee;
        color: #dc3545 !important;
        padding: 8px;
        font-size: 13px;
    }

    .aup-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 5px 10px;
        margin: 0;
        background: #fff;
        border-top: 1px solid #f0f0f0;
        scrollbar-width: thin;
    }
    .aup-nav::-webkit-scrollbar { height: 4px; }
    .aup-nav::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

    .aup-nav li { flex: 0 0 auto; margin: 0 5px; }

    .aup-nav a {
        flex-direction: column;
        justify-content: center;
        text-align: center;
        padding: 10px 15px;
        font-size: 11px;
        border-right: none;
        border-bottom: 3px solid transparent;
        color: #777;
        border-radius: 0;
        gap: 5px;
        background: transparent;
    }
    .aup-nav a:hover { background: #f8f8f8; color: var(--aup-primary); }
    .aup-nav a.active {
        background: transparent;
        color: var(--aup-primary);
        border-bottom-color: var(--aup-primary);
        font-weight: 700;
    }
    .aup-nav-icon { margin: 0; font-size: 20px; width: auto; }

    .aup-content {
        width: 100%;
        max-width: 100%;
        padding: 25px 20px;
        min-width: 0;
    }

    .aup-tab-title { font-size: 20px; margin-bottom: 20px; padding-bottom: 15px; }

    .aup-dashboard-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
        padding: 20px 16px;
        margin-bottom: 20px;
    }
    .aup-stat-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        min-width: 0;
        overflow: hidden;
    }
    .aup-stat-card {
        padding: 16px;
        min-width: 0;
        overflow: hidden;
    }
    .aup-stat-card .aup-stat-info {
        min-width: 0;
        overflow: hidden;
    }
    .aup-stat-card .aup-stat-info h4 {
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-word;
    }
    .aup-stat-info h4 { font-size: 24px; }
    .aup-stat-info span { font-size: 12px; }
    .aup-stat-icon { font-size: 24px; }

    .aup-dashboard-footer { padding: 16px; margin-top: 16px; }

    .aup-orders-table thead { display: none; }
    .aup-orders-table, .aup-orders-table tbody, .aup-orders-table tr, .aup-orders-table td { display: block; width: 100%; }
    .aup-orders-table tr {
        margin-bottom: 15px; border: 1px solid #eee;
        border-radius: 10px; padding: 15px; background: #fff;
    }
    .aup-orders-table td {
        text-align: left; padding: 10px 0;
        border: none; border-bottom: 1px solid #f5f5f5;
        display: flex; justify-content: space-between; align-items: center;
    }
    .aup-orders-table td:last-child { border-bottom: none; }
    .aup-orders-table td::before {
        content: attr(data-label);
        font-weight: bold; color: #555; font-size: 13px;
    }

    .aup-form-row { flex-direction: column; gap: 15px; }
    .aup-dashboard-header { flex-direction: column; text-align: center; gap: 20px; }
    .aup-stat-grid { grid-template-columns: 1fr; }
    .aup-mobile-overlay {
        display: flex !important;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99998;
        flex-direction: column;
        padding: 20px;
        padding-top: 60px;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
        direction: rtl;
    }
    .aup-mobile-overlay.is-open {
        opacity: 1;
        visibility: visible;
    }
    .aup-mobile-close {
        position: absolute;
        top: 15px;
        inset-inline-end: 15px;
        width: 44px;
        height: 44px;
        border: none;
        background: rgba(255,255,255,0.2);
        color: #fff;
        font-size: 28px;
        line-height: 1;
        cursor: pointer;
        border-radius: 10px;
    }
    .aup-mobile-overlay .aup-nav-mobile {
        list-style: none;
        margin: 0;
        padding: 0;
        background: #fff;
        border-radius: 15px;
        overflow: hidden;
        flex: 1;
        overflow-y: auto;
        display: block;
    }
    .aup-mobile-overlay .aup-nav-mobile li { margin: 0; }
    .aup-mobile-overlay .aup-nav-mobile a {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        padding: 16px 20px;
        text-decoration: none;
        color: #333;
        border-bottom: 1px solid #eee;
        font-size: 16px;
        text-align: right;
    }
    .aup-mobile-overlay .aup-nav-mobile a:hover,
    .aup-mobile-overlay .aup-nav-mobile a.active {
        background: #f0f4ff;
        color: var(--aup-primary);
    }
    .aup-mobile-overlay .aup-nav-icon { width: 28px; margin-left: 12px; margin-right: 0; font-size: 20px; text-align: center; flex-shrink: 0; }
    .aup-mobile-overlay-footer {
        padding: 15px 0 0;
    }
    .aup-mobile-overlay-footer .aup-logout-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        padding: 14px;
        background: #fff5f5;
        color: #dc3545 !important;
        border-radius: 10px;
        font-weight: 600;
        text-decoration: none;
        border: 1px solid #ffebeb;
    }
}

@media (max-width: 600px) {
    .aup-stat-grid { grid-template-columns: 1fr; }
}

/* Common Elements */
.aup-dashboard-header { background: var(--aup-panel-header-bg, #f8faff); padding: 30px; border-radius: 12px; margin-bottom: 30px; border: 1px solid #eef2f9; display: flex; justify-content: space-between; align-items: center; color: var(--aup-panel-header-text, inherit); }
.aup-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.aup-stat-card { background: var(--aup-panel-widget-bg, #fff); border: 1px solid #eee; padding: 25px; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; color: var(--aup-panel-widget-text, inherit); }
.aup-stat-info h4 { margin: 0; font-size: 30px; color: var(--aup-panel-widget-text, #333); }
.aup-stat-info span { color: var(--aup-panel-widget-text, #888); font-size: 13px; opacity: 0.8; }
.aup-stat-icon { font-size: 30px; opacity: 0.8; }

/* Form & Messages */
.aup-form-group label { display: block; margin-bottom: 8px; font-weight: bold; font-size: 13px; }
.aup-form-control { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
.aup-btn-save { background: var(--aup-primary); color: #fff; border: none; padding: 12px 30px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.aup-message { padding: 15px; border-radius: 8px; margin-bottom: 20px; }
.aup-message.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.aup-message.error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

.aup-dashboard-footer {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 4px;
    background: var(--aup-panel-footer-bg, #fff);
    color: var(--aup-panel-footer-text, inherit);
}
.aup-dashboard-footer-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.aup-dashboard-footer-body { margin-top: 8px; }

/* Announcements (in modal) */
.aup-announcements-modal-body .aup-announcement {
    margin-bottom: 10px;
    padding: 12px 40px 12px 12px;
}
.aup-announcements-modal-body .aup-announcement:last-child { margin-bottom: 0; }
.aup-announcements-modal-body .aup-announcement-image img { max-width: 80px; }
.aup-announcements-modal-body .aup-announcement-title { font-size: 15px; }
.aup-announcements-modal-body .aup-announcement-body { font-size: 14px; max-height: 200px; overflow-y: auto; }
.aup-announcement {
    margin-bottom: 20px;
    padding: 20px;
    padding-inline-end: 50px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
    position: relative;
}
.aup-announcement-inner { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.aup-announcement-image { flex-shrink: 0; }
.aup-announcement-image img { max-width: 120px; height: auto; border-radius: 8px; }
.aup-announcement-content { flex: 1; min-width: 0; }
.aup-announcement-title { margin: 0 0 8px; font-size: 1.1em; }
.aup-announcement-body { line-height: 1.6; }
.aup-announcement-body img { max-width: 100%; height: auto; }
.aup-announcement-dismiss {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: rgba(0,0,0,0.1);
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}
.aup-announcement-dismiss:hover { background: rgba(0,0,0,0.2); }
.aup-announcement-info { background: #e3f2fd; color: #1565c0; }
.aup-announcement-success { background: #e8f5e9; color: #2e7d32; }
.aup-announcement-warning { background: #fff8e1; color: #f57c00; }
.aup-announcement-danger { background: #ffebee; color: #c62828; }
@media (max-width: 600px) {
    .aup-announcement { padding: 16px 45px 16px 16px; }
    .aup-announcement-image img { max-width: 80px; }
}
@media (max-width: 900px) {
    .aup-announcements-bell-wrap { position: relative; top: auto; inset-inline-end: auto; }
    .aup-announcements-bell { width: 44px; height: 44px; }
    .aup-announcements-overlay { padding: 15px; }
    .aup-announcements-modal-box { max-height: 90vh; }
}
