/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1877f2;
    --secondary-color: #42b72a;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --dark-color: #1c1e21;
    --light-color: #f0f2f5;
    --text-color: #050505;
    --border-color: #dddfe2;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--light-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header Styles */
.main-header {
    background-color: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    background-color: white;
    padding: 8px 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand h1 {
    color: var(--primary-color);
    font-size: 24px;
}

.nav-search form {
    display: flex;
    background-color: var(--light-color);
    border-radius: 20px;
    overflow: hidden;
}

.nav-search input {
    border: none;
    padding: 8px 15px;
    width: 300px;
    background: transparent;
}

.nav-search button {
    background: transparent;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    color: #65676b;
}

.nav-menu ul {
    display: flex;
    list-style: none;
    gap: 20px;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.3s;
}

.nav-menu a:hover {
    background-color: var(--light-color);
}

.notification-badge {
    position: relative;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 12px;
}

.nav-toggle {
    display: none;
    font-size: 24px;
    cursor: pointer;
}

/* Auth Pages */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.auth-box {
    background: white;
    border-radius: 10px;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.auth-box h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.auth-box p {
    text-align: center;
    color: #65676b;
    margin-bottom: 30px;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.auth-form .checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-form .checkbox input {
    width: auto;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
}

.auth-link a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Alerts */
.alert {
    padding: 12px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #166fe5;
}

.btn-secondary {
    background-color: var(--light-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: #e4e6e9;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-small {
    padding: 5px 10px;
    font-size: 14px;
}

/* Posts */
.create-post {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.create-post textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    resize: none;
    margin-bottom: 10px;
}

.create-post input[type="file"] {
    margin-bottom: 10px;
}

.post {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.post-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.post-content {
    margin-bottom: 15px;
}

.post-content img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 10px;
}

.post-stats {
    display: flex;
    gap: 20px;
    padding: 10px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.post-actions {
    display: flex;
    gap: 10px;
}

.post-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 5px;
    font-size: 14px;
}

.post-actions button:hover {
    background-color: var(--light-color);
}

/* Comments */
.comments-section {
    margin-top: 15px;
}

.comments-section form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.comments-section input {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
}

.comment {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.comment img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.comment div {
    background-color: var(--light-color);
    padding: 8px 12px;
    border-radius: 18px;
    flex: 1;
}

/* Profile Page */
.profile-header {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.profile-cover {
    height: 200px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    position: relative;
}

.profile-avatar {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid white;
    background: white;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.change-photo-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary-color);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-info {
    text-align: center;
    padding: 70px 20px 20px;
}

.profile-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 20px 0;
}

.stat {
    text-align: center;
}

.stat .count {
    font-size: 20px;
    font-weight: bold;
    display: block;
}

.stat .label {
    color: #65676b;
}

.profile-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.profile-tabs {
    display: flex;
    gap: 10px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 5px;
    font-size: 16px;
}

.tab-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Messages */
.messages-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.messages-container .sidebar {
    background: white;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.messages-container .sidebar h2 {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.conversations-list {
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s;
    position: relative;
}

.conversation-item:hover {
    background-color: var(--light-color);
}

.conversation-item img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.conv-info {
    flex: 1;
}

.conv-info h4 {
    font-size: 16px;
    margin-bottom: 3px;
}

.last-message {
    font-size: 13px;
    color: #65676b;
}

.unread-badge {
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 12px;
    min-width: 20px;
    text-align: center;
}

/* Chat Area */
.chat-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

.back-btn {
    text-decoration: none;
    color: var(--primary-color);
    margin-right: 15px;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-user-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 70%;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.message-content {
    background-color: var(--light-color);
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
}

.message.sent .message-content {
    background-color: var(--primary-color);
    color: white;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

.chat-input {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: white;
}

.chat-input form {
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
}

/* Search */
.search-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.search-form {
    margin: 20px 0;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-box input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
}

.search-filters {
    display: flex;
    gap: 20px;
}

.user-result {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
}

.user-result img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    flex: 1;
}

/* Footer */
.main-footer {
    background: white;
    padding: 40px 0 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h3,
.footer-section h4 {
    margin-bottom: 15px;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section a {
    text-decoration: none;
    color: #65676b;
    transition: color 0.3s;
}

.footer-section a:hover {
    color: var(--primary-color);
}

.social-links {
    display: flex;
    gap: 15px;
}

.social-links a {
    font-size: 20px;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    color: #65676b;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-search {
        display: none;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        padding: 20px;
        box-shadow: var(--shadow);
    }
    
    .nav-menu.active {
        display: block;
    }
    
    .nav-menu ul {
        flex-direction: column;
    }
    
    .nav-toggle {
        display: block;
    }
    
    .messages-container {
        grid-template-columns: 1fr;
    }
    
    .messages-container .sidebar {
        display: none;
    }
    
    .profile-stats {
        gap: 20px;
    }
    
    .post-actions {
        flex-wrap: wrap;
    }
}

/* Loading States */
.loading {
    text-align: center;
    padding: 20px;
}

.loading-spinner {
    border: 3px solid var(--light-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s forwards;
    border-left: 4px solid;
}

.toast.success { border-left-color: #42b72a; }
.toast.error { border-left-color: #dc3545; }
.toast.warning { border-left-color: #ffc107; }
.toast.info { border-left-color: #1877f2; }

.toast i { font-size: 24px; }
.toast.success i { color: #42b72a; }
.toast.error i { color: #dc3545; }
.toast.warning i { color: #ffc107; }
.toast.info i { color: #1877f2; }

.toast-content { flex: 1; }
.toast-message { font-size: 14px; color: #65676b; }
.toast-close {
    cursor: pointer;
    color: #65676b;
    font-size: 18px;
}
.toast-close:hover { color: #1c1e21; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(100%); }
}