:root {
    --primary: #4338ca;
    --primary-light: #6366f1;
    --secondary: #0ea5e9;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --radius: 12px;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', sans-serif;
    outline: none;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}
#home_page{
    width: 100%;
    background-color: var(--bg-body);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Mobile Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0;
    transition: var(--transition);
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-card);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 25px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 700;
}

.sidebar-header i {
    font-size: 1.5rem;
}

.sidebar-menu {
    padding: 20px 15px;
    flex: 1;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 18px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    cursor: pointer;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 1.05rem;
}

.menu-item:hover,
.menu-item.active {
    background-color: #e0e7ff;
    color: var(--primary);
    transform: translateX(-5px);
}

.menu-item i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.header {
    background-color: var(--bg-card);
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 5px;
}

.header-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #34d399);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #f87171);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-main);
    box-shadow: none;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f8fafc;
}

.content-body {
    padding: 25px;
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Views */
.view-section {
    display: none;
    animation: slideUp 0.4s ease forwards;
    opacity: 0;
    transform: translateY(15px);
}

.view-section.active {
    display: block;
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid Lists */
.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.api-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid transparent;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.api-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.api-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 5px;
}

.api-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
}

.api-status.success{
    background: #d1fae5;
    color: #065f46;
}

.api-status.error{
    background: #fad1d1;
    color: #5f0606;
}

.api-card-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
}

.api-card-path {
    font-size: 0.95rem;
    color: var(--secondary);
    font-family: monospace;
    background: #f0f9ff;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    display: inline-block;
    word-break: break-all;
}

.api-card-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.api-card-actions .btn {
    flex: 1;
    padding: 10px;
}

/* Forms & Builder */
.builder-container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding-bottom: 50px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.card-header {
    padding: 20px 25px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    color: var(--primary);
    font-size: 1.3rem;
}

.card-body {
    padding: 25px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    font-size: 0.95rem;
    transition: var(--transition);
    color: var(--text-main);
}

.form-control:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    background-size: 1em;
}

/* Dynamic Rows */
.dynamic-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dynamic-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    background: #fafafa;
    padding: 15px;
    border-radius: var(--radius-lg);
    border: 1px dashed #cbd5e1;
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.dynamic-row .form-group {
    flex: 1;
}

.btn-remove {
    background: #fee2e2;
    color: var(--danger);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    width: 46px;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.05);
}

.query-section {
    margin-top: 25px;
    border-top: 2px dashed var(--border-color);
    padding-top: 25px;
}

.queryTable{
    box-shadow: var(--shadow-md);
}

.query-section-title {
    font-size: 1.05rem;
    font-weight: 800;
    margin-bottom: 15px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}


/*LOADING*/
.loading-content {
    direction: unset !important;
    width: 100%;
    height: 100%;
    background: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 1000000;
}

.loading-container {
    width: 3.25em;
    transform-origin: center;
    animation: loading-rotate4 2s linear infinite;
}

.loading-loader {
    fill: none;
    stroke: var(--primary);
    stroke-width: 10;
    stroke-dasharray: 2, 200;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    animation: loading-dash4 1.5s ease-in-out infinite;
}

@keyframes loading-rotate4 {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes loading-dash4 {
    0% {
        stroke-dasharray: 1, 200;
        stroke-dashoffset: 0;
    }

    50% {
        stroke-dasharray: 90, 200;
        stroke-dashoffset: -35px;
    }

    100% {
        stroke-dashoffset: -125px;
    }
}


/* لودینگ مخصوص المان خارجی */
.element-loading {
    position: relative;
    pointer-events: none;
    overflow: hidden;
}

.element-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    /* پس‌زمینه مشابه المان اصلی */
    backdrop-filter: blur(2px);
    /* افکت تاری اختیاری */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* اسپینر با ::before یا content */
.element-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-right-color: var(--primary);
    border-bottom-color: var(--primary);
    border-radius: 50%;
    animation: spinss 0.5s linear infinite;
    z-index: 11;
}

@keyframes spinss {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}



#login_page {
    width: 100%;
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--card);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.login-logo {
    width: 56px;
    height: 56px;
    margin: auto;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    margin-bottom: 18px;
}
.login-h1 {
    font-size: 1.4rem;
    text-align: center;
    margin-bottom: 6px;
}
.login-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 26px;
}
.login-form-group {
    margin-bottom: 16px;
}
.login-label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--muted);
}
.login-card input {
    width: 100%;
    height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #f8fafc;
    font-size: 0.9rem;
}
.login-card input:focus {
    border-color: var(--primary);
    outline: none;
    background: #fff;
}
.login-card button {
    width: 100%;
    height: 46px;
    margin-top: 6px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}
.login-card button:hover {
    opacity: 0.95;
}
.login-card .error {
    display: none;
    background: #fee2e2;
    color: #991b1b;
    padding: 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 12px;
    text-align: center;
}
.login-card .footer {
    margin-top: 18px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
}


/* Notification Toast */
.toast-container {
    direction: rtl;
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-right: 4px solid var(--primary);
    border-radius: 16px;
    padding: 1.25rem;
    min-width: 300px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideInLeft1 0.4s ease;
}

@keyframes slideInLeft1 {
    from {
        transform: translateX(+100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    width: 48px;
    height: 48px;
    background: rgba(220, 38, 38, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.5rem;
}

.toast-content h4 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.toast-content p {
    font-size: 0.9rem;
    opacity: 0.9;
    color: var(--text-secondary);
}



/* Responsive Design */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        right: -280px;
        top: 0;
        bottom: 0;
        height: 100vh;
    }

    .sidebar.show {
        transform: translateX(-280px);
    }

    .menu-toggle {
        display: block;
    }
}

@media (max-width: 768px) {
    .content-body {
        padding: 15px;
    }

    .api-grid {
        grid-template-columns: 1fr;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-header .btn {
        width: 100%;
    }

    .dynamic-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px 15px;
    }

    .btn-remove {
        width: 100%;
        margin-top: 5px;
    }

    .query-section-title {
        flex-direction: column;
        align-items: stretch;
    }
}