/* =================================================================
   Polimasson — Design System
   Source unique des variables, base, typo et composants communs.
   Tous les fichiers CSS "page" doivent se reposer sur ce socle.
   ================================================================= */

/* ─────────────────────────────────────────────
   1. Design tokens
   ───────────────────────────────────────────── */
:root {
    /* Brand */
    --primary:           #7c3aed;
    --primary-hover:     #6d28d9;
    --primary-light:     #f5f3ff;
    --primary-dark:      #5b21b6;
    --accent:            #a78bfa;
    --accent-soft:       #c4b5fd;

    /* Status */
    --success:           #10b981;
    --success-light:     #d1fae5;
    --warning:           #f59e0b;
    --warning-light:     #fef3c7;
    --danger:            #ef4444;
    --danger-light:     #fee2e2;
    --info:              #3b82f6;
    --info-light:        #dbeafe;
    --gold:              #f59e0b;
    --gold-light:        #fef3c7;

    /* Surfaces */
    --bg:                #f8fafc;
    --bg-card:           #ffffff;
    --bg-sidebar:        #ffffff;
    --text:             #0f172a;
    --text-secondary:   #64748b;
    --text-muted:       #94a3b8;
    --border:           #e2e8f0;
    --border-light:     #f1f5f9;

    /* Shadows */
    --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow:      0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-md:   0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg:   0 16px 40px rgba(0, 0, 0, 0.10);
    --shadow-xl:   0 24px 56px rgba(124, 58, 237, 0.12);
    --glow:        0 0 20px rgba(124, 58, 237, 0.15);

    /* Radii */
    --radius-sm:    8px;
    --radius:      12px;
    --radius-md:   16px;
    --radius-lg:   20px;
    --radius-xl:   24px;
    --radius-full: 9999px;

    /* Motion */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --sidebar-width:    260px;
    --sidebar-collapsed: 72px;
    --container-max:    1200px;

    /* Typography */
    --font-body:  system-ui, sans-serif;
    --font-head:  'Outfit', system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
    --primary:       #a78bfa;
    --primary-hover: #8b5cf6;
    --primary-light: #2e1065;
    --primary-dark:  #c4b5fd;
    --accent:        #7c3aed;
    --accent-soft:   #6d28d9;

    --bg:            #0f172a;
    --bg-card:       #1e293b;
    --bg-sidebar:    #0f172a;
    --text:         #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:   #64748b;
    --border:       #1e293b;
    --border-light: #334155;

    --success-light: #064e3b;
    --warning-light: #78350f;
    --danger-light:  #7f1d1d;
    --info-light:    #1e3a5f;
    --gold-light:    #78350f;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.15);
    --shadow:    0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 24px 56px rgba(124, 58, 237, 0.18);
    --glow:    0 0 24px rgba(167, 139, 250, 0.20);
}

/* ─────────────────────────────────────────────
   2. Fonts
   ───────────────────────────────────────────── */
@font-face {
    font-family: 'Outfit';
    src: url('/resc/theme/font/Outfit[wght].woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

/* ─────────────────────────────────────────────
   3. Reset + base
   ───────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 80px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-head);
    font-weight: 600;
    color: var(--text);
}

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

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

/* ─────────────────────────────────────────────
    4. Layout primitives
   ───────────────────────────────────────────── */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar Premium */
header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 30px;
}
html[data-theme="dark"] header {
    background: rgba(20, 20, 20, 0.85);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    height: 100%;
}
.logo::after {
    position: fixed;
    content: "Polimasson";
    top: 22px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: color var(--transition);
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-btn {
    background: var(--primary);
    color: #fff !important;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.8125rem !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
    transition: all var(--transition);
}
.nav-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.3);
}

.nav-btn-outline {
    border: 1px solid var(--primary);
    color: var(--primary) !important;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.8125rem !important;
    transition: all var(--transition);
}
.nav-btn-outline:hover {
    background: var(--primary-light);
}

.save-btn-action {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    background: var(--bg);
    border: 1px solid var(--border);
}
.save-btn-action:hover {
    color: var(--primary);
    transform: scale(1.1);
    background: var(--primary-light);
    border-color: var(--accent);
}
.save-btn-action.saved {
    color: var(--primary);
    background: var(--primary-light);
    border-color: var(--accent);
}

.share-btn-container {
    position: relative;
    display: inline-flex;
}

.share-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 8px;
    display: none;
    margin-top: 6px;
}

.share-dropdown.show {
    display: block;
}

.share-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.share-dropdown-item:hover {
    background: var(--primary-light);
}

.share-dropdown-item i {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.share-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 8px;
}

html[dir="rtl"] .share-dropdown {
    right: auto;
    left: 0;
}

html[dir="rtl"] .share-dropdown-item {
    text-align: right;
}

.container-narrow {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 20px;
}

.section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.section:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title::before {
    content: '';
    width: 4px;
    height: 22px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 2px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
    color: var(--text-muted);
}
.empty-state h3 {
    margin: 0 0 16px 0;
    color: var(--text-muted);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 20px;
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.back-link:hover {
    color: var(--primary);
    border-color: var(--accent);
    transform: translateX(-2px);
}

/* ─────────────────────────────────────────────
   5. Buttons
   ───────────────────────────────────────────── */
.btn,
button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn {
    padding: 10px 18px;
    font-size: 0.875rem;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.2;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.3);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 2px dashed var(--border);
    width: 100%;
}
.btn-secondary:hover {
    background: var(--primary);
    color: #fff;
    border-style: solid;
    border-color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
    color: #fff;
    transform: translateY(-1px);
}

.btn-edit {
    background: var(--primary);
    color: #fff;
}
.btn-edit:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
}

button[type="submit"] {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}
button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
button[type="submit"]:active {
    transform: translateY(0);
}

.btn-boost {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: #fff;
    border: none;
    cursor: pointer;
}
.btn-boost:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
    color: #fff;
}

.btn-boosted {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    border: none;
    cursor: pointer;
    animation: pulse-boost 2s infinite;
}
@keyframes pulse-boost {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50%     { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.btn-del {
    background: var(--danger);
    color: #fff;
    cursor: pointer;
}

/* ─────────────────────────────────────────────
   6. Forms
   ───────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="date"],
textarea,
select {
    width: 100%;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg-card);
    transition: all var(--transition);
}
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 48px;
}
[dir="rtl"] select {
    background-position: left 16px center;
    padding-right: 12px;
    padding-left: 48px;
}
select optgroup {
    font-weight: 600;
    color: var(--primary);
}

/* EasyMDE (editor de markdown) */
.EasyMDEContainer {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}
.EasyMDEContainer:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}
.editor-toolbar {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 8px;
}
.editor-toolbar button {
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    margin: 0 2px;
    background: transparent;
    box-shadow: none;
}
.editor-toolbar button:hover {
    background: var(--primary);
    color: #fff;
}
.CodeMirror {
    background: var(--bg-card);
    min-height: 120px;
    color: var(--text);
}
.CodeMirror-scroll {
    min-height: 120px;
}

/* ─────────────────────────────────────────────
   7. Badges & meta
   ───────────────────────────────────────────── */
.badge,
.meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.badge-primary,
.meta-badge.category {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #fff;
    border: none;
}
.badge-info,
.meta-badge.location {
    background: linear-gradient(135deg, #bae6fd, var(--info));
    color: var(--text);
    border: none;
}

/* ─────────────────────────────────────────────
   8. Messages (success / error / warning)
   ───────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-weight: 500;
}
.alert-success {
    background: var(--success-light);
    border: 1px solid var(--success);
    color: #065f46;
}
.alert-warning {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    color: #92400e;
}
.alert-danger {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    color: #991b1b;
}

.muted {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: -8px 0 16px 0;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
}

/* ─────────────────────────────────────────────
   9. Cards / grids
   ───────────────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    background: var(--bg-card);
    transition: all var(--transition);
}
.card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.grid-annonces,
.annonces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
}

/* Annonce cards (used by browse, view-vendor, favorites) */
.annonce-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.015);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: var(--bg-card);
}
.annonce-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(124, 58, 237, 0.08);
    border-color: var(--accent);
}

.boosted-card {
    border: 1.5px solid var(--accent);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.06);
}

.boost-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.3);
    z-index: 10;
}

.annonce-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
}
.annonce-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.annonce-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.annonce-title {
    font-size: 1.125rem;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.4;
    transition: color var(--transition);
}
.annonce-card:hover .annonce-title {
    color: var(--primary);
}

.annonce-desc {
    font-size: 0.84375rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 42px;
}

.annonce-plans-preview {
    border-top: 1px solid var(--border);
    padding-top: 15px;
    margin-top: auto;
}

.starting-price {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.price-tag {
    font-family: var(--font-head);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}
.price-tag span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

/* ─────────────────────────────────────────────
   10. Markdown content (shared between many views)
   ───────────────────────────────────────────── */
.markdown-content {
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.6;
}
.markdown-content p {
    margin-bottom: 12px;
}
.markdown-content p:last-child {
    margin-bottom: 0;
}
.markdown-content h1, .markdown-content h2, .markdown-content h3, .markdown-content h4 {
    color: var(--text);
    margin: 20px 0 10px 0;
    font-weight: 600;
}
.markdown-content h1 { font-size: 1.25rem; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.markdown-content h2 { font-size: 1.1rem; }
.markdown-content h3 { font-size: 1rem; }
.markdown-content h4 { font-size: 0.9rem; }
.markdown-content ul, .markdown-content ol {
    margin: 10px 0;
    padding-left: 20px;
}
.markdown-content ul { list-style-type: disc; }
.markdown-content ol { list-style-type: decimal; }
.markdown-content li { margin-bottom: 4px; }
.markdown-content blockquote {
    border-left: 4px solid var(--primary);
    background: var(--primary-light);
    padding: 8px 16px;
    margin: 12px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}
.markdown-content strong {
    font-weight: 600;
    color: var(--text);
}

/* ─────────────────────────────────────────────
   11. Scopes communes (header-actions, balance, etc.)
   ───────────────────────────────────────────── */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 20px;
    flex-wrap: wrap;
}
.header-actions h1 {
    margin: 0;
}

.header-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--gold-light), #fde68a);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1.125rem;
}
.header-balance .balance-amount {
    color: #92400e;
}
.header-balance .balance-icon {
    color: var(--gold);
    font-size: 1.25rem;
}

/* ─────────────────────────────────────────────
   12. RTL support
   ───────────────────────────────────────────── */
[dir="rtl"] .back-link:hover {
    transform: translateX(2px);
}
[dir="rtl"] .btn-primary:hover,
[dir="rtl"] button[type="submit"]:hover,
[dir="rtl"] .card:hover {
    transform: translateY(-2px);
}

/* ─────────────────────────────────────────────
   13. Language switcher (shared)
   ───────────────────────────────────────────── */
.language-switcher {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.language-switcher .lang-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text);
    transition: all var(--transition);
}
.language-switcher .lang-btn:hover,
.language-switcher .lang-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.language-switcher--public {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: -10px auto 20px;
    max-width: var(--container-max);
    padding: 0 20px;
}

/* ─────────────────────────────────────────────
   14. Responsive
   ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .grid-annonces,
    .annonces-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .grid-auto {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    .section, .card {
        padding: 16px;
    }
    .header-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}
