/* Main CSS File with Dark Mode Support */

/* CSS Variables for Light and Dark Themes */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    
    /* Light Theme */
    --bg-color: #ffffff;
    --text-color: #333333;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --header-bg: #ffffff;
    --footer-bg: #f8f9fa;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --text-muted: #adb5bd;
    --border-color: #495057;
    --header-bg: #212529;
    --footer-bg: #343a40;
    --card-bg: #2d2d2d;
    --input-bg: #495057;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.4);
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.3;
}

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;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-color);
    opacity: 0.8;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
}

.skip-link:focus {
    top: 6px;
}

/* Header Styles */
.site-header {
    background-color: var(--header-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.header-top {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 0;
    font-size: 0.9rem;
}

.header-top-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.theme-toggle:hover {
    background-color: rgba(255,255,255,0.1);
}

[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }

.auth-links a, .user-menu a {
    color: white;
    margin-left: 10px;
    font-size: 0.9rem;
}

.header-main {
    padding: 15px 0;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo img {
    max-height: 50px;
    width: auto;
}

/* Navigation */
.main-navigation {
    flex: 1;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    margin: 3px 0;
    transition: 0.3s;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
    justify-content: center;
}

.nav-menu a {
    color: var(--text-color);
    font-weight: 500;
    padding: 10px 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s ease;
}

.nav-menu a:hover,
.nav-menu a.active {
    border-bottom-color: var(--primary-color);
}

/* Header Tools */
.header-tools {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-box form {
    display: flex;
    align-items: center;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    overflow: hidden;
    min-width: 250px;
}

.search-box input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: none;
    color: var(--text-color);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box button {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1.1rem;
}

.cart-widget {
    position: relative;
}

.cart-link {
    font-size: 1.5rem;
    position: relative;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

/* Main Content */
.main-content {
    min-height: calc(100vh - 200px);
    padding: 30px 0;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-color);
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    line-height: 1.5;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
    color: white;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 15px 30px;
    font-size: 1.125rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

.col {
    flex: 1;
    padding: 0 15px;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* Product Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin: 30px 0;
}

.product-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.product-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-5px);
}

.product-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background-color: var(--border-color);
}

.product-info {
    padding: 20px;
}

.product-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
}

.product-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.product-price .old-price {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 1rem;
    margin-left: 10px;
}

/* Footer */
.site-footer {
    background-color: var(--footer-bg);
    border-top: 1px solid var(--border-color);
    margin-top: 50px;
}

.footer-main {
    padding: 40px 0;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.footer-section h3 {
    margin-bottom: 20px;
    color: var(--text-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 8px;
}

.footer-section ul li a {
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.footer-section ul li a:hover {
    color: var(--text-color);
}

.social-links {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.social-links a {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.social-links a:hover {
    transform: scale(1.2);
}

.newsletter-form {
    display: flex;
    margin-top: 15px;
}

.newsletter-form input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px 0 0 5px;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.newsletter-form button {
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
}

.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding: 20px 0;
    background-color: var(--header-bg);
}

.footer-bottom-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.payment-methods {
    display: flex;
    align-items: center;
    gap: 10px;
}

.payment-methods img {
    border-radius: 3px;
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    z-index: 1000;
}

.back-to-top:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

/* Responsive Design */
@media (max-width: 992px) {
    .container {
        padding: 0 20px;
    }
    
    .header-content {
        flex-wrap: wrap;
    }
    
    .search-box form {
        min-width: 200px;
    }
    
    .footer-content {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--header-bg);
        flex-direction: column;
        padding: 20px;
        box-shadow: var(--shadow);
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .header-tools {
        order: -1;
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box form {
        min-width: auto;
        flex: 1;
        margin-right: 15px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (max-width: 576px) {
    .header-top-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-bottom-content {
        flex-direction: column;
        text-align: center;
    }
    
    .payment-methods {
        justify-content: center;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Cart Notification */
.cart-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 20px;
    min-width: 350px;
    z-index: 10000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.cart-notification.show {
    transform: translateX(0);
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.notification-icon {
    font-size: 1.5rem;
}

.notification-text {
    flex: 1;
    color: var(--text-color);
}

/* Messages */
.message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--card-bg);
    color: var(--text-color);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 10001;
    transition: transform 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

.message.show {
    transform: translateX(-50%) translateY(0);
}

.message-success {
    border-left-color: var(--success-color);
    background: rgba(76, 175, 80, 0.1);
}

.message-error {
    border-left-color: var(--danger-color);
    background: rgba(244, 67, 54, 0.1);
}

.message-info {
    border-left-color: var(--info-color);
    background: rgba(33, 150, 243, 0.1);
}

/* Cart Button States */
.add-to-cart:disabled,
.add-to-cart-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.add-to-cart:hover:not(:disabled),
.add-to-cart-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.add-to-cart-btn:disabled,
.add-to-cart-btn.btn-disabled {
    cursor: not-allowed !important;
    opacity: 0.9;
}

.add-to-cart-btn.btn-success.btn-disabled {
    background: #28a745 !important;
    border-color: #28a745 !important;
    color: white !important;
    font-size: 1rem !important;
    padding: 12px 15px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.add-to-cart-btn.btn-secondary.btn-disabled {
    background: #6c757d !important;
    border-color: #6c757d !important;
    opacity: 0.7;
}

.add-to-cart-btn:disabled:hover,
.add-to-cart-btn.btn-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Cart Counter */
.cart-widget {
    position: relative;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 10;
}

.cart-link {
    position: relative;
    font-size: 1.5rem;
    text-decoration: none;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.cart-link:hover {
    background-color: var(--hover-color, rgba(0,0,0,0.1));
}

/* Responsive Messages */
@media (max-width: 768px) {
    .cart-notification {
        right: 10px;
        left: 10px;
        min-width: auto;
        max-width: calc(100% - 20px);
    }
    
    .notification-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .message {
        left: 10px;
        right: 10px;
        transform: translateY(-100px);
        max-width: calc(100% - 20px);
    }
    
    .message.show {
        transform: translateY(0);
    }
}

/* Stock Status Styles */
.stock-complete { 
    color: #28a745; 
    font-weight: 600;
    background: rgba(40, 167, 69, 0.1);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(40, 167, 69, 0.3);
    display: inline-block;
    font-size: 0.9rem;
}



/* Wishlist Button */
.wishlist-btn {
    transition: all 0.3s ease;
}

.wishlist-btn[data-in-wishlist="true"] {
    background: #ff6b6b;
    border-color: #ff6b6b;
    color: white;
}

.wishlist-btn[data-in-wishlist="true"]:hover {
    background: #ff5252;
    border-color: #ff5252;
}

.wishlist-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Responsive Button Text */
.short-text {
    display: none;
}

.full-text {
    display: inline;
}

@media (max-width: 480px) {
    .add-to-cart-btn.btn-success.btn-disabled {
        font-size: 0.9rem !important;
        padding: 10px 12px !important;
    }
    
    .add-to-cart-btn {
        font-size: 0.95rem;
        padding: 12px;
    }
    
    .short-text {
        display: inline;
    }
    
    .full-text {
        display: none;
    }
}

/* Smooth Transitions */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
