:root {
    --primary: #4F46E5;   /* Indigo 600 */
    --secondary: #10B981; /* Emerald 500 */
    --accent: #F59E0B;    /* Amber 500 */
    --bg: #F3F4F6;        /* Gray 100 */
    --text: #111827;      /* Gray 900 */
    --text-muted: #6B7280; /* Gray 500 */
    --white: #FFFFFF;
    --error: #EF4444;     /* Red 500 */
    --success: #10B981;   /* Emerald 500 */
    --border: #E5E7EB;    /* Gray 200 */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

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

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

.main-content {
    flex: 1;
    padding: 40px 0;
}

.main-header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.logo {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--secondary);
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 30px;
}

.main-nav a {
    font-weight: 500;
    color: var(--text-muted);
    position: relative;
    font-size: 15px;
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--primary);
}

.main-nav a.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--secondary);
    border-radius: 3px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white) !important;
    padding: 10px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    border: 1px solid var(--primary);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background: #4338CA; /* darker indigo */
    border-color: #4338CA;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--white);
    color: var(--text) !important;
    padding: 10px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-weight: 600;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: #D1D5DB;
    transform: translateY(-1px);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    transition: var(--transition);
    color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.btn-logout {
    color: var(--error) !important;
    font-weight: 600;
}

.btn-logout:hover {
    opacity: 0.8;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    transition: var(--transition);
}

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #2a4d7a 100%);
    padding: 80px 0;
    text-align: center;
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(212, 165, 116, 0.1) 0%, transparent 50%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: 48px;
    color: var(--white);
    margin-bottom: 20px;
}

.hero p {
    font-size: 20px;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto 30px;
}

.hero-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.hero .btn-primary {
    background: var(--secondary);
}

.hero .btn-primary:hover {
    background: #c49464;
}

.hero .btn-secondary {
    background: transparent;
    border: 2px solid var(--white);
}

.hero .btn-secondary:hover {
    background: var(--white);
    color: var(--primary) !important;
}

.features {
    padding: 60px 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.dashboard-card, .profile-card, .feature-card, .messages-list, .chat-view, .search-filters {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: var(--transition);
}

.profile-card {
    padding: 0;
}

.profile-card:hover, .feature-card:hover {
    border-color: #A78BFA; /* Indigo 400 */
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.feature-icon {
    width: 64px;
    height: 64px;
    background: #EEF2FF; /* Indigo 50 */
    color: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 32px;
}

.feature-card h3 {
    margin-bottom: 12px;
}

.auth-container {
    max-width: 480px;
    margin: 40px auto;
    padding: 40px 32px;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 14px;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-error {
    color: var(--error);
    font-size: 14px;
    margin-top: 6px;
}

.form-success {
    color: #047857; /* Emerald 700 */
    font-size: 14px;
    margin-top: 6px;
    padding: 12px;
    background: #D1FAE5; /* Emerald 100 */
    border-radius: 6px;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin-top: 8px;
}

.btn-submit:hover {
    background: #4338CA;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
}

.auth-footer a:hover {
    color: var(--secondary);
}

.dashboard {
    padding: 40px 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.dashboard-card {
    background: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dashboard-card h2 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: var(--bg);
    border-radius: 10px;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    font-family: 'Poppins', sans-serif;
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
}

.search-filters {
    background: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.search-filters h2 {
    margin-bottom: 20px;
}

.filters-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

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

.profile-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.profile-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(30, 58, 95, 0.15);
}

.profile-image {
    height: 200px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(10px);
    transition: var(--transition);
}

.profile-card:hover .profile-image img {
    filter: blur(0);
}

.profile-avatar {
    font-size: 80px;
    color: var(--white);
    opacity: 0.8;
}

.profile-info {
    padding: 20px;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 5px;
    font-family: 'Poppins', sans-serif;
}

.profile-details {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 15px;
}

.profile-actions {
    display: flex;
    gap: 10px;
}

.online-indicator {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--white);
}

.offline-indicator {
    background: #ccc;
}

.messages-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    margin-bottom: 40px; /* Espace garanti avec le footer */
}

@media (max-width: 768px) {
    .messages-container {
        grid-template-columns: 1fr;
        margin-bottom: 20px;
        min-height: 400px;
    }
    
    .chat-view {
        flex: 1;
        min-height: 400px;
    }
}

.messages-list {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.messages-list h2 {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.message-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: var(--transition);
}

.message-item:hover,
.message-item.active {
    background: var(--bg);
}

.message-item.unread {
    background: rgba(212, 165, 116, 0.1);
}

.message-sender {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 5px;
}

.message-preview {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    font-size: 12px;
    color: #999;
}

.chat-view {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    max-width: 70%;
    padding: 15px;
    border-radius: 15px;
}

.chat-message.sent {
    background: var(--primary);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 3px;
}

.chat-message.received {
    background: var(--bg);
    align-self: flex-start;
    border-bottom-left-radius: 3px;
}

.chat-message .time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

.chat-input {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    background: #F9FAFB;
}

.chat-input textarea {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    max-height: 100px;
    background: var(--white);
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.chat-icon-btn, .send-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    color: var(--text-muted);
    transition: var(--transition);
}

.chat-icon-btn:hover, .send-btn:hover {
    color: var(--primary);
}

.send-btn {
    color: var(--primary);
    font-size: 28px;
}

#attachment-preview {
    padding: 0 12px 12px;
    background: #F9FAFB;
}

#attachment-preview img {
    max-width: 100px;
    max-height: 100px;
    border-radius: 8px;
    border: 1px solid var(--border);
}


.profile-edit {
    max-width: 700px;
    margin: 0 auto;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 30px;
}

.profile-avatar-large {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 60px;
    color: var(--white);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
}

.pagination a,
.pagination span {
    padding: 10px 16px;
    border-radius: 6px;
    background: var(--white);
    color: var(--primary);
    font-weight: 600;
}

.pagination a:hover {
    background: var(--primary);
    color: var(--white);
}

.pagination span {
    background: var(--secondary);
    color: var(--white);
}

.main-footer {
    background: var(--primary);
    color: var(--white);
    padding: 40px 0 20px;
    margin-top: auto;
    position: relative;
    z-index: 10;
}

body.has-messages .main-content {
    padding-bottom: 0;
}

body.has-messages .messages-container {
    margin-bottom: 30px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h3 {
    color: var(--white);
    margin-bottom: 15px;
}

.footer-section h4 {
    color: var(--secondary);
    margin-bottom: 15px;
    font-size: 18px;
}

.footer-section p {
    opacity: 0.8;
    line-height: 1.8;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section a {
    opacity: 0.8;
}

.footer-section a:hover {
    opacity: 1;
    color: var(--secondary);
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.6;
}

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-error {
    background: rgba(196, 91, 91, 0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.alert-success {
    background: rgba(91, 140, 90, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }

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

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

@media (max-width: 768px) {
    .header-content {
        padding: 10px 15px;
    }

    .logo {
        font-size: 22px;
    }

    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 20px;
        box-shadow: var(--shadow);
        gap: 15px;
    }

    .main-nav.active {
        display: flex;
    }

    .main-nav a {
        padding: 10px 0;
        border-bottom: 1px solid #eee;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .hero {
        padding: 50px 0;
    }

    .hero h1 {
        font-size: 28px;
        margin-bottom: 15px;
    }

    .hero p {
        font-size: 16px;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .hero-buttons a {
        width: 100%;
        max-width: 250px;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .feature-card {
        padding: 20px;
    }

    .auth-container {
        padding: 25px;
        margin: 20px 15px;
    }

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

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

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

    .profile-card {
        max-width: 350px;
        margin: 0 auto;
    }

    .search-filters {
        padding: 20px;
    }

    .filters-form {
        grid-template-columns: 1fr;
    }

    .messages-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 500px;
    }

    .messages-list {
        display: flex;
        flex-direction: column;
    }

    .chat-view {
        display: none;
        min-height: 100%;
    }

    .chat-view.active {
        display: flex;
    }

    .chat-header {
        flex-wrap: wrap;
        justify-content: center;
        padding: 15px;
    }

    .chat-header > div {
        width: 100%;
        text-align: center;
        order: 2;
    }

    .chat-header .back-btn {
        order: 1;
    }

    .chat-header span {
        order: 3;
        width: 100%;
    }

    .chat-messages {
        max-height: calc(100vh - 280px);
        padding: 15px;
    }

    .chat-message {
        max-width: 85%;
        padding: 12px;
    }

    .chat-input {
        flex-direction: column;
        padding: 15px;
        gap: 10px;
    }

    .chat-input input {
        order: 1;
    }

    .chat-input button {
        order: 2;
        width: 100%;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-edit form > div {
        margin-bottom: 15px;
    }

    .profile-avatar-large {
        width: 100px;
        height: 100px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer-section ul {
        padding: 0;
    }

    .footer-section {
        padding: 15px 0;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .pagination a,
    .pagination span {
        padding: 8px 12px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 24px;
    }

    .main-content {
        padding: 20px 0;
    }

    .dashboard-card {
        padding: 20px;
    }

    .stat-item {
        padding: 15px 10px;
    }

    .stat-number {
        font-size: 24px;
    }

    .profile-name {
        font-size: 18px;
    }

    .profile-image {
        height: 180px;
    }

    .btn-primary, .btn-secondary {
        padding: 10px 20px;
        font-size: 14px;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 12px;
        font-size: 14px;
    }

    .btn-submit {
        padding: 14px;
        font-size: 16px;
    }

    .toast-notification {
        left: 10px;
        right: 10px;
        transform: translateY(-100px);
    }

    .toast-notification.show {
        transform: translateY(0);
    }
}

.toast-notification {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--primary);
    color: var(--white);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    font-weight: 600;
}

.toast-notification.show {
    transform: translateX(0);
}

.location-message a {
    display: block;
    padding: 12px;
    background: #F9FAFB;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    transition: var(--transition);
}
.location-message a:hover {
    background: var(--white);
    border-color: var(--primary);
}
.location-message strong {
    display: block;
    color: var(--text);
}
.location-message span {
    font-size: 14px;
    color: var(--primary);
    text-decoration: underline;
}

.message-badge {
    background: var(--error);
    color: var(--white);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

.back-btn {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .messages-list {
        display: none;
    }

    .messages-list.active {
        display: block;
    }

    .chat-view {
        display: none;
    }

    .chat-view.active {
        display: flex;
    }
}