@font-face {
    font-family: "Vazirmatn";
    src: url("../assets/fonts/Vazirmatn-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #16a34a;
    --danger: #ef4444;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
    font-size: 16px;
}

.hidden { display: none !important; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: 0.2s ease;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #ffffff; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: #ffffff; }
.btn-danger:hover { background: #dc2626; }

.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-outline { background: #ffffff; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { background: #f1f5f9; }

.btn-sm { padding: 8px 16px; font-size: 0.88rem; }
.btn-block { width: 100%; }

.active-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
    user-select: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--danger);
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

input:checked + .slider {
    background-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.login-screen {
    position: fixed;
    inset: 0;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.login-card {
    background: #ffffff;
    width: 100%;
    max-width: 420px;
    padding: 40px 32px 28px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 12px;
}

.login-header h2 {
    font-size: 1.4rem;
    margin-bottom: 6px;
}

.login-header p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 26px;
}

.login-form .form-group {
    text-align: right;
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

.login-footer {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.dev-name {
    color: var(--primary);
    font-weight: 700;
}

.error-msg {
    color: var(--danger);
    font-size: 0.9rem;
    font-weight: 700;
    margin-top: 14px;
    min-height: 22px;
}

.dashboard-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.mobile-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-menu {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 1.3rem;
    cursor: pointer;
}

.mobile-brand {
    font-size: 1.05rem;
    font-weight: 800;
}

.menu-toggle {
    background: none;
    width: 42px;
    height: 42px;
    position: relative;
    cursor: pointer;
    border: none;
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
}
.menu-toggle img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}
.menu-toggle .menu-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
}
.menu-toggle .close-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-360deg);
}
.menu-toggle.active .menu-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(360deg);
}
.menu-toggle.active .close-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg);
}

.sidebar {
    display: flex;
    flex-direction: column;
    z-index: 200;
    background: var(--bg-sidebar);
    color: #ffffff;
    overflow-y: auto;
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}
.sidebar::-webkit-scrollbar {
    display: none; 
}

@media (max-width: 767px) {
    
    .sidebar {
        position: fixed;
        top: 88px;
        right: 16px;
        left: 16px;
        bottom: auto;
        width: auto;
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        background-color: rgba(255, 255, 255, 0.98);
        border: 1px solid var(--border);
        border-radius: 20px;
        box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
        color: var(--text-main);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-16px) scale(0.96);
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease;
        
        max-height: calc(100dvh - 104px);
        overflow-y: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .sidebar::-webkit-scrollbar {
        display: none;
    }
    .sidebar.open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
    }
    .sidebar-header {
        display: none !important;
    }
    .sidebar-nav {
        padding: 20px;
        gap: 10px;
    }
    .sidebar-nav .nav-item {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 12px 16px;
        border-radius: 12px;
        font-weight: 700;
        font-size: 15px;
        color: #334155;
        background-color: #f8fafc;
        transition: all 0.2s ease;
        border: none;
    }
    .sidebar-nav .nav-item.active {
        background-color: #eff6ff;
        color: var(--primary);
    }
    .sidebar-footer {
        padding: 0 20px 20px 20px;
        border-top: none;
    }
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo-box {
    font-size: 1.8rem;
}

.sidebar-brand h3 {
    font-size: 1.1rem;
    font-weight: 800;
}

.sidebar-brand span {
    font-size: 0.8rem;
    color: #94a3b8;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.4rem;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    transition: 0.2s ease;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .btn-outline {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.4);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-header {
    display: none;
}

.content-body {
    padding: 20px;
    flex: 1;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.tab-section {
    display: none;
}

.tab-section.active {
    display: block;
}

.panel-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 28px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafafa;
}

.panel-card-header h3 {
    font-size: 1.2rem;
    font-weight: 800;
}

.panel-card-body {
    padding: 28px 24px;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.form-group label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: #ffffff;
    transition: 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

textarea.form-control {
    line-height: 1.6;
    resize: vertical;
}

.image-uploader-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    background: #f8fafc;
}

.image-preview {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    background: #e2e8f0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    flex-shrink: 0;
    font-size: 2.2rem;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.uploader-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    width: 100%;
    text-align: center;
}

.file-input-hidden {
    display: none;
}

.items-list-container, .items-grid-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 24px;
}

.item-card {
    background: #f8fafc;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    transition: 0.2s ease;
}

.item-card:hover {
    border-color: #94a3b8;
    background: #ffffff;
}

.item-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid #e2e8f0;
}

.item-card-header h4 {
    font-size: 1.05rem;
    font-weight: 800;
}

.item-card-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toast-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: #0f172a;
    color: #ffffff;
    padding: 14px 22px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: toastSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toastSlideUp {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast-success { background: #166534; }
.toast-error { background: #991b1b; }

@media (min-width: 768px) {
    .dashboard-app {
        flex-direction: row;
    }

    .mobile-nav-bar {
        display: none;
    }

    .sidebar {
        position: sticky;
        top: 0;
        right: 0;
        height: 100vh;
        width: 280px;
        flex-shrink: 0;
    }

    .sidebar-close-btn {
        display: none;
    }

    .top-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20px 36px;
        background: #ffffff;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .top-header h2 {
        font-size: 1.3rem;
        font-weight: 800;
    }

    .header-right {
        display: flex;
        align-items: center;
        gap: 14px;
    }

    .content-body {
        padding: 36px;
    }

    .toast-container {
        right: auto;
        max-width: 420px;
    }

    .image-uploader-wrapper {
        align-items: center;
    }

    .image-preview {
        width: 100%;
        height: 100%;
    }

    .uploader-inputs {
        text-align: right;
    }
}

.terminal-box {
    background-color: #0f172a;
    color: #4ade80;
    font-family: Consolas, monospace;
    font-size: 13px;
    padding: 16px;
    border-radius: var(--radius-sm);
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    direction: ltr;
    text-align: left;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
    border: 1px solid #334155;
}

.dynamic-list {
    counter-reset: dynamic-item;
}
.dynamic-item .item-card-header h4::after {
    counter-increment: dynamic-item;
    content: " " counter(dynamic-item);
}
