/* =============================================
   Plateforme ATS V2 - Styles Custom
   ============================================= */

/* Variables de couleurs */
:root {
    --ats-primary: #2563EB;
    --ats-primary-dark: #1D4ED8;
    --ats-secondary: #059669;
    --ats-accent: #F59E0B;
    --ats-danger: #DC2626;
    --ats-dark: #1F2937;
    --ats-light: #F3F4F6;
    --ats-whatsapp: #25D366;
    --ats-border: #E5E7EB;
}

/* Base */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--ats-light);
    color: var(--ats-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Navbar */
.navbar-ats {
    background: linear-gradient(135deg, var(--ats-primary), var(--ats-primary-dark));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar-ats .navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    color: #fff !important;
}

.navbar-ats .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500;
    transition: color 0.2s;
}

.navbar-ats .nav-link:hover,
.navbar-ats .nav-link.active {
    color: #fff !important;
}

/* Cards produits */
.product-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    background: #fff;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.product-card .card-img-top {
    height: 200px;
    object-fit: cover;
}

.product-card .card-body {
    padding: 1rem;
}

.product-card .product-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ats-dark);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Prix */
.price-tag {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ats-primary);
}

.price-tag-large {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--ats-primary);
}

.price-margin {
    font-weight: 600;
    color: var(--ats-secondary);
}

.price-margin-negative {
    color: var(--ats-danger);
}

/* Stock */
.stock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 20px;
}

.stock-in {
    background-color: #D1FAE5;
    color: #065F46;
}

.stock-out {
    background-color: #FEE2E2;
    color: #991B1B;
}

/* Bouton WhatsApp */
.btn-whatsapp {
    background-color: var(--ats-whatsapp);
    color: #fff;
    border: none;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 12px 30px;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-whatsapp:hover {
    background-color: #20BD5A;
    color: #fff;
    transform: scale(1.02);
}

.btn-whatsapp:active {
    transform: scale(0.98);
}

/* Badges statut commande */
.badge-pending   { background-color: #FEF3C7; color: #92400E; }
.badge-confirmed { background-color: #DBEAFE; color: #1E40AF; }
.badge-shipped   { background-color: #E0E7FF; color: #3730A3; }
.badge-delivered  { background-color: #D1FAE5; color: #065F46; }
.badge-cancelled  { background-color: #FEE2E2; color: #991B1B; }

/* Carte catégorie */
.category-card {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    text-align: center;
    transition: transform 0.2s;
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.category-card:hover {
    transform: translateY(-3px);
    color: inherit;
}

.category-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
    margin: 1rem auto 0.5rem;
}

.category-card .card-title {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0 0.5rem 1rem;
}

/* Formulaire de commande — aperçu marge */
.margin-preview {
    background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
    border: 2px solid var(--ats-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.margin-preview .margin-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ats-secondary);
}

.margin-preview.negative {
    background: linear-gradient(135deg, #FEF2F2, #FEE2E2);
    border-color: var(--ats-danger);
}

.margin-preview.negative .margin-amount {
    color: var(--ats-danger);
}

/* Dashboard stats */
.stat-card {
    border: none;
    border-radius: 12px;
    padding: 1.5rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    font-size: 3rem;
    opacity: 0.2;
    position: absolute;
    right: 15px;
    top: 15px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-card .stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.stat-orders    { background: linear-gradient(135deg, #2563EB, #1D4ED8); }
.stat-revenue   { background: linear-gradient(135deg, #059669, #047857); }
.stat-resellers { background: linear-gradient(135deg, #7C3AED, #6D28D9); }
.stat-products  { background: linear-gradient(135deg, #F59E0B, #D97706); }

/* Admin sidebar */
.sidebar-admin {
    background: var(--ats-dark);
    min-height: calc(100vh - 56px);
    padding-top: 1rem;
}

.sidebar-admin .nav-link {
    color: rgba(255, 255, 255, 0.7);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    margin: 2px 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-admin .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-admin .nav-link.active {
    color: #fff;
    background-color: var(--ats-primary);
}

.sidebar-admin .sidebar-heading {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem 1.25rem 0.5rem;
}

/* Auth pages */
.auth-container {
    max-width: 420px;
    margin: 2rem auto;
    padding: 2rem;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.auth-container h2 {
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--ats-primary);
}

.auth-container .form-control {
    border-radius: 10px;
    padding: 0.75rem 1rem;
    border: 2px solid var(--ats-border);
}

.auth-container .form-control:focus {
    border-color: var(--ats-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-container .btn-primary {
    border-radius: 10px;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
    background-color: var(--ats-primary);
    border-color: var(--ats-primary);
}

.auth-container .btn-primary:hover {
    background-color: var(--ats-primary-dark);
    border-color: var(--ats-primary-dark);
}

/* Timeline statut commande */
.order-timeline {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 0;
    list-style: none;
    margin: 2rem 0;
}

.order-timeline::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--ats-border);
}

.order-timeline li {
    text-align: center;
    position: relative;
    flex: 1;
}

.order-timeline li .timeline-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--ats-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 0.8rem;
    position: relative;
    z-index: 1;
}

.order-timeline li.active .timeline-dot {
    background-color: var(--ats-secondary);
    color: #fff;
}

.order-timeline li.active ~ li .timeline-dot {
    background-color: var(--ats-border);
}

.order-timeline li .timeline-label {
    font-size: 0.7rem;
    color: #6B7280;
}

/* Footer */
.footer-ats {
    background-color: var(--ats-dark);
    color: rgba(255, 255, 255, 0.7);
    padding: 1.5rem 0;
    margin-top: auto;
    font-size: 0.9rem;
}

/* Utilitaires */
.text-ats-primary { color: var(--ats-primary); }
.text-ats-secondary { color: var(--ats-secondary); }
.text-ats-accent { color: var(--ats-accent); }

.bg-ats-primary { background-color: var(--ats-primary); }
.bg-ats-secondary { background-color: var(--ats-secondary); }

/* Image placeholder */
.img-placeholder {
    background-color: #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9CA3AF;
    font-size: 2rem;
}

/* Navbar mobile — fond du menu déroulant */
@media (max-width: 991.98px) {
    .navbar-ats .navbar-collapse {
        background: linear-gradient(135deg, var(--ats-primary), var(--ats-primary-dark));
        margin: 0 -0.75rem;
        padding: 0.75rem 1rem;
        border-radius: 0 0 12px 12px;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    }

    .navbar-ats .navbar-nav {
        padding: 0.25rem 0;
    }

    .navbar-ats .nav-link {
        padding: 0.65rem 0.75rem !important;
        border-radius: 8px;
        margin: 2px 0;
    }

    .navbar-ats .nav-link:hover,
    .navbar-ats .nav-link.active {
        background-color: rgba(255, 255, 255, 0.15);
    }

    .navbar-ats .dropdown-menu {
        background: rgba(255, 255, 255, 0.1);
        border: none;
        box-shadow: none;
    }

    .navbar-ats .dropdown-item {
        color: rgba(255, 255, 255, 0.85);
    }

    .navbar-ats .dropdown-item:hover {
        color: #fff;
        background-color: rgba(255, 255, 255, 0.15);
    }

    .navbar-ats .dropdown-divider {
        border-color: rgba(255, 255, 255, 0.2);
    }

    .navbar-ats .btn-outline-light {
        margin-left: 0 !important;
        margin-top: 0.25rem;
    }
}

/* Admin offcanvas mobile */
.offcanvas .sidebar-admin {
    min-height: 100%;
    background: var(--ats-dark);
}

/* Admin contenu principal — empêcher le débordement mobile */
.d-flex > .flex-grow-1 {
    min-width: 0;
    overflow-x: hidden;
}

/* Admin stat cards — taille adaptée sur mobile */
@media (max-width: 576px) {
    .stat-card .stat-value {
        font-size: 1.2rem;
    }
    .stat-card .stat-label {
        font-size: 0.75rem;
    }
    .stat-card {
        padding: 1rem;
    }
    .stat-card .stat-icon {
        font-size: 2rem;
        right: 8px;
        top: 8px;
    }
}

/* Admin tableaux — texte plus petit sur mobile */
@media (max-width: 768px) {
    .table-responsive table {
        font-size: 0.8rem;
    }
    .table-responsive table th,
    .table-responsive table td {
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }
}

/* Responsive mobile */
@media (max-width: 768px) {
    .product-card .card-img-top {
        height: 150px;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }

    .auth-container {
        margin: 1rem;
        padding: 1.5rem;
    }

    .order-timeline li .timeline-label {
        font-size: 0.6rem;
    }

    .margin-preview .margin-amount {
        font-size: 1.5rem;
    }

    .sidebar-admin {
        min-height: auto;
    }
}

@media (max-width: 576px) {
    .product-card .card-img-top {
        height: 130px;
    }

    .price-tag {
        font-size: 0.95rem;
    }

    .btn-whatsapp {
        font-size: 1rem;
        padding: 10px 20px;
        width: 100%;
        justify-content: center;
    }
}
