/* Main Styles */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #3498db;
    --sidebar-active: #2980b9;
    --sidebar-submenu: #34495e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    overflow-x: hidden;
}

/* Sidebar */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    position: relative;
}

#sidebar {
    min-width: 250px;
    max-width: 250px;
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 999;
    background: var(--sidebar-bg);
    color: #fff;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    transform: translateX(0);
}

#sidebar.active {
    transform: translateX(250px);
    margin-right: -250px;
}

#content {
    width: calc(100% - 250px);
    margin-right: 250px;
    transition: all 0.3s ease;
    position: relative;
    min-height: 100vh;
}

#content.active {
    width: 100%;
    margin-right: 0;
}

/* Bouton pour basculer la barre latérale */
#sidebarCollapse {
    background-color: var(--info-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#sidebarCollapse:hover {
    background-color: #138496;
}

#sidebarCollapse i {
    font-size: 1.2rem;
}

.sidebar-header {
    padding: 15px;
    background: #1a2530;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebar ul.components {
    padding: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebar ul li {
    position: relative;
}

#sidebar ul li a {
    padding: 12px 15px;
    font-size: 1rem;
    display: block;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.3s;
    border-right: 3px solid transparent;
}

#sidebar ul li a:hover,
#sidebar ul li.hover > a {
    color: #fff;
    background: #34495e;
    border-right: 3px solid #3498db;
}

#sidebar ul li.active > a {
    color: #fff;
    background: #34495e;
    border-right: 3px solid #3498db;
}

/* Submenu styles */
#sidebar ul.components li ul.collapse,
#sidebar ul.components li ul.collapsing {
    background: #1a2530;
    padding-right: 15px;
}

#sidebar ul.components li ul.collapse li a,
#sidebar ul.components li ul.collapsing li a {
    padding: 10px 15px 10px 30px;
    font-size: 0.9rem;
    border-right: none;
}

#sidebar ul.components li ul.collapse li.active a,
#sidebar ul.components li ul.collapsing li.active a {
    border-right: 3px solid #3498db;
}

#sidebar ul.components li ul.collapse.show,
#sidebar ul.components li ul.collapsing.show {
    display: block;
}

/* Dropdown toggle icon */
#sidebar ul li a.dropdown-toggle::after {
    display: block;
    margin-right: 10px;
    content: "\f107";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    transition: transform 0.3s;
    float: left;
}

#sidebar ul li a.dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

/* RTL specific adjustments */
body {
    direction: rtl;
    text-align: right;
}

.me-2 {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

.ms-2 {
    margin-right: 0.5rem !important;
    margin-left: 0 !important;
}

.me-3 {
    margin-left: 1rem !important;
    margin-right: 0 !important;
}

.ms-3 {
    margin-right: 1rem !important;
    margin-left: 0 !important;
}

/* Content */
#content {
    width: 100%;
    min-height: 100vh;
    transition: all 0.3s;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #sidebar {
        margin-right: -250px;
    }
    
    #sidebar.active {
        margin-right: 0;
    }
    
    #content {
        width: 100%;
    }
    
    #sidebarCollapse {
        display: block;
    }
}

/* Transition effects */
#sidebar, #content, #sidebar ul li a {
    transition: all 0.3s ease;
}

/* Sidebar item badges */
#sidebar .badge {
    float: left;
    margin-top: 3px;
}

/* Cards */
.card {
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: transform 0.3s;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: bold;
    background-color: var(--primary-color);
    color: white;
}

.card-body {
    padding: 1.5rem;
}

.dashboard-card {
    text-align: center;
    padding: 20px;
    margin-bottom: 15px;
}

.dashboard-card i {
    font-size: 3rem;
    margin-bottom: 15px;
}

.dashboard-card .count {
    font-size: 2rem;
    font-weight: bold;
}

/* Forms */
.form-control {
    border-radius: 5px;
    padding: 10px;
}

.form-label {
    font-weight: bold;
}

/* Tables */
.table th {
    font-weight: bold;
    background-color: #f8f9fa;
}

.dataTables_wrapper .dataTables_filter {
    margin-bottom: 15px;
}

/* Buttons */
.btn {
    border-radius: 5px;
    padding: 8px 15px;
}

.btn-icon {
    padding: 5px 10px;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f5f5f5;
}

.login-form {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo img {
    max-height: 80px;
}

/* Profile Image */
.profile-img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 50%;
    border: 5px solid #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.profile-img-sm {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 50%;
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        margin-right: -250px;
    }
    
    #sidebar.active {
        margin-right: 0;
        position: fixed;
        z-index: 1000;
    }
    
    #sidebarCollapse span {
        display: none;
    }
    
    .dashboard-card i {
        font-size: 2rem;
    }
    
    .dashboard-card .count {
        font-size: 1.5rem;
    }
}

/* Print Styles */
@media print {
    #sidebar, .navbar, .no-print {
        display: none !important;
    }
    
    #content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* RTL specific adjustments */
.dropdown-menu-end {
    left: 0;
    right: auto;
}

/* Status badges */
.badge-active {
    background-color: var(--success-color);
    color: white;
}

.badge-expired {
    background-color: var(--danger-color);
    color: white;
}

.badge-expiring {
    background-color: var(--warning-color);
    color: black;
}

/* File upload preview */
.image-preview {
    max-width: 100%;
    max-height: 200px;
    margin-bottom: 10px;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Notifications */
.notification-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.notification-item:hover {
    background-color: #f8f9fa;
}

.notification-item.unread {
    background-color: #e6f7ff;
}

/* Custom switch for RTL */
.form-switch.form-switch-rtl {
    padding-right: 2.5em;
    padding-left: 0;
}

.form-switch.form-switch-rtl .form-check-input {
    margin-right: -2.5em;
    margin-left: 0;
}

/* Receipt Styling */
.receipt-container {
    padding: 20px;
    font-family: 'Arial', sans-serif;
    background-color: #fff;
}

.receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
}

.receipt-logo {
    max-width: 100px;
    max-height: 100px;
}

.receipt-title {
    text-align: center;
    flex-grow: 1;
}

.receipt-title h2 {
    margin-bottom: 5px;
    font-weight: bold;
}

.receipt-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.receipt-section {
    margin-bottom: 20px;
}

.receipt-section h5 {
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-weight: bold;
}

.receipt-table {
    width: 100%;
    border-collapse: collapse;
}

.receipt-table th, .receipt-table td {
    padding: 8px;
    text-align: right;
    border-bottom: 1px solid #eee;
}

.receipt-table th {
    width: 30%;
    font-weight: bold;
}

.receipt-photo {
    text-align: center;
    margin-top: 10px;
}

.receipt-photo img {
    max-width: 300px;
    max-height: 200px;
    border: 1px solid #ddd;
}

.receipt-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    margin-bottom: 20px;
}

.receipt-signature, .receipt-stamp {
    text-align: center;
    width: 40%;
}

.signature-line {
    margin-top: 50px;
    border-top: 1px solid #000;
}

.stamp-circle {
    margin: 20px auto;
    width: 100px;
    height: 100px;
    border: 1px dashed #000;
    border-radius: 50%;
}

.receipt-terms {
    margin-top: 20px;
    font-size: 0.9em;
    text-align: center;
    border-top: 1px solid #ddd;
    padding-top: 10px;
}

/* Timeline Styling */
.timeline {
    position: relative;
    padding-left: 30px;
    list-style: none;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-marker {
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: #0d6efd;
    left: -30px;
    top: 0;
}

.timeline-marker::before {
    content: '';
    position: absolute;
    width: 2px;
    height: calc(100% + 20px);
    background-color: #dee2e6;
    left: 6px;
    top: 15px;
}

.timeline-item:last-child .timeline-marker::before {
    display: none;
}

.timeline-content {
    padding-bottom: 10px;
}

.timeline-title {
    margin-bottom: 5px;
}

.timeline-date {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

/* Print Styles */
@media print {
    body * {
        visibility: hidden;
    }
    
    #receipt, #receipt * {
        visibility: visible;
    }
    
    #receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    
    .receipt-photo img {
        max-width: 200px;
    }
    
    .btn, .navbar, #sidebar {
        display: none !important;
    }
}

/* Dropdown Menu Styling */
#sidebar ul ul {
    background-color: #2c3e50;
}

#sidebar ul ul li.active a {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Subscription Status Badges */
.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-warning {
    background-color: var(--warning-color) !important;
    color: #212529;
}

.badge.bg-danger {
    background-color: var(--danger-color) !important;
}

/* WhatsApp Button */
.btn-whatsapp {
    background-color: #25D366;
    color: white;
}

.btn-whatsapp:hover {
    background-color: #128C7E;
    color: white;
}

/* Styles pour les appareils mobiles */
@media (max-width: 768px) {
    /* Styles pour le corps lorsque le sidebar est ouvert sur mobile */
    body.sidebar-open {
        overflow: hidden;
    }

    /* Styles pour la barre latérale sur mobile */
    #sidebar {
        width: 250px;
        min-width: 250px;
        max-width: 250px;
        position: fixed;
        top: 0;
        right: -250px; /* Commencer hors écran */
        height: 100vh;
        z-index: 1050;
        transition: all 0.3s ease;
        margin-right: 0;
        transform: none;
    }
    
    #sidebar.active {
        right: -250px; /* Caché */
        margin-right: 0;
        transform: none;
    }
    
    #sidebar:not(.active) {
        right: 0; /* Visible */
    }
    
    #content {
        width: 100%;
        margin-right: 0;
        transition: all 0.3s ease;
    }
    
    /* Overlay pour fermer le menu sur mobile quand il est ouvert */
    .sidebar-overlay {
        display: none;
        position: fixed;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        opacity: 0;
        transition: all 0.3s ease-in-out;
        top: 0;
        left: 0;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    /* Ajustements pour les petits écrans */
    .table-responsive {
        overflow-x: auto;
    }
    
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* Assurer que le bouton est toujours visible */
    #sidebarCollapse {
        position: relative;
        z-index: 1060;
    }
    
    /* Ajustements pour les tableaux sur mobile */
    .table th, .table td {
        white-space: nowrap;
    }
    
    /* Ajustements pour les formulaires sur mobile */
    .form-group {
        margin-bottom: 15px;
    }
    
    /* Ajustements pour les boutons sur mobile */
    .btn {
        margin-bottom: 5px;
    }
}
