:root {
    /* Modern Color Palette */
    --sw-primary: #4F46E5; /* Indigo 600 */
    --sw-primary-hover: #4338CA; /* Indigo 700 */
    --sw-secondary: #64748B; /* Slate 500 */
    --sw-bg-page: #F8FAFC; /* Slate 50 */
    --sw-bg-card: #FFFFFF;
    --sw-text-main: #1E293B; /* Slate 800 */
    --sw-text-muted: #64748B; /* Slate 500 */
    --sw-border: #E2E8F0; /* Slate 200 */
    --sw-success: #10B981; /* Emerald 500 */
    --sw-danger: #EF4444; /* Red 500 */
    --sw-warning: #F59E0B; /* Amber 500 */
    
    /* Shadows */
    --sw-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --sw-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --sw-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --sw-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Radius */
    --sw-radius-md: 0.5rem; /* 8px */
    --sw-radius-lg: 1rem;   /* 16px */
    --sw-radius-xl: 1.5rem; /* 24px */
    
    /* Transitions */
    --sw-trans: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* -------------------------------------------
   Global Reset & Wrapper
------------------------------------------- */
.stories-wall-wrapper {
    width: 100%;
    max-width: 1440px; /* Increased Max Width for better desktop usage */
    margin: 40px auto;
    padding: 0 24px;
    font-family: 'Cairo', system-ui, -apple-system, sans-serif;
    direction: rtl; /* Force RTL */
    color: var(--sw-text-main);
    line-height: 1.6;
    background-color: transparent;
}

.stories-wall-wrapper *, 
.stories-wall-wrapper *::before, 
.stories-wall-wrapper *::after {
    box-sizing: border-box;
}

/* Override Theme Constraints */
.stories-wall-wrapper #main,
.stories-wall-wrapper .site-main,
.stories-wall-wrapper .content-area {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

.stories-wall-wrapper a {
    text-decoration: none;
    color: inherit;
    transition: var(--sw-trans);
}

/* -------------------------------------------
   Layout Structure
------------------------------------------- */
.sw-main-layout {
    display: grid;
    /* Main Content (Flexible) | Sidebar (Fixed 300px) */
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 32px; /* Optimized gap */
    align-items: start;
}

/* Responsive Layout */
@media (max-width: 1024px) {
    .sw-main-layout {
        grid-template-columns: 1fr; /* Stack on smaller screens */
    }
    
    .sw-sidebar-section {
        order: 2; /* Sidebar below content on mobile */
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Sidebar widgets grid */
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .stories-wall-wrapper {
        padding: 0 16px;
        margin: 24px auto;
    }
    
    .sw-sidebar-section {
        grid-template-columns: 1fr; /* Stack widgets on phones */
    }
}

/* -------------------------------------------
   Stories Grid
------------------------------------------- */
.stories-wall-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Story Card */
.story-card {
    background: var(--sw-bg-card);
    border-radius: var(--sw-radius-lg);
    border: 1px solid var(--sw-border);
    box-shadow: var(--sw-shadow-sm);
    transition: var(--sw-trans);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.story-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--sw-shadow-hover);
    border-color: var(--sw-primary);
}

/* Card Image */
.story-image {
    position: relative;
    padding-top: 60%; /* Aspect Ratio 16:9 approx */
    overflow: hidden;
    background-color: var(--sw-bg-page);
}

.story-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.story-card:hover .story-image img {
    transform: scale(1.05);
}

/* Card Content */
.story-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.story-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    line-height: 1.4;
    color: var(--sw-text-main);
}

.story-title a:hover {
    color: var(--sw-primary);
}

.story-meta {
    font-size: 0.875rem;
    color: var(--sw-text-muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.story-author {
    font-weight: 600;
    color: var(--sw-secondary);
}

.story-summary {
    font-size: 0.95rem;
    color: var(--sw-text-muted);
    margin-bottom: 24px;
    line-height: 1.6;
    flex-grow: 1; /* Push footer down */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card Footer */
.story-footer {
    padding-top: 16px;
    border-top: 1px solid var(--sw-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.story-engagement {
    display: flex;
    gap: 16px;
    color: var(--sw-text-muted);
}

.story-engagement span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sw-read-more {
    color: var(--sw-primary);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sw-read-more:hover {
    color: var(--sw-primary-hover);
    gap: 8px; /* Arrow animation */
}

/* -------------------------------------------
   Single Story Footer (Interactions, Share, Author)
------------------------------------------- */
.sw-single-footer {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid var(--sw-border);
}

/* Interaction Buttons */
.sw-interaction-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    margin-bottom: 48px;
}

.sw-interaction-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.sw-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: var(--sw-radius-full);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--sw-trans);
    border: none;
    box-shadow: var(--sw-shadow-sm);
}

.sw-like-btn {
    background: #FFF1F2; /* Rose 50 */
    color: #E11D48; /* Rose 600 */
}

.sw-like-btn:hover {
    background: #FFE4E6; /* Rose 100 */
    transform: translateY(-2px);
    box-shadow: var(--sw-shadow-md);
}

.sw-comment-btn {
    background: #EFF6FF; /* Blue 50 */
    color: #2563EB; /* Blue 600 */
}

.sw-comment-btn:hover {
    background: #DBEAFE; /* Blue 100 */
    transform: translateY(-2px);
    box-shadow: var(--sw-shadow-md);
}

.sw-count {
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: var(--sw-radius-md);
    font-size: 0.85rem;
}

/* Share Section */
.sw-share-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.sw-share-label {
    font-weight: 600;
    color: var(--sw-text-muted);
    font-size: 0.95rem;
}

.sw-share-icons {
    display: flex;
    gap: 12px;
}

.sw-share-link {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--sw-trans);
    box-shadow: var(--sw-shadow-sm);
}

.sw-share-link:hover {
    transform: translateY(-3px);
    box-shadow: var(--sw-shadow-md);
}

.sw-share-link.whatsapp { background: #25D366; }
.sw-share-link.twitter { background: #000000; }
.sw-share-link.facebook { background: #1877F2; }
.sw-share-link.telegram { background: #0088CC; }

/* Author Card */
.sw-author-card {
    background: #F8FAFC; /* Slate 50 */
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius-xl);
    padding: 32px;
    display: flex;
    align-items: flex-start;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

.sw-author-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--sw-primary), var(--sw-secondary));
}

@media (max-width: 640px) {
    .sw-author-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 24px;
    }
}

.sw-author-avatar-large {
    width: 80px;
    height: 80px;
    background: var(--sw-primary);
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--sw-shadow-md);
    border: 4px solid white;
}

.sw-author-content {
    flex-grow: 1;
}

.sw-author-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0 0 12px 0;
    color: var(--sw-text-main);
}

.sw-author-bio {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--sw-text-muted);
    margin-bottom: 20px;
}

.author-highlight {
    color: var(--sw-text-main);
    font-weight: 700;
}

.sw-author-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--sw-primary);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 16px;
    border: 1px solid var(--sw-primary);
    border-radius: var(--sw-radius-full);
    transition: var(--sw-trans);
    background: white;
}

.sw-author-btn:hover {
    background: var(--sw-primary);
    color: white;
    gap: 12px;
}
.sw-single-story-card {
    background: var(--sw-bg-card);
    border-radius: var(--sw-radius-xl);
    box-shadow: var(--sw-shadow-md);
    padding: 40px;
    margin-bottom: 40px;
    border: 1px solid var(--sw-border);
}

@media (max-width: 768px) {
    .sw-single-story-card {
        padding: 24px;
        border-radius: var(--sw-radius-lg);
    }
}

.sw-single-header {
    margin-bottom: 32px;
    text-align: center;
}

.sw-single-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 24px 0;
    color: var(--sw-text-main);
    line-height: 1.2;
}

@media (max-width: 768px) {
    .sw-single-title {
        font-size: 1.75rem;
    }
}

.sw-single-image {
    margin: -40px -40px 32px -40px; /* Bleed to edges */
    border-radius: var(--sw-radius-xl) var(--sw-radius-xl) 0 0;
    overflow: hidden;
    max-height: 500px;
}

@media (max-width: 768px) {
    .sw-single-image {
        margin: -24px -24px 24px -24px;
        border-radius: var(--sw-radius-lg) var(--sw-radius-lg) 0 0;
        max-height: 300px;
    }
}

.sw-single-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sw-author-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.sw-avatar-placeholder {
    width: 48px;
    height: 48px;
    background: var(--sw-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
}

.sw-author-text {
    text-align: right;
}

.sw-author-name {
    display: block;
    font-weight: 700;
    color: var(--sw-text-main);
}

.sw-post-date {
    display: block;
    font-size: 0.85rem;
    color: var(--sw-text-muted);
}

.sw-single-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--sw-text-main);
}

.sw-single-content p {
    margin-bottom: 1.5em;
}

/* -------------------------------------------
   Submission Form
------------------------------------------- */
.stories-wall-form-wrapper {
    background: var(--sw-bg-card);
    padding: 40px;
    border-radius: var(--sw-radius-xl);
    box-shadow: var(--sw-shadow-lg);
    border: 1px solid var(--sw-border);
    max-width: 800px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .stories-wall-form-wrapper {
        padding: 24px;
    }
}

.stories-wall-instructions {
    background: #EFF6FF; /* Light blue bg */
    border: 1px solid #BFDBFE;
    color: #1E40AF;
    padding: 20px;
    border-radius: var(--sw-radius-md);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.stories-wall-field {
    margin-bottom: 24px;
}

.stories-wall-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--sw-text-main);
}

.stories-wall-field input[type="text"],
.stories-wall-field input[type="email"],
.stories-wall-field input[type="url"],
.stories-wall-field select,
.stories-wall-field textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius-md);
    font-size: 1rem;
    transition: var(--sw-trans);
    background-color: #FAFAFA;
    font-family: inherit;
}

.stories-wall-field input:focus,
.stories-wall-field select:focus,
.stories-wall-field textarea:focus {
    outline: none;
    border-color: var(--sw-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); /* Indigo glow */
    background-color: white;
}

.stories-wall-submit-btn {
    background: var(--sw-primary);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--sw-radius-full);
    cursor: pointer;
    transition: var(--sw-trans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.stories-wall-submit-btn:hover {
    background: var(--sw-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--sw-shadow-md);
}

/* -------------------------------------------
   Sidebar Widgets
------------------------------------------- */
.sw-sidebar-section .widget {
    background: var(--sw-bg-card);
    padding: 24px;
    border-radius: var(--sw-radius-lg);
    border: 1px solid var(--sw-border);
    box-shadow: var(--sw-shadow-sm);
    margin-bottom: 30px;
}

.sw-sidebar-section .widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--sw-border);
    color: var(--sw-text-main);
    position: relative;
}

.sw-sidebar-section .widget-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: 0; /* RTL alignment */
    width: 60px;
    height: 2px;
    background: var(--sw-primary);
}

.sw-sidebar-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sw-sidebar-section ul li {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--sw-border);
}

.sw-sidebar-section ul li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.sw-sidebar-section ul li a {
    color: var(--sw-text-main);
    font-weight: 500;
    display: block;
    transition: var(--sw-trans);
}

.sw-sidebar-section ul li a:hover {
    color: var(--sw-primary);
    padding-right: 8px; /* RTL nudge */
}

/* -------------------------------------------
   Section Header
------------------------------------------- */
.sw-section-header {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sw-section-header h3 {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0;
    color: var(--sw-text-main);
    position: relative;
    padding-right: 20px;
}

.sw-section-header h3::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 30px;
    background: var(--sw-primary);
    border-radius: 4px;
}

/* -------------------------------------------
   Home Button
------------------------------------------- */
.sw-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius-full);
    font-weight: 600;
    color: var(--sw-text-main);
    margin-bottom: 30px;
    box-shadow: var(--sw-shadow-sm);
}

.sw-home-btn:hover {
    background: var(--sw-bg-page);
    color: var(--sw-primary);
    border-color: var(--sw-primary);
}

/* -------------------------------------------
   Leaderboard / Top Writers
------------------------------------------- */
.stories-wall-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sw-promoter-item {
    background: var(--sw-bg-card);
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius-lg);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--sw-trans);
}

.sw-promoter-item:hover {
    border-color: var(--sw-primary);
    transform: translateX(-5px); /* Slide left slightly for RTL feel */
    box-shadow: var(--sw-shadow-sm);
}

.sw-promoter-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sw-promoter-rank {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--sw-primary);
    width: 40px;
    text-align: center;
    line-height: 1;
}

.sw-promoter-details {
    display: flex;
    flex-direction: column;
}

.sw-promoter-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--sw-text-main);
}

.sw-promoter-link-small {
    font-size: 0.85rem;
    color: var(--sw-primary);
    margin-top: 4px;
}

.sw-promoter-stats {
    background: #FEF3C7; /* Amber 100 */
    color: #D97706; /* Amber 600 */
    padding: 8px 16px;
    border-radius: var(--sw-radius-full);
    font-weight: 700;
    font-size: 1rem;
}

/* -------------------------------------------
   Pagination
------------------------------------------- */
.sw-pagination {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.sw-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius-md);
    background: white;
    color: var(--sw-text-main);
    font-weight: 600;
    transition: var(--sw-trans);
}

.sw-pagination .page-numbers.current,
.sw-pagination .page-numbers:hover {
    background: var(--sw-primary);
    color: white;
    border-color: var(--sw-primary);
}
