/* ============================================================
   ShopLink - Styles principaux
   ============================================================ */

:root {
    --primary:    #4F46E5;
    --primary-dk: #3730A3;
    --secondary:  #10B981;
    --danger:     #EF4444;
    --warning:    #F59E0B;
    --info:       #3B82F6;
    --success:    #10B981;
    --green:      #10B981;
    --red:        #EF4444;
    --blue:       #3B82F6;
    --dark:       #1F2937;
    --gray:       #6B7280;
    --light:      #F9FAFB;
    --white:      #FFFFFF;
    --border:     #E5E7EB;
    --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
    --radius:     .5rem;
    --radius-lg:  1rem;
    --transition: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--dark);
    background: var(--light);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dk); }

img { max-width: 100%; height: auto; display: block; }

/* ---- Boutons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.25rem;
    border-radius: var(--radius);
    border: 2px solid transparent;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: normal;
    word-wrap: break-word;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary  { background: var(--primary);   color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dk); border-color: var(--primary-dk); color: #fff; }
.btn-success  { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-danger   { background: var(--danger);    color: #fff; border-color: var(--danger); }
.btn-warning  { background: var(--warning);   color: #fff; border-color: var(--warning); }
.btn-outline  { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-ghost    { background: transparent; color: var(--gray); border-color: transparent; }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: .3rem .8rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Formulaires ---- */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: .875rem; font-weight: 600; color: var(--dark); margin-bottom: .4rem; }
.form-control {
    width: 100%;
    padding: .65rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.form-control::placeholder { color: #9CA3AF; }
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }
.form-hint { font-size: .78rem; color: var(--gray); margin-top: .3rem; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: .3rem; }

/* ---- Cards ---- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 1rem; }
.card-body   { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: #F9FAFB; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---- Alertes ---- */
.alert { padding: .9rem 1.25rem; border-radius: var(--radius); font-size: .9rem; margin-bottom: 1rem; display: flex; align-items: flex-start; gap: .6rem; }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FCA5A5; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ---- Badge ---- */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; }
.badge-primary  { background: #EDE9FE; color: #5B21B6; }
.badge-success  { background: #D1FAE5; color: #065F46; }
.badge-danger   { background: #FEE2E2; color: #991B1B; }
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-info     { background: #DBEAFE; color: #1E40AF; }
.badge-gray     { background: #F3F4F6; color: #374151; }

/* ---- Tables ---- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); }
table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: .875rem; }
thead { background: #F9FAFB; }
th { padding: .75rem 1rem; text-align: left; font-weight: 600; color: var(--gray); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
td { padding: .875rem 1rem; border-top: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #F9FAFB; }

/* ---- Pagination ---- */
.pagination ul { display: flex; gap: .3rem; list-style: none; flex-wrap: wrap; padding: 1rem 0; }
.pagination .page-link { display: flex; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem; border-radius: var(--radius); border: 1.5px solid var(--border); font-size: .875rem; color: var(--dark); transition: all var(--transition); }
.pagination .page-item.active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-link:hover { background: var(--border); }

/* ---- Stat cards ---- */
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-card .stat-icon { width: 3rem; height: 3rem; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1.2; }
.stat-card .stat-label { font-size: .875rem; color: var(--gray); }

/* ---- Loading ---- */
.spinner { width: 1.5rem; height: 1.5rem; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(3, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0 !important; }
    #menuToggle { display: flex !important; }
}

@media (max-width: 576px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    /* Passage en colonne unique pour tous les contextes (Public, Admin, Marchand) */
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr !important; }
    .page-content { padding: 1rem; }
    .card-body { padding: 1.25rem 1rem; }
    .hero h1 { font-size: 1.8rem; }
}

/* ---- Utilitaires ---- */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--gray); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--secondary); }
.text-primary { color: var(--primary); }
.fw-bold      { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Product cards (shop) ---- */
.product-card { background: var(--white); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); transition: transform var(--transition), box-shadow var(--transition); }
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.product-card .product-img { aspect-ratio: 1; overflow: hidden; background: #F3F4F6; position: relative; }
.product-card .product-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.product-card:hover .product-img img { transform: scale(1.05); }
.product-card .product-info { padding: 1rem; }
.product-card .product-name { font-weight: 600; font-size: .95rem; color: var(--dark); margin-bottom: .3rem; }
.product-card .product-price { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.product-card .product-price .original { font-size: .85rem; color: var(--gray); text-decoration: line-through; font-weight: 400; }
.product-card .product-badge { position: absolute; top: .6rem; left: .6rem; }

/* ---- Shop header ---- */
.shop-banner { width: 100%; height: 220px; object-fit: cover; background: linear-gradient(135deg, var(--primary), var(--primary-dk)); }
.shop-logo-wrapper { width: 90px; height: 90px; border-radius: 50%; overflow: hidden; border: 4px solid #fff; box-shadow: var(--shadow); background: var(--white); }
.shop-logo-wrapper img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Sidebar merchant ---- */
.sidebar { width: 260px; min-height: 100vh; background: var(--dark); color: #fff; position: fixed; top: 0; left: 0; z-index: 1000; transition: transform var(--transition); }
.sidebar .sidebar-logo { padding: 1.5rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar .sidebar-logo a { font-size: 1.4rem; font-weight: 800; color: #fff; }
.sidebar nav { padding: 1rem 0; }
.sidebar nav a { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.5rem; color: rgba(255,255,255,.75); font-size: .9rem; transition: all var(--transition); }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar nav a i { width: 1.2rem; text-align: center; }
.sidebar nav .nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: .5rem 0; }
.sidebar nav .nav-section { padding: .5rem 1.5rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.4); font-weight: 600; }

/* ---- Main content ---- */
.main-wrapper { margin-left: 260px; min-height: 100vh; }
.topbar { background: var(--white); border-bottom: 1px solid var(--border); padding: 1rem 2rem; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); }
.page-content { padding: 2rem; }

#menuToggle { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; }

@media (max-width: 768px) {
    .topbar { padding: 1rem; }
    .page-content { padding: 1rem; }
}

/* Reduced padding on small screens */
@media (max-width: 480px) {
    .product-card .product-info { padding: 0.5rem; }
}

/* ---- Landing page ---- */
.hero { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; padding: 6rem 2rem; text-align: center; }
.hero h1 { font-size: 3rem; font-weight: 900; margin-bottom: 1rem; }
.hero p  { font-size: 1.25rem; opacity: .9; max-width: 600px; margin: 0 auto 2rem; }

/* ---- Image placeholder ---- */
.img-placeholder { background: linear-gradient(135deg, #E5E7EB 0%, #D1D5DB 100%); display: flex; align-items: center; justify-content: center; color: #9CA3AF; font-size: 3rem; width: 100%; height: 100%; }

/* ---- Panier flottant ---- */
#cart-btn { position: fixed; bottom: 2rem; right: 2rem; width: 3.5rem; height: 3.5rem; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; box-shadow: var(--shadow-lg); z-index: 999; cursor: pointer; border: none; transition: transform var(--transition); }
#cart-btn:hover { transform: scale(1.1); }
#cart-count { position: absolute; top: -.3rem; right: -.3rem; background: var(--danger); color: #fff; width: 1.3rem; height: 1.3rem; border-radius: 50%; font-size: .7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--white); border-radius: var(--radius-lg); max-width: 550px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body   { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }
.modal-close  { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--gray); line-height: 1; }

/* Fin des ajustements responsives */
