/* css/style.css */

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --primary-color: #ed1d24; /* Refaco Red */
    --primary-gradient: linear-gradient(135deg, #ed1d24 0%, #b91c1c 100%);
    --navy-color: #0d2257; /* Refaco Navy */
    --navy-gradient: linear-gradient(135deg, #0d2257 0%, #1e3a8a 100%);
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-main: #0d2257; /* Navy Text */
    --text-muted: #64748b;
    --font-fa: 'Vazirmatn', sans-serif;
    --font-en: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadow-premium: 0 10px 30px rgba(13, 34, 87, 0.05);
    --shadow-hover: 0 20px 40px rgba(13, 34, 87, 0.12);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.refaco-catalog-wrapper *,
.refaco-standalone-body * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.refaco-standalone-body {
    background-color: var(--bg-light);
    color: var(--text-main);
    font-family: var(--font-fa);
    min-height: 100vh;
    overflow-x: hidden;
}

/* RTL Helpers */
.rtl {
    direction: rtl;
}

.ltr {
    direction: ltr;
}

/* --- Layout Components --- */
.refaco-standalone-body header {
    background: var(--bg-white);
    border-bottom: 2px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-container h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
}

.logo-container img {
    height: 42px;
    object-fit: contain;
}

.refaco-standalone-body nav {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* --- Container --- */
.container {
    max-width: 1400px;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(237, 29, 36, 0.2);
}

.btn-primary:hover {
    background: var(--navy-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(13, 34, 87, 0.25);
}

.btn-accent {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(237, 29, 36, 0.2);
}

.btn-accent:hover {
    background: var(--navy-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(13, 34, 87, 0.25);
}

.btn-secondary {
    background: var(--bg-white);
    color: var(--navy-color);
    border: 1.5px solid var(--navy-color);
}

.btn-secondary:hover {
    background: var(--navy-color);
    color: white;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

/* Floating Export Button */
.floating-export-btn {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    right: auto;
    z-index: 9999;
    padding: 1rem 2.25rem;
    border-radius: 50px;
    font-size: 1.05rem;
    box-shadow: 0 10px 25px rgba(237, 29, 36, 0.3);
}

/* --- Search & Filters Bar --- */
.filter-bar {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
}

.search-input-group {
    position: relative;
    flex: 1;
    min-width: 300px;
}

.search-input-group input {
    width: 100%;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1rem 0.85rem 2.8rem;
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: var(--font-fa);
    outline: none;
    transition: var(--transition-smooth);
}

.search-input-group input:focus {
    border-color: var(--primary-color);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(237, 29, 36, 0.15);
}

.search-input-group .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.filters-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-select {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.85rem 1.5rem;
    border-radius: 12px;
    font-family: var(--font-fa);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    min-width: 180px;
    transition: var(--transition-smooth);
}

.filter-select:focus {
    border-color: var(--primary-color);
    background: var(--bg-white);
}

/* --- Product Grid --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* --- Product Card --- */
.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 480px;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-gradient);
    opacity: 0;
    transition: var(--transition-smooth);
}

.product-card:hover {
    transform: translateY(-8px);
    border-color: rgba(237, 29, 36, 0.2);
    box-shadow: var(--shadow-hover);
}

.product-card:hover::before {
    opacity: 1;
}

.card-top {
    position: relative;
}

.image-container {
    width: 100%;
    height: 200px;
    border-radius: 16px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #f1f5f9;
    margin-bottom: 1.25rem;
}

.image-container img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    transition: var(--transition-smooth);
}

.product-card:hover .image-container img {
    transform: scale(1.05);
}

.status-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 10;
    white-space: nowrap;
}

.status-available { background: rgba(16, 185, 129, 0.1); color: #059669; border: 1px solid rgba(16, 185, 129, 0.2); }
.status-out_of_stock { background: rgba(239, 68, 68, 0.1); color: #dc2626; border: 1px solid rgba(239, 68, 68, 0.2); }
.status-coming_soon { background: rgba(245, 158, 11, 0.1); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.2); }
.status-new { background: rgba(139, 92, 246, 0.1); color: #7c3aed; border: 1px solid rgba(139, 92, 246, 0.2); }

.category-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-color);
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.product-model {
    font-family: var(--font-en);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--navy-color);
    margin-bottom: 0.75rem;
}

.product-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1rem;
}

.product-tag-pill {
    font-size: 0.7rem;
    font-weight: bold;
    background: rgba(13, 34, 87, 0.06);
    color: var(--navy-color);
    padding: 3px 10px;
    border-radius: 50px;
    border: 1px solid rgba(13, 34, 87, 0.1);
    transition: var(--transition-smooth);
}

.product-card:hover .product-tag-pill {
    background: rgba(237, 29, 36, 0.08);
    color: var(--primary-color);
    border-color: rgba(237, 29, 36, 0.15);
}

.product-specs {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    white-space: pre-line;
    max-height: 120px;
    overflow-y: auto;
}

.card-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-container {
    display: flex;
    flex-direction: column;
}

.price-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.price-value {
    font-family: var(--font-en);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-color);
}

/* --- Login Panel --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 3rem 2.5rem;
    max-width: 450px;
    width: 100%;
    box-shadow: var(--shadow-hover);
}

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

.login-header h2 {
    font-size: 1.85rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--navy-color);
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-smooth);
}

.form-input:focus {
    border-color: var(--primary-color);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(237, 29, 36, 0.15);
}

.form-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
}

/* --- Admin Panel --- */
.admin-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2.5rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

.admin-card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow-premium);
    position: sticky;
    top: 100px;
}

.admin-table-container {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-premium);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.admin-table th {
    background: var(--bg-light);
    padding: 1.25rem 1.5rem;
    font-weight: 700;
    color: var(--navy-color);
    border-bottom: 1.5px solid var(--border-color);
}

.admin-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.admin-table tr:hover {
    background: #f8fafc;
}

.admin-table-img {
    height: 48px;
    width: 48px;
    border-radius: 8px;
    object-fit: contain;
    background: #f8fafc;
    border: 1px solid var(--border-color);
}

.action-links {
    display: flex;
    gap: 12px;
}

.action-link-edit {
    color: var(--navy-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
}

.action-link-edit:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.action-link-delete {
    color: var(--danger-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
}

.action-link-delete:hover {
    text-decoration: underline;
}

/* Custom Scrollbar */
.refaco-catalog-wrapper ::-webkit-scrollbar,
.refaco-standalone-body ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.refaco-catalog-wrapper ::-webkit-scrollbar-track,
.refaco-standalone-body ::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.refaco-catalog-wrapper ::-webkit-scrollbar-thumb,
.refaco-standalone-body ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.refaco-catalog-wrapper ::-webkit-scrollbar-thumb:hover,
.refaco-standalone-body ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- Mobile Responsive Rules --- */
@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
    }
    
    .header-container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .logo-container {
        flex-direction: column;
        gap: 4px;
    }
    
    .logo-container span {
        border-right: none !important;
        padding-right: 0 !important;
        margin-right: 0 !important;
        font-size: 0.85rem;
    }
    
    .container {
        margin: 1.5rem auto;
        padding: 0 1rem;
    }
    
    .filter-bar {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        border-radius: 16px;
        gap: 1rem;
    }
    
    .search-input-group {
        min-width: 100%;
    }
    
    .filters-group {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .filter-select {
        width: 100%;
    }
    
    .product-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .product-card {
        min-height: auto;
        padding: 1.25rem;
        border-radius: 20px;
    }
    
    .image-container {
        height: 180px;
    }
    
    .floating-export-btn {
        position: fixed;
        bottom: 1rem;
        left: 1rem;
        right: auto;
        padding: 0.85rem 1.5rem;
        font-size: 0.95rem;
        border-radius: 50px;
        text-align: center;
        justify-content: center;
        box-shadow: 0 6px 20px rgba(237, 29, 36, 0.2);
    }
    
    .admin-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .admin-card {
        padding: 1.25rem;
        border-radius: 16px;
    }
}
