/* CRM - Styles personnalisés */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Prevent overflow globally */
*, *::before, *::after {
    box-sizing: border-box;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

.container-fluid {
    flex: 1;
}

/* Navbar */
.navbar-brand {
    font-weight: bold;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
}

/* Stats Cards */
.stat-card {
    border-left: 4px solid;
}

.stat-card.primary {
    border-left-color: var(--secondary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: bold;
}

.stat-card .stat-label {
    color: #6c757d;
    font-size: 0.875rem;
    text-transform: uppercase;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo i {
    font-size: 3rem;
    color: var(--primary-color);
}

.login-card .logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 0.5rem;
}

/* Tables */
.table th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-top: none;
}

.table-hover tbody tr:hover {
    background-color: #f1f3f5;
}

/* Responsive Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    min-width: 100%;
}

@media (max-width: 992px) {
    .table td, .table th {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem;
    }

    .table .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* Buttons */
.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Footer */
.footer {
    margin-top: auto;
}

/* Badges */
.badge {
    font-weight: 500;
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

/* Alerts */
.alert {
    border: none;
    border-radius: 8px;
}

/* Installation Page */
.install-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.install-card {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.install-step {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}

.install-step:last-child {
    border-bottom: none;
}

.install-step .step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--secondary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 1rem;
}

.install-step.completed .step-number {
    background: var(--success-color);
}

.install-step.error .step-number {
    background: var(--danger-color);
}

/* Responsive */
@media (max-width: 768px) {
    .stat-card .stat-value {
        font-size: 1.25rem;
    }

    .navbar-brand {
        font-size: 1rem;
    }

    /* Container adjustments */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Cards on mobile */
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Stat cards grid */
    .row .col-md-3,
    .row .col-md-4,
    .row .col-lg-3 {
        margin-bottom: 0.5rem;
    }

    /* Buttons on mobile */
    .btn {
        white-space: normal;
        word-wrap: break-word;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    /* Forms on mobile */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Modal on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    /* Hide certain columns on mobile */
    .d-none-mobile {
        display: none !important;
    }

    /* Navbar adjustments */
    .navbar .nav-link {
        padding: 0.5rem 0.75rem;
    }

    /* Page titles */
    h1, .h1 {
        font-size: 1.5rem;
    }

    h2, .h2 {
        font-size: 1.25rem;
    }
}

/* Extra small devices */
@media (max-width: 576px) {
    .stat-card .stat-value {
        font-size: 1rem;
    }

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

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

    /* Stack buttons vertically */
    .btn-group-vertical-xs {
        flex-direction: column;
    }

    .btn-group-vertical-xs .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    /* Compact badges */
    .badge {
        font-size: 0.65rem;
        padding: 0.2em 0.4em;
    }

    /* Login card */
    .login-card {
        padding: 1.5rem;
        margin: 0.5rem;
    }

    .login-card .logo i {
        font-size: 2rem;
    }

    .login-card .logo h1 {
        font-size: 1.2rem;
    }

    /* Install card */
    .install-card {
        padding: 1rem;
        margin: 0.5rem;
    }
}

/* Quick Actions */
.quick-action {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.quick-action:hover {
    background-color: #f8f9fa;
    transform: translateX(5px);
}

.quick-action i {
    font-size: 1.5rem;
    margin-right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal */
.modal-header {
    background-color: #f8f9fa;
}

/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

/* Ensure text wraps on small screens */
.text-break-mobile {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Small tables in modals */
.table-sm td {
    word-break: break-word;
    max-width: 200px;
}

@media (max-width: 576px) {
    .table-sm td {
        max-width: 150px;
        font-size: 0.85rem;
    }

    .table-sm td:first-child {
        width: 80px;
        min-width: 80px;
    }
}

/* Row and column fixes for mobile */
.row {
    margin-left: 0;
    margin-right: 0;
}

.row > * {
    max-width: 100%;
}

/* Prevent long content from overflowing */
.text-truncate-mobile {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Responsive flexbox utilities */
@media (max-width: 768px) {
    .flex-column-mobile {
        flex-direction: column !important;
    }

    .w-100-mobile {
        width: 100% !important;
    }

    .mb-2-mobile {
        margin-bottom: 0.5rem !important;
    }
}

/* Card action buttons responsive */
@media (max-width: 576px) {
    .card-header .btn,
    .card-header .btn-group {
        margin-top: 0.5rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .card-header .d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

/* Filter forms responsive */
@media (max-width: 768px) {
    .filter-form .row > div {
        margin-bottom: 0.5rem;
    }

    .filter-form .btn {
        width: 100%;
    }
}

/* Stats row responsive */
@media (max-width: 576px) {
    .stats-row .col-6,
    .stats-row .col-md-3 {
        padding: 0.25rem;
    }

    .stats-row .card-body {
        padding: 0.75rem;
    }
}

/* Lead detail modal responsive */
@media (max-width: 576px) {
    .modal-body .row > .col-md-6 {
        margin-bottom: 1rem;
    }

    .modal-body h6 {
        font-size: 0.9rem;
    }

    .modal-body p {
        font-size: 0.85rem;
    }
}

/* Action buttons in tables */
@media (max-width: 576px) {
    .btn-group-actions {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .btn-group-actions .btn {
        width: 100%;
    }
}

/* Navbar dropdown responsive */
@media (max-width: 768px) {
    .navbar-nav .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
    }
}

/* Footer responsive */
@media (max-width: 576px) {
    .footer {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
}

/* ========================================
   LEAD CARDS (Mobile View)
   ======================================== */

.lead-card {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.lead-card:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.lead-card.border-danger {
    border-left: 4px solid var(--danger-color) !important;
}

.lead-card.border-warning {
    border-left: 4px solid var(--warning-color) !important;
}

.lead-card .card-body {
    padding: 0.75rem !important;
}

.lead-card h6 {
    font-size: 0.95rem;
    line-height: 1.3;
}

.lead-card .badge {
    font-size: 0.7rem;
}

.lead-card .btn-group .btn {
    padding: 0.35rem 0.5rem;
}

.lead-card .btn-group .btn i {
    font-size: 0.9rem;
}

/* Ensure lead cards don't cause horizontal scroll */
@media (max-width: 991px) {
    .lead-card {
        max-width: 100%;
        overflow: hidden;
    }

    .lead-card .text-truncate {
        max-width: calc(100% - 20px);
    }

    .lead-card .btn-group {
        flex-wrap: nowrap;
    }

    .lead-card .btn-group .btn {
        padding: 0.25rem 0.4rem;
    }
}
