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


:root {
    --primary: #0066FF;
    --primary-dark: #0052CC;
    --secondary: #00D4FF;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg-dark: #0F172A;
    --bg-darker: #0A0F1E;
    --bg-card: #1E293B;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --border: #334155;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    /* Prevent horizontal scrolling of the whole page */
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--bg-darker);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo-section {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.nav-item:hover {
    background: rgba(0, 102, 255, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.2), rgba(0, 212, 255, 0.1));
    color: var(--text-primary);
    box-shadow: 0 0 20px rgba(0, 102, 255, 0.3);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-active {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.main-content {
    flex: 1;
    margin-left: 280px;
    background: var(--bg-dark);
}

.top-bar {
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-toggle {
    display: none;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    width: 400px;
    border: 1px solid var(--border);
}

.search-bar input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    width: 100%;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notification-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 0.75rem;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.notification-btn:hover {
    background: var(--bg-dark);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.page-content {
    display: none;
    padding: 2rem;
}

.page-content.active {
    display: block;
}

.page-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h2 {
    font-size: 2rem;
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 102, 255, 0.2);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon-blue {
    background: linear-gradient(135deg, rgba(0, 102, 255, 0.2), rgba(0, 212, 255, 0.1));
    color: var(--secondary);
}

.stat-icon-green {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));
    color: var(--success);
}

.stat-icon-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    color: #A78BFA;
}

.stat-icon-orange {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
    color: var(--warning);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stat-change {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: inline-block;
}

.stat-change.positive {
    color: var(--success);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 102, 255, 0.4);
}

.btn-secondary {
    background: var(--bg-darker);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Force minimum width to ensure data visibility */
}

.calls-table-container,
.clients-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
}

.apt-card-flex {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.apt-actions {
    display: flex;
    gap: 0.5rem;
}



.data-table th {
    text-align: left;
    padding: 1rem;
    background: var(--bg-darker);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
}

.data-table td {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(0, 102, 255, 0.05);
}

.settings-grid {
    display: grid;
    gap: 1.5rem;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
}

.settings-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.setting-item {
    margin-bottom: 1.5rem;
}

.setting-item label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.setting-item input,
.setting-item select,
.setting-item textarea {
    width: 100%;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 1rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

.filters-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 1rem;
}

.filter-group {
    flex: 1;
}

.filter-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.filter-group select {
    width: 100%;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text-primary);
}

.calendar-view {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 2rem;
}

.calendar-grid-container {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.calendar-header-day {
    text-align: center;
    font-weight: 600;
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.calendar-day {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.apt-details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}


.calendar-day.today {
    background: rgba(0, 102, 255, 0.1);
}

.calendar-day.today div {
    font-weight: 700;
    color: var(--secondary);
}

.calendar-day.selected {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 102, 255, 0.5);
    z-index: 1;
}

.calendar-day.selected div {
    color: white !important;
    font-weight: 700;
}

.calendar-day.selected .apt-dot {
    background: white !important;
}

.calendar-day.has-apt {
    border-color: var(--secondary);
}

.apt-dot {
    width: 6px;
    height: 6px;
    background: var(--secondary);
    border-radius: 50%;
    margin: 0.25rem auto 0;
}


.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.calendar-nav {
    background: var(--bg-darker);
    border: 1px solid var(--border);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.calendar-nav:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(0, 102, 255, 0.4);
}

.calendar-nav:active {
    transform: scale(0.95);
}

.calendar-nav svg {
    pointer-events: none;
}

.availability-grid {
    display: grid;
    gap: 1rem;
}

.day-schedule {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.day-schedule label {
    width: 120px;
}

.day-schedule input[type="time"] {
    width: 120px;
}

/* Animations avancées */
@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Appliquer les animations */
.stat-card {
    animation: scaleIn 0.4s ease-out;
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

.dashboard-card {
    animation: fadeIn 0.5s ease-out;
}

.page-content.active {
    animation: fadeIn 0.3s ease-out;
}

/* Effets de survol améliorés */
.call-item:hover,
.appointment-item:hover {
    background: rgba(0, 102, 255, 0.05);
    transform: translateX(5px);
    transition: all 0.3s ease;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 5px 15px rgba(0, 102, 255, 0.3);
}

.btn-secondary:hover {
    background: var(--bg-card);
    transform: translateY(-2px);
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Effet de focus pour les inputs */
.setting-item input:focus,
.setting-item select:focus,
.setting-item textarea:focus,
.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

/* Effet de loading */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 212, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--secondary);
    animation: spin 0.8s linear infinite;
}

/* Responsive design */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        margin-left: 240px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    /* Mobile Toggle & Overlay */
    .mobile-toggle {
        display: block;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        padding: 0.5rem;
        margin-right: 1rem;
    }

    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 95;
    }

    .mobile-overlay.active {
        display: block;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 10px 0 50px rgba(0, 0, 0, 0.5);
    }

    /* Amélioration de la lisibilité des tables sur mobile */
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    .page-header h2 {
        font-size: 1.5rem;
    }

    .filters-bar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .filter-group {
        width: 100%;
    }

    /* Appointment Cards stacking on mobile */
    .apt-card-flex {
        flex-direction: column !important;
        gap: 0.75rem;
        /* Reduced gap */
    }


    .apt-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        /* Stack buttons vertically */
        gap: 0.5rem;
        border-top: 1px solid var(--border);
        padding-top: 0.75rem;
    }

    .apt-actions button {
        width: 100%;
        /* Full width buttons */
    }


    /* Shrink calendar more on very small screens */
    .calendar-day {
        padding: 0.25rem;
        font-size: 0.75rem;
        min-height: 35px;
    }
}


@media (max-width: 480px) {
    html {
        font-size: 12px;
        /* Aggressive de-zoom */
    }


    .calendar-view {
        padding: 0.25rem;
        /* Minimum padding */
        margin-bottom: 0.75rem;
        /* Reduced bottom margin */
    }


    .calendar-grid-container {
        gap: 1px;
        max-width: 280px;
        /* Limit width to avoid stretching */
        margin: 0 auto;
    }

    .calendar-header-day {
        font-size: 0.6rem;
    }


    .calendar-day {
        padding: 2px;
        font-size: 0.7rem;
    }

    .page-content {
        padding: 0.5rem 0.25rem;
    }

    .top-bar {
        padding: 0.5rem 0.75rem;
    }

    .search-bar {
        display: none;
    }

    /* Shrink Appointment Cards height */
    .apt-card-flex {
        gap: 0.25rem !important;
    }

    .apt-details-grid {
        gap: 0.25rem !important;
        margin-top: 0.25rem !important;
    }

    .apt-actions {
        border-top: none !important;
        /* Remove border to pull up */
        padding-top: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        /* Back to row to save vertical space if possible, or stay column if user prefers but tighter */
        gap: 0.25rem !important;
    }

    .apt-actions button {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.7rem !important;
    }

    /* Standardize all cards and sections across all pages */
    .calendar-view,
    .dashboard-card,
    .stat-card,
    .settings-card,
    .filters-bar,
    .calls-table-container,
    .clients-table-container,
    .appointment-card {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
        margin-bottom: 0.75rem !important;
        overflow: hidden !important;
        /* Safety against internal overflow */
    }

    .calendar-grid-container {
        display: grid !important;
        grid-template-columns: repeat(7, 1fr) !important;
        gap: 2px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .calendar-day {
        min-width: 0 !important;
        padding: 2px !important;
    }

    .main-content {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .page-content {
        padding: 0.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }




    /* iOS Safe Areas */
    .top-bar {
        padding-top: max(1.5rem, env(safe-area-inset-top));
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Effet glassmorphism pour les cartes */
    .stat-card,
    .dashboard-card,
    .settings-card {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    /* Effet de brillance sur les boutons */
    .btn-primary::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.5s;
    }

    .btn-primary:hover::before {
        left: 100%;
    }

    .btn-primary {
        position: relative;
        overflow: hidden;
    }

    /* Amélioration des tables */
    .data-table tbody tr {
        animation: fadeIn 0.3s ease-out;
    }

    .data-table tbody tr:nth-child(odd) {
        background: rgba(0, 0, 0, 0.1);
    }

    /* Effet de pulsation pour les notifications */
    @keyframes pulse-notification {

        0%,
        100% {
            box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
        }

        50% {
            box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
        }
    }

    .notification-badge {
        animation: pulse-notification 2s infinite;
    }

    /* Style pour les tooltips */
    [data-tooltip] {
        position: relative;
        cursor: help;
    }

    [data-tooltip]::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: 100%;
        left: 50%;
        transform: translateX(-50%);
        padding: 0.5rem 1rem;
        background: var(--bg-darker);
        color: var(--text-primary);
        border: 1px solid var(--border);
        border-radius: 0.5rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }

    [data-tooltip]:hover::after {
        opacity: 1;
    }
}