* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
    direction: rtl;
    padding: 20px;
    min-height: 100vh;
}

.admin-container {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.08);
    animation: slideInUp 0.5s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====== عنوان و صفحه ====== */
h1 {
    font-size: 28px;
    margin-bottom: 24px;
    color: #1a1a2e;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 10px;
}

h1::before {
    content: "⚙️";
    font-size: 32px;
}

h2 {
    font-size: 20px;
    margin-top: 40px;
    margin-bottom: 20px;
    color: #1a1a2e;
    font-weight: 800;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
}

h3 {
    font-size: 16px;
    margin-top: 16px;
    margin-bottom: 12px;
    color: #333;
    font-weight: 700;
}

/* ====== توپ بار ====== */
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 12px;
}

.back-link, .logout-link {
    font-size: 13px;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: inline-block;
}

.back-link {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.back-link:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateX(-2px);
}

.logout-link {
    color: #fff;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.2);
}

.logout-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(231, 76, 60, 0.3);
}

/* ====== فرم ها ====== */
form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 40px;
    padding: 24px;
    background: linear-gradient(135deg, #f9fafb, #f5f7fa);
    border-radius: 14px;
    border: 1px solid rgba(102, 126, 234, 0.08);
}

label {
    font-size: 13px;
    color: #555;
    margin-top: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="file"],
select,
textarea {
    padding: 12px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    transition: all 0.3s ease;
    color: #333;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
    background: #fff;
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    accent-color: #667eea;
    width: 18px;
    height: 18px;
}

/* ====== دکمه ها ====== */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 16px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(-1px);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.submit-btn {background: linear-gradient(135deg, #667eea, #764ba2);
    margin-top: 24px;
    font-size: 15px;
    padding: 14px 30px;
}

/* ====== دکمه افزودن برند ====== */
#add-variant-btn {
    background: #fff;
    border: 2px dashed #667eea;
    color: #667eea;
    margin-bottom: 20px;
    margin-top: 14px;
    font-weight: 700;
    transition: all 0.3s ease;
}

#add-variant-btn:hover {
    background: rgba(102, 126, 234, 0.05);
    border-color: #764ba2;
    transform: none;
    box-shadow: none;
}

/* ====== ردیف برندها ====== */
.variant-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 12px;
    align-items: flex-end;
}

.variant-row input {
    padding: 10px 12px;
    font-size: 13px;
}

.remove-variant {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    padding: 10px 16px;
    border-radius: 8px;
    white-space: nowrap;
    margin-top: 0;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.2);
}

.remove-variant:hover {
    box-shadow: 0 6px 16px rgba(231, 76, 60, 0.3);
}

/* ====== درخت دسته‌بندی ====== */
.cat-tree {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
    background: #f9fafb;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

.cat-tree::-webkit-scrollbar {
    width: 6px;
}

.cat-tree::-webkit-scrollbar-track {
    background: transparent;
}

.cat-tree::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.cat-tree::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.cat-tree .tree-toggle {
    cursor: pointer;
    padding: 8px 10px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    color: #1a1a2e;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin-bottom: 4px;
}

.cat-tree .tree-toggle:hover {
    background: rgba(102, 126, 234, 0.1);
}

.cat-tree .tree-children {
    display: none;
    padding-right: 14px;
    border-right: 2px solid rgba(102, 126, 234, 0.2);
    margin-right: 8px;
}

.cat-tree .tree-children.open {
    display: block;
}

.cat-tree .tree-toggle .arrow {
    transition: transform 0.2s;
    color: #667eea;
    font-weight: 700;
}

.cat-tree .tree-toggle.open .arrow {
    transform: rotate(180deg);
}

.cat-tree .tree-leaf {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
    margin-bottom: 4px;
    color: #333;
}

.cat-tree .tree-leaf:hover {
    background: rgba(102, 126, 234, 0.1);
}

.cat-tree .tree-leaf input {
    margin-left: 8px;
    accent-color: #667eea;
}

/* ====== جدول ====== */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-top: 20px;
}

th {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    text-align: right;
    padding: 16px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    text-align: right;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #555;
}

tr:hover {
    background: rgba(102, 126, 234, 0.03);
}

tr:last-child td {
    border-bottom: none;
}

table img {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ====== لینک‌های عملیات ====== */
.edit-link, .delete-link {
    font-size: 12px;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    margin-left: 6px;
    display: inline-block;
    transition: all 0.3s ease;
    font-weight: 600;
    cursor: pointer;
}

.edit-link {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.edit-link:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));transform: translateX(-2px);
}

.delete-link {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.2), rgba(192, 57, 43, 0.2));
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.delete-link:hover {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.3), rgba(192, 57, 43, 0.3));
    transform: translateX(-2px);
}

/* ====== پیام‌ها ====== */
.error-msg {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.1), rgba(192, 57, 43, 0.1));
    color: #c0102a;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-right: 4px solid #e74c3c;
    animation: slideInDown 0.4s ease;
}

.success-msg {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.1), rgba(39, 174, 96, 0.1));
    color: #0a7a4d;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 13px;
    border: 1px solid rgba(46, 204, 113, 0.3);
    border-right: 4px solid #27ae60;
    animation: slideInDown 0.4s ease;
}

.flash {
    animation: slideInDown 0.4s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====== صفحه ورود ====== */
.login-box {
    max-width: 420px;
    margin: 60px auto;
    animation: scaleIn 0.5s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.switch-link {
    text-align: center;
    font-size: 13px;
    margin-top: 20px;
    color: #666;
}

.switch-link a {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.3s;
}

.switch-link a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* ====== فرم‌های متخصص ====== */
.status-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.status-form select {
    padding: 10px 12px;
    font-size: 13px;
    flex: 1;
    min-width: 150px;
}

.status-form button {
    margin-top: 0;
    padding: 10px 20px;
    font-size: 12px;
}

.custom-select {
    position: relative;
    width: 100%;
    max-width: 240px;
    font-family: inherit;
}

.custom-select-selected {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    color: #333;
    font-weight: 600;
}

.custom-select-selected:hover {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.custom-select-options {
    display: none;
    position: absolute;
    top: 105%;
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 10;
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

.custom-select.open .custom-select-options {
    display: block;
    animation: slideDown 0.3s ease;
}

.custom-select-option {
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
    font-weight: 500;
}

.custom-select-option:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    color: #667eea;
}

/* ====== موبایل ====== */
@media (max-width: 768px) {
    .admin-container {
        padding: 20px;
    }

    .admin-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .admin-topbar a {
        width: 100%;
        text-align: center;
    }

    form {
        padding: 16px;
    }

    .variant-row {
        grid-template-columns: 1fr;
    }

    .variant-row input {
        width: 100%;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 10px;
    }

    .edit-link, .delete-link {
        display: block;
        margin: 4px 0;
        margin-left: 0;
    }

    h1 {
        font-size: 20px;}

        h2 {
            font-size: 16px;
        }
    }