/**
 * Mobile-First PrestaShop Product Entry Portal
 * Persian/RTL Optimized Stylesheet
 */

/* ===== CSS Variables ===== */
:root {
    --primary: #1a237e;
    --primary-light: #3949ab;
    --primary-dark: #0d1642;
    --secondary: #ff6f00;
    --success: #2e7d32;
    --danger: #c62828;
    --warning: #f57f17;
    --info: #0277bd;
    --light: #f5f5f5;
    --dark: #212121;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --font-family: 'Vazirmatn', 'IRANSansX', 'Tahoma', sans-serif;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow: 0 2px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --transition: all 0.2s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.7;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    direction: rtl;
    text-align: right;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family);
    font-weight: 700;
    color: var(--gray-900);
}

/* ===== Navbar ===== */
.navbar {
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow);
}

.navbar-brand {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.navbar-text {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ===== Login Page ===== */
.login-page {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: var(--white);
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--gray-900);
}

.login-header p {
    font-size: 0.9rem;
}

.login-form {
    margin-top: 1.5rem;
}

.login-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.15rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    margin-top: 0.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}

/* ===== Password Toggle ===== */
.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: 4px;
}

/* ===== Form Controls ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.form-control,
.form-select {
    border-radius: var(--border-radius);
    padding: 0.875rem 1rem;
    font-size: 1.05rem;
    border: 2px solid var(--gray-300);
    transition: var(--transition);
    font-family: var(--font-family);
    min-height: 54px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.15);
}

.form-control-lg {
    font-size: 1.1rem;
    padding: 1rem 1.25rem;
    min-height: 58px;
}

.form-text {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.35rem;
}

/* ===== Section Cards ===== */
.section-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--gray-200);
}

.section-title svg {
    color: var(--primary);
}

/* ===== Image Upload ===== */
.image-upload-area {
    border: 3px dashed var(--gray-300);
    border-radius: var(--border-radius-lg);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--gray-100);
}

.image-upload-area:hover,
.image-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(26, 35, 126, 0.05);
}

.upload-placeholder {
    color: var(--gray-600);
}

.upload-placeholder svg {
    margin-bottom: 0.75rem;
    color: var(--gray-400);
}

.upload-placeholder p {
    margin: 0.25rem 0;
    font-size: 1rem;
}

.upload-placeholder .small {
    font-size: 0.85rem;
}

/* ===== Image Preview ===== */
.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    border: 2px solid var(--gray-200);
    transition: var(--transition);
}

.image-preview-item:active {
    cursor: grabbing;
    box-shadow: var(--shadow-lg);
    transform: scale(1.05);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--danger);
    color: var(--white);
    border: 2px solid var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 2;
    transition: var(--transition);
}

.remove-image:hover {
    transform: scale(1.1);
}

.cover-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: var(--primary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 2;
}

.drag-handle {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.5);
    color: var(--white);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 2;
}

/* ===== Advanced Options ===== */
.advanced-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 0.75rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-family);
    transition: var(--transition);
}

.advanced-toggle:hover {
    color: var(--primary-dark);
}

.advanced-toggle.active svg {
    transform: rotate(180deg);
}

.advanced-toggle svg {
    transition: transform 0.3s ease;
}

.advanced-options {
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
    margin-top: 0.5rem;
}

/* ===== Buttons ===== */
.btn {
    font-family: var(--font-family);
    font-weight: 600;
    border-radius: var(--border-radius);
    padding: 0.75rem 1.5rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    border: none;
    font-size: 1rem;
}

.btn-lg {
    padding: 1rem 1.75rem;
    font-size: 1.1rem;
    min-height: 56px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    box-shadow: 0 6px 16px rgba(26, 35, 126, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    transform: none;
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: var(--white);
}

/* ===== Submit Section ===== */
.submit-section {
    padding: 1rem 0 2rem;
    position: sticky;
    bottom: 0;
    background: var(--gray-100);
    padding-top: 1rem;
}

.submit-btn {
    font-size: 1.2rem;
    padding: 1.1rem;
    min-height: 60px;
    border-radius: var(--border-radius-lg);
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-top: 0.25rem;
}

.stat-today .stat-number { color: var(--info); }
.stat-week .stat-number { color: var(--success); }
.stat-month .stat-number { color: var(--primary); }
.stat-failed .stat-number { color: var(--danger); }

/* ===== Tables ===== */
.table {
    font-size: 0.95rem;
}

.table th {
    font-weight: 600;
    color: var(--gray-700);
    background: var(--gray-100);
    border-bottom: 2px solid var(--gray-300);
    padding: 0.875rem 1rem;
}

.table td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-200);
}

.product-name-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* ===== Badges ===== */
.badge {
    font-weight: 600;
    padding: 0.4em 0.8em;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* ===== Alerts ===== */
.alert {
    border-radius: var(--border-radius);
    border: none;
    padding: 1rem 1.25rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

/* ===== Success Content ===== */
.success-content {
    text-align: center;
    padding: 1.5rem 0;
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.success-content h5 {
    font-size: 1.3rem;
    color: var(--success);
    margin-bottom: 1rem;
}

.success-content p {
    font-size: 1rem;
    margin: 0.5rem 0;
    color: var(--gray-700);
}

.success-content a {
    color: var(--primary);
    font-weight: 600;
}

/* ===== Toast Notifications ===== */
.toast-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: var(--white);
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    font-weight: 500;
    max-width: 90%;
    text-align: center;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success { background: var(--success); }
.toast-danger { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--info); }

/* ===== Spinner ===== */
.spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 576px) {
    html {
        font-size: 15px;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }

    .section-card {
        padding: 1.25rem;
    }

    .stat-number {
        font-size: 1.75rem;
    }

    .image-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    }

    .product-name-cell {
        max-width: 120px;
    }
}

@media (max-width: 380px) {
    html {
        font-size: 14px;
    }

    .image-preview-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== RTL Specific ===== */
[dir="rtl"] .form-control {
    text-align: right;
}

[dir="rtl"] input[type="url"],
[dir="rtl"] input[dir="ltr"] {
    text-align: left !important;
}

/* ===== Print Styles ===== */
@media print {
    .navbar,
    .submit-section,
    .btn {
        display: none !important;
    }
}

/* ===== Focus Visible (Accessibility) ===== */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ===== Selection ===== */
::selection {
    background: rgba(26, 35, 126, 0.2);
    color: var(--gray-900);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}
