/* Chapter Dealership Portal - Dashboard Layout */

.chapter-dealership-wrapper {
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    color: #333;
    display: flex;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    position: relative;
    overflow-x: hidden;
}

/* Sidebar (Left) */
.cd-header {
    background: #1a1a1a;
    color: #fff;
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 30px;
    border-right: 4px solid #f37021;
    box-sizing: border-box;
    transition: transform 0.3s ease;
}

.cd-dealer-name {
    margin: 0 0 30px 0;
    color: #f37021;
    font-size: 18px;
    text-transform: uppercase;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
}

.cd-nav a {
    color: #bbb;
    text-decoration: none;
    padding: 12px 15px;
    border-radius: 6px;
    font-weight: 500;
    text-transform: uppercase;
    display: block;
}

.cd-nav a.active {
    background: #f37021 !important;
    color: #fff !important;
}

.cd-nav a.cd-nav-exit {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #333;
    text-transform: none;
    color: #888;
}

/* Main Content (Right) */
.cd-content {
    flex-grow: 1;
    background: #f4f6f8;
    padding: 40px;
    /* Reduced specific mobile overrides below */
    overflow-y: auto;
    width: 100%;
    /* Ensure width is managed */
}

/* --- NEW COMPONENT CLASSES --- */

/* 1. Stats Grid */
.cd-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.cd-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    text-align: center;
    border-bottom: 3px solid #f37021;
}

.cd-card h3 {
    margin: 0 0 10px;
    font-size: 14px;
    text-transform: uppercase;
    color: #888;
}

.cd-card .number {
    font-size: 32px;
    font-weight: 800;
    color: #333;
}


/* 2. Actions Grid (Dashboard) */
.cd-actions-grid-container {
    margin-top: 40px;
}

.cd-section-title {
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #333;
}

.cd-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* Standard Buttons - Homogenized */
.cd-btn,
.button-primary,
.cd-btn-submit,
.cd-btn-action,
button.button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: #f37021 !important;
    color: #fff !important;
    padding: 12px 24px !important;
    border-radius: 6px !important;
    text-decoration: none !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 14px !important;
    border: none !important;
    cursor: pointer !important;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.2 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
    font-family: 'Roboto', sans-serif !important;
    min-height: 44px;
    /* Touch target size */
}

.cd-btn:hover,
.button-primary:hover,
.cd-btn-submit:hover,
.cd-btn-action:hover,
button.button:hover {
    background: #d35400 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.cd-btn:active,
.button-primary:active,
.cd-btn-submit:active,
.cd-btn-action:active,
button.button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

/* Secondary Buttons */
.cd-btn-secondary {
    background: #6c757d !important;
}

.cd-btn-secondary:hover {
    background: #5a6268 !important;
}

/* Delete/Danger Actions */
.cd-btn-delete {
    background: none !important;
    border: none !important;
    cursor: pointer;
    font-size: 1.2em;
    color: #dc3545 !important;
    opacity: 0.8;
    transition: all 0.2s;
    padding: 8px;
    /* Touch padding */
}

.cd-btn-delete:hover {
    opacity: 1;
    transform: scale(1.1);
    color: #bd2130 !important;
}

.cd-action-card {
    background: #fff;
    border: 1px solid #ddd !important;
    padding: 20px;
    border-radius: 5px;
    text-decoration: none !important;
    color: #333 !important;
    display: block;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    /* Equal height */
    box-sizing: border-box;
}

.cd-action-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: #f37021 !important;
}

.cd-card-icon {
    font-size: 32px;
    color: #333;
    margin-bottom: 10px;
    display: block;
    width: 32px;
    height: 32px;
}

.cd-action-card:hover .cd-card-icon {
    color: #f37021;
}

.cd-action-card h3 {
    margin: 10px 0 5px !important;
    color: #000 !important;
    font-weight: 800 !important;
    font-size: 1.1em !important;
}

.cd-action-card p {
    margin: 0 !important;
    color: #666 !important;
    font-size: 0.9em !important;
}


/* 3. Split Views (Occasions, Events) */
.cd-split-view {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.cd-split-main {
    flex: 2;
}

.cd-split-aside {
    flex: 1;
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.03);
}


/* 4. Communication View */
.cd-com-container {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    max-width: 800px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

/* Global Input Styling - Homogenized */
.chapter-dealership-wrapper input[type="text"],
.chapter-dealership-wrapper input[type="number"],
.chapter-dealership-wrapper input[type="date"],
.chapter-dealership-wrapper input[type="time"],
.chapter-dealership-wrapper input[type="email"],
.chapter-dealership-wrapper input[type="password"],
.chapter-dealership-wrapper select,
.chapter-dealership-wrapper textarea {
    width: 100% !important;
    padding: 12px 15px !important;
    border: 1px solid #ced4da !important;
    border-radius: 6px !important;
    font-size: 15px !important;
    /* Readable on mobile */
    color: #495057 !important;
    background-color: #fff !important;
    background-clip: padding-box !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    min-height: 44px;
    /* Touch target */
    margin-bottom: 0 !important;
    /* Managed by containers */
}

.chapter-dealership-wrapper input:focus,
.chapter-dealership-wrapper select:focus,
.chapter-dealership-wrapper textarea:focus {
    border-color: #f37021 !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.2rem rgba(243, 112, 33, 0.25) !important;
}

.chapter-dealership-wrapper label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 0.95em;
    color: #333;
}

/* Specific Adjustments for Filters (Search Bar) */
.cd-filters input[type="text"] {
    border-radius: 6px 0 0 6px !important;
    border-right: none !important;
}

.cd-filters .cd-btn {
    border-radius: 0 6px 6px 0 !important;
    margin: 0 !important;
}

.cd-textarea-full {
    min-height: 200px;
}


/* 5. Import View */
.cd-import-container {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    max-width: 700px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.cd-import-note {
    margin-top: 20px;
    font-size: 0.9em;
    color: #666;
    border-top: 1px solid #eee;
    padding-top: 10px;
}


/* 6. Forms & Inputs */
.cd-form-stack label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
}

.cd-form-stack input[type="text"],
.cd-form-stack input[type="number"],
.cd-form-stack input[type="date"],
.cd-form-stack input[type="time"],
.cd-form-stack select,
.cd-form-stack textarea {
    width: 100% !important;
    padding: 10px !important;
    box-sizing: border-box !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    margin-bottom: 15px !important;
}

.cd-form-stack input[type="file"] {
    width: 100% !important;
    padding: 8px !important;
    box-sizing: border-box !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    margin-bottom: 15px !important;
    background: #fff !important;
    font-size: 0.9em;
}

.cd-form-stack input[type="file"]::file-selector-button {
    padding: 8px 14px;
    margin-right: 12px;
    border: none;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cd-form-stack input[type="file"]::file-selector-button:hover {
    background: #f37021;
}

.cd-form-row {
    display: flex;
    gap: 15px;
}

.cd-form-col {
    flex: 1;
}


/* 7. Events List */
.cd-event-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.cd-event-item {
    background: #fff;
    border: 1px solid #eee;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #f37021;
    display: flex;
    gap: 15px;
    align-items: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.cd-event-item:hover {
    background: #fafafa;
}

.cd-event-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    background: #eee;
}

.cd-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.cd-badge.public {
    background: #d4edda;
    color: #155724;
}

.cd-badge.private {
    background: #fff3cd;
    color: #856404;
}


/* 8. Tables */
.cd-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cd-table th {
    background: #333;
    color: #fff;
    padding: 15px;
    text-align: left;
}

.cd-table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.cd-table tr:hover {
    background: #f9f9f9;
}

/* Prix/Km : toujours sur une seule ligne, la colonne s'élargit au besoin
   plutôt que de laisser le texte retourner à la ligne ; alignées à droite
   pour que les chiffres forment une colonne lisible. */
.cd-table td.cd-col-price,
.cd-table th.cd-col-price,
.cd-table td.cd-col-km,
.cd-table th.cd-col-km {
    white-space: nowrap;
    text-align: right;
}

/* Miniature en début de ligne pour repérer une annonce plus vite */
.cd-table td.cd-col-thumb,
.cd-table th.cd-col-thumb {
    width: 60px;
    text-align: center;
}

.cd-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    background: #eee;
    display: inline-block;
}

.cd-thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
}

/* Action : pas de libellé (les icônes se suffisent), icônes centrées et
   alignées sur une ligne (le <form> de suppression est aussi un flex item,
   pas un bloc qui retomberait sous le lien "Modifier"). */
.cd-table td.cd-col-actions,
.cd-table th.cd-col-actions {
    width: 90px;
    text-align: center;
}

.cd-row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.cd-row-actions form {
    display: contents;
}

.cd-btn-edit {
    text-decoration: none !important;
    font-size: 1.2em;
    padding: 8px;
    opacity: 0.8;
    transition: all 0.2s;
    display: inline-block;
    line-height: 1;
}

.cd-btn-edit:hover {
    opacity: 1;
    transform: scale(1.1);
}


/* =========================================
   MOBILE RESPONSIVENESS (MAXIMIZED)
   ========================================= */

/* Toggle Button */
.cd-mobile-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    background: #f37021;
    border: none;
    border-radius: 5px;
    z-index: 10000;
    cursor: pointer;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cd-mobile-toggle span,
.cd-mobile-toggle span::before,
.cd-mobile-toggle span::after {
    display: block;
    width: 25px;
    height: 3px;
    background: #fff;
    position: absolute;
    left: 10px;
    transition: all 0.3s;
}

.cd-mobile-toggle span::before {
    content: '';
    top: -8px;
    left: 0;
}

.cd-mobile-toggle span::after {
    content: '';
    top: 8px;
    left: 0;
}

.cd-mobile-toggle.active span {
    background: transparent;
}

.cd-mobile-toggle.active span::before {
    transform: rotate(45deg);
    top: 0;
}

.cd-mobile-toggle.active span::after {
    transform: rotate(-45deg);
    top: 0;
}

@media (max-width: 1024px) {

    /* Layout Reset */
    .chapter-dealership-wrapper {
        flex-direction: column;
    }

    /* Content Maximization */
    .cd-content {
        padding: 15px !important;
        /* Minimal padding */
        padding-top: 70px !important;
        /* Space for toggle */
        width: 100%;
    }

    /* Menu Hidden by Default */
    .cd-header {
        position: fixed;
        left: -100%;
        /* Fully off-screen */
        top: 0;
        bottom: 0;
        width: 80%;
        /* Wider menu on mobile */
        max-width: 300px;
        z-index: 9999;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    }

    .menu-open .cd-header {
        left: 0;
    }

    /* Overlay */
    .menu-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 9998;
        backdrop-filter: blur(2px);
    }

    /* Toggle Visible */
    .cd-mobile-toggle {
        display: block;
    }

    /* Stack Split Views */
    .cd-split-view {
        flex-direction: column;
        gap: 40px;
    }

    .cd-split-main,
    .cd-split-aside {
        width: 100%;
        padding: 0;
        box-shadow: none;
        background: transparent;
    }

    .cd-split-aside {
        background: #fff;
        padding: 20px;
        border: 1px solid #eee;
    }

    /* Forms */
    .cd-form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Mobile Form Adjustments */
    .cd-filters {
        flex-direction: column;
    }

    .cd-filters input[type="text"] {
        border-radius: 6px !important;
        border-right: 1px solid #ced4da !important;
        margin-bottom: 10px !important;
    }

    .cd-filters .cd-btn {
        border-radius: 6px !important;
        width: 100%;
    }

    /* Full width buttons on mobile for better touch */
    .cd-btn,
    .button-primary,
    .cd-btn-submit,
    .cd-btn-action {
        width: 100% !important;
        max-width: none !important;
    }

    /* Responsive Table (Card View) */
    .cd-table {
        display: block;
        width: 100%;
    }

    .cd-table thead,
    .cd-table tbody,
    .cd-table th,
    .cd-table td,
    .cd-table tr {
        display: block;
    }

    .cd-table thead {
        display: none;
        /* Hide headers */
    }

    .cd-table tr {
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 20px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        padding: 10px;
    }

    .cd-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #eee;
        padding: 12px 10px;
        text-align: right;
        min-height: 30px;
    }

    .cd-table td:last-child {
        border-bottom: none;
        flex-direction: column;
        gap: 10px;
    }

    /* Pseudo-label for mobile */
    .cd-table td::before {
        content: attr(data-label);
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.85em;
        color: #888;
        float: left;
        margin-right: 15px;
    }

    /* Hide label for Actions to give full space to buttons */
    .cd-table td.cd-col-actions::before {
        display: none;
    }

    /* Thumbnail card: centered, no pseudo-label */
    .cd-table td.cd-col-thumb {
        justify-content: center;
        padding-bottom: 0;
        width: auto;
    }

    .cd-table td.cd-col-thumb::before {
        display: none;
    }

    .cd-thumb {
        width: 70px;
        height: 70px;
    }


    /* Stats Grid */
    .cd-stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .cd-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        text-align: left;
    }

    .cd-card h3 {
        margin: 0;
    }

    /* Action Grid */
    .cd-actions-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   FOOTER STYLES
   ========================================= */
.portal-footer {
    background: #111;
    color: #fff;
    padding: 20px;
    margin-top: auto;
    /* Push to bottom if using flex column on body */
    border-top: 4px solid #333;
}

.portal-footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.portal-user-info {
    font-size: 0.95em;
    color: #ccc;
    text-align: center;
}

.portal-logout {
    color: #f37021;
    text-decoration: none;
    font-weight: bold;
    margin-left: 5px;
    transition: color 0.2s;
}

.portal-logout:hover {
    color: #fff;
    text-decoration: underline;
}

.portal-lang-switcher ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 15px;
}

.portal-lang-switcher li a {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.portal-lang-switcher li a:hover {
    opacity: 1;
}

/* Ensure body fills height for sticky footer effect */
html,
body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
}

#portal-app {
    flex: 1;
}

@media (max-width: 768px) {
    .portal-footer-content {
        flex-direction: column;
        gap: 15px;
    }
}