/* RTL Hebrew CSS Framework for Electrical Store */
/* Accessibility and A11Y Compliance Styles */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

html {
    scroll-behavior: smooth;
}

/* ==== ACCESSIBILITY IMPROVEMENTS ==== */

/* Skip to main content link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 4px;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
}

/* Enhanced Focus Indicators */
*:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* High contrast focus for interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
.btn:focus,
.card:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
    position: relative;
    z-index: 1;
}

/* Ensure focus is visible on all clickable elements */
[role="button"]:focus,
[tabindex]:focus,
.clickable:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

/* Remove outline for mouse users, keep for keyboard users */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
    box-shadow: none;
}

/* Enhanced text contrast for accessibility */
body {
    color: #212529; /* Higher contrast */
}

/* Ensure minimum color contrast ratios */
.text-muted {
    color: #495057 !important; /* Improved contrast */
}

.card-text {
    color: #495057; /* Better contrast than original #6c757d */
}

/* Enhanced hover states for better usability */
a:hover, a:focus,
button:hover, button:focus,
.btn:hover, .btn:focus {
    text-decoration: underline;
    transition: all 0.2s ease;
}

/* Screen reader only text */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Show screen reader text on focus for debugging */
.sr-only:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0.25rem 0.5rem !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    background: #000;
    color: #fff;
    z-index: 9999;
}

/* Keyboard navigation indicators */
.keyboard-nav .navbar-nav a:focus,
.keyboard-nav .btn:focus,
.keyboard-nav .card:focus {
    background-color: rgba(74, 144, 226, 0.1);
    border-radius: 4px;
}

/* Enhanced modal accessibility */
.modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal[aria-hidden="false"] {
    display: block;
}

.modal-content {
    position: relative;
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border: none;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced form accessibility */
label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #495057;
}

.form-control {
    border: 2px solid #ced4da;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.25);
    outline: none;
}

.form-control[aria-invalid="true"] {
    border-color: #dc3545;
}

.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Enhanced error state visibility */
.is-invalid {
    border-color: #dc3545 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23dc3545' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-left: calc(1.5em + 0.75rem);
}

/* RTL adjustments for error indicators */
[dir="rtl"] .is-invalid {
    background-position: right calc(0.375em + 0.1875rem) center;
    padding-right: calc(1.5em + 0.75rem);
    padding-left: 0.75rem;
}

/* ==== END ACCESSIBILITY IMPROVEMENTS ====

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
    color: #2c3e50;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p { margin-bottom: 1rem; }

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.container-fluid {
    width: 100%;
    padding: 0 20px;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.col {
    flex: 1;
    padding: 0 15px;
}

.col-1 { flex: 0 0 8.333333%; }
.col-2 { flex: 0 0 16.666667%; }
.col-3 { flex: 0 0 25%; }
.col-4 { flex: 0 0 33.333333%; }
.col-6 { flex: 0 0 50%; }
.col-8 { flex: 0 0 66.666667%; }
.col-9 { flex: 0 0 75%; }
.col-12 { flex: 0 0 100%; }

/* Header Styles - Enhanced for Accessibility */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.navbar-brand {
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 4px;
}

.navbar-brand:hover,
.navbar-brand:focus {
    color: #ffd700;
    text-decoration: none;
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 1rem;
    margin: 0;
    padding: 0;
}

.navbar-nav li {
    margin: 0;
}

.navbar-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    min-height: 44px; /* Accessibility: minimum touch target */
}

.navbar-nav a:hover,
.navbar-nav a:focus {
    color: #ffd700;
    background-color: rgba(255, 215, 0, 0.1);
    outline: 2px solid #ffd700;
    outline-offset: 2px;
    text-decoration: none;
}

/* Enhanced active state for current page */
.navbar-nav a[aria-current="page"],
.navbar-nav a.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-weight: 600;
}

/* Cart Badge Styling - Enhanced Accessibility */
.cart-badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    animation: none;
    background: #ffc107;
    color: #212529;
    font-weight: bold;
    margin-right: 0.25rem;
}

.cart-badge.updated {
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 20%, 60%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    80% {
        transform: translateY(-5px);
    }
}

/* Button Styles - Enhanced for Accessibility */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: 2px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    line-height: 1.5;
    min-height: 44px; /* Minimum touch target size */
    min-width: 44px;
    position: relative;
    vertical-align: middle;
}

/* Ensure buttons are keyboard accessible */
.btn:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

/* Enhanced button states for accessibility */
.btn:disabled,
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border-color: #6c757d;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background: #5a6169;
    border-color: #545b62;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.btn-success:hover,
.btn-success:focus {
    background: #218838;
    border-color: #1e7e34;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.btn-danger:hover,
.btn-danger:focus {
    background: #c82333;
    border-color: #bd2130;
    color: white;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
    border-color: #ffc107;
}

.btn-warning:hover,
.btn-warning:focus {
    background: #e0a800;
    border-color: #d39e00;
    color: #212529;
}

/* Outline button variants for better accessibility */
.btn-outline-primary {
    background: transparent;
    color: #667eea;
    border-color: #667eea;
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
    min-height: 36px;
    min-width: 36px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.125rem;
    min-height: 52px;
    min-width: 52px;
}

/* Categories Section Styling */
.categories {
    padding: 3rem 0;
    background: #ffffff;
}

.categories .card {
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    height: 100%;
}

.categories .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.categories .card-body {
    padding: 2rem 1.5rem;
    text-align: center;
}

.categories .card-title {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.categories .card-text {
    color: #6c757d;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Ensure proper spacing for categories grid */
.categories .row {
    margin: 0 -15px;
}

.categories .col-md-4 {
    padding: 0 15px;
    margin-bottom: 2rem;
}

/* Additional fixes for categories section */
.categories .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.categories h2 {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 2rem;
}

/* Prevent layout shifts during AJAX operations */
.categories .row {
    min-height: 200px;
}

/* Ensure cards maintain consistent height */
.categories .card {
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.categories .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Loading state for add to cart buttons */
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Smooth transitions for all interactive elements */
.btn, .card, .product-card {
    transition: all 0.3s ease;
}

/* Fix for RTL text alignment in cards */
.card-title, .card-text {
    text-align: right;
    direction: rtl;
}

/* Enhanced alert positioning */
.alert.dynamic-alert {
    backdrop-filter: blur(5px);
    border: none;
}

/* Responsive fixes */
@media (max-width: 768px) {
    .categories .col-md-4 {
        margin-bottom: 1rem;
    }
    
    .categories .card-body {
        padding: 1.5rem 1rem;
    }
    
    .alert.dynamic-alert {
        right: 10px;
        left: 10px;
        top: 10px;
    }
}
.categories .card-title:before {
    content: "";
    display: block;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    margin: 0 auto 1rem;
    position: relative;
}

.categories .card-title:before {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 30px;
}
/* Card Styles - Enhanced for Accessibility */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 2rem;
    border: 2px solid transparent;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Enhanced focus for keyboard navigation */
.card:focus,
.card[tabindex]:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(74, 144, 226, 0.3);
}

/* Make cards keyboard accessible when clickable */
.card[role="button"],
.card.clickable {
    cursor: pointer;
    tabindex: 0;
}

.card[role="button"]:focus,
.card.clickable:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

.card-header {
    background: #f8f9fa;
    padding: 1.25rem;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: #f8f9fa;
    padding: 1rem 1.25rem;
    border-top: 1px solid #dee2e6;
}

.card-img-top {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

/* Enhanced card titles for better hierarchy */
.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #2c3e50;
}

.card-text {
    color: #495057;
    line-height: 1.6;
    margin-bottom: 1rem;
}

/* Product Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.product-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-info {
    padding: 1.5rem;
}

.product-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.product-description {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.product-price {
    font-size: 1.4rem;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 1rem;
}

.product-price.discount {
    color: #27ae60;
}

.original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 1rem;
    margin-left: 10px;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    direction: rtl;
    text-align: right;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control.is-invalid {
    border-color: #dc3545;
}

.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid #e9ecef;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: #f8f9fa;
}

/* Alert Messages */
.alert {
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 6px;
    position: relative;
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-start;
    gap: 1rem;
}

.close {
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close:hover {
    color: #333;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem;
}

.badge-primary { background-color: #007bff; color: white; }
.badge-success { background-color: #28a745; color: white; }
.badge-danger { background-color: #dc3545; color: white; }
.badge-warning { background-color: #ffc107; color: #212529; }
.badge-info { background-color: #17a2b8; color: white; }

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.flex-column { flex-direction: column; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* Footer Styles */
.footer {
    background: #2c3e50;
    color: white;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer h5 {
    color: #ecf0f1;
    margin-bottom: 1rem;
}

.footer p, .footer a {
    color: #bdc3c7;
    text-decoration: none;
}

.footer a:hover {
    color: white;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .navbar-nav {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .col-sm-12 { flex: 0 0 100%; }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.5rem; }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

@media (max-width: 576px) {
    .card-body {
        padding: 1rem;
    }
    
    .product-info {
        padding: 1rem;
    }
    
    .form-control {
        padding: 10px 12px;
    }
    
    .btn {
        padding: 10px 20px;
    }
}