:root {
    --background: hsl(240, 15%, 8%);
    --foreground: hsl(0, 0%, 98%);
    --card: hsl(240, 15%, 10%);
    --card-foreground: hsl(0, 0%, 98%);
    --primary: hsl(270, 80%, 65%);
    --primary-foreground: hsl(0, 0%, 100%);
    --secondary: hsl(240, 10%, 15%);
    --secondary-foreground: hsl(0, 0%, 98%);
    --muted: hsl(240, 10%, 20%);
    --muted-foreground: hsl(240, 5%, 65%);
    --accent: hsl(280, 70%, 60%);
    --accent-foreground: hsl(0, 0%, 98%);
    --border: hsl(240, 10%, 20%);
    --input: hsl(240, 10%, 15%);
    --ring: hsl(270, 80%, 65%);

    --violet-glow: hsl(270, 80%, 55%);
    --gradient-hero: linear-gradient(135deg, hsl(270, 80%, 65%), hsl(280, 70%, 60%));
    --gradient-card: linear-gradient(145deg, hsl(240, 15%, 12%), hsl(240, 15%, 8%));
    --shadow-glow: 0 0 40px hsl(270, 80%, 65%, 0.3);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);

    --radius: 1rem;
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

a {
    text-decoration: none;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* NAVBAR */
/* Navbar styles handled by global.css */

/*BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    border: none;
}

.btn-primary {
    background: var(--gradient-hero);
    color: white;
    box-shadow: 0 4px 15px hsl(270, 80%, 65%, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px hsl(270, 80%, 65%, 0.5);
}

.btn-outline {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--secondary);
    border-color: var(--primary);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--foreground);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: hsl(240, 10%, 20%);
}




/*MAIN CONTENT*/
.main-content {
    padding-top: 6rem;
    padding-bottom: 4rem;
    min-height: calc(100vh - 400px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
 /   padding: 0 1rem;
}

@media (min-width: 1024px) {
    .container {
        padding: 0 2rem;
    }
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

@media (min-width: 1024px) {
    .page-title {
        font-size: 2.25rem;
    }
}

.text-gradient-violet {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    color: var(--muted-foreground);
    font-size: 1rem;
}

/* Search and Actions */
.search-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 640px) {
    .search-actions {
        flex-direction: row;
    }
}

.search-wrapper {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--foreground);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.search-input::placeholder {
    color: var(--muted-foreground);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsl(270, 80%, 65%, 0.2);
}

.create-btn {
    white-space: nowrap;
    background: linear-gradient(135deg, hsl(150, 60%, 45%), hsl(160, 60%, 40%));
    box-shadow: 0 4px 15px hsl(150, 60%, 45%, 0.4);
}

.create-btn:hover {
    box-shadow: 0 6px 25px hsl(150, 60%, 45%, 0.5);
    background: linear-gradient(135deg, hsl(150, 70%, 50%), hsl(160, 70%, 45%));
    transform: translateY(-2px);
}

/*COMMUNITIES GRID*/
.communities-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 0.25rem;
}

@media (min-width: 768px) {
    .communities-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .communities-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Community Card - Glass Card Style */
.community-card {
    background: var(--gradient-card);
    border: 1px solid hsl(270, 80%, 65%, 0.2);
    border-radius: 1.25rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.community-card:hover {
    transform: translateY(-4px);
    border-color: hsl(270, 80%, 65%, 0.4);
    box-shadow: var(--shadow-glow);
}

.community-content {
    padding: 1.5rem;
}

.community-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.community-avatar {
    width: 64px;
    height: 64px;
    border-radius: 0.75rem;
    background: var(--gradient-hero);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    overflow: hidden;
    flex-shrink: 0;
}

.community-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.community-info {
    flex: 1;
    min-width: 0;
}

.community-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.community-followers {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.community-followers svg {
    width: 16px;
    height: 16px;
}

.community-description {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

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

.community-actions .btn {
    flex: 1;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
}

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsla(240, 15%, 6%, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-elevated);
    overflow: hidden;
}

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

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted-foreground);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--foreground);
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--foreground);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsl(270, 80%, 65%, 0.1);
}

.modal-footer {
    padding: 1.5rem;
    background: hsla(240, 15%, 6%, 0.5);
    display: flex;
    gap: 1rem;
    border-top: 1px solid var(--border);
}

.modal-footer .btn {
    flex: 1;
}

/* ANIMATIONS */
@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

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

.animate-scale-in {
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.animate-fade-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* Media Queries for Navbar already handled or in global.css */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.custom-toast {
    background: rgba(30, 30, 45, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    min-width: 280px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    transition: opacity 0.5s ease;
}

/* Specific color for Success vs Info */
.custom-toast.success { border-left: 4px solid #10b981; }
.custom-toast.info { border-left: 4px solid #6366f1; }

.toast-title { color: white; font-weight: bold; display: block; }
.toast-message { color: #94a3b8; margin: 0; font-size: 0.9rem; }
.toast-close { background: none; border: none; color: white; cursor: pointer; }

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
/* Optional: Pause the disappear timer if the user hovers over the toast */
.custom-toast:hover {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

/* The container holding both buttons */
/* This ensures the container splits 50/50 regardless of section */
.community-actions {
    display: flex !important;
    gap: 12px !important;
    width: 100% !important;
    align-items: stretch !important;
}

/* Force the form to be exactly the same width as the link */
.community-actions > a,
.community-actions > .follow-form {
    flex: 1 1 0% !important; /* Forces equal 50% width */
    display: flex !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Force the buttons to be exactly the same height */
.action-btn {
    box-sizing: border-box !important;
    height: 44px !important; /* Pick a height and stick to it */
    width: 100% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 15px !important;
    border-radius: 10px !important;
    font-size: 0.95rem !important;
    line-height: 1 !important;
    border: 1px solid transparent !important;
}

/* ---- Community Profile Picture Upload Area ---- */
.comm-pic-upload-area {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100px;
    border: 2px dashed var(--border);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    background: var(--secondary);
    padding: 1rem;
}

.comm-pic-upload-area:hover {
    border-color: var(--primary);
    background: hsla(270, 80%, 65%, 0.05);
}

.comm-pic-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
    font-size: 0.85rem;
}

/* ---- My Communities page: search-actions spacing ---- */
.search-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
