:root {
    --twitter-blue: #1d9bf0;
    --twitter-blue-hover: #1a8cd8;
    --bg-color: #ffffff;
    --border-color: #eff3f4;
    --text-main: #0f1419;
    --text-muted: #536471;
    --sidebar-width: 275px;
    --right-sidebar: 350px;
    --error-bg: #ffdbe0;
    --error-text: #f4212e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Cairo', sans-serif;
    color: var(--text-main);
    direction: rtl;
    text-align: right;
}

.app-layout {
    display: flex;
    max-width: 1250px;
    margin: 0 auto;
    min-height: 100vh;
}

/* SIDEBAR LEFT */
.sidebar-left {
    width: var(--sidebar-width);
    padding: 0 12px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { padding: 12px; }
.brand-logo { width: 30px; fill: var(--twitter-blue); }

.sidebar-nav { flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 20px;
    border-radius: 99px;
    margin-bottom: 4px;
    transition: background 0.2s;
}
.nav-item:hover { background: rgba(15, 20, 25, 0.1); }
.nav-item.active { font-weight: 700; }
.nav-icon { margin-right: 16px; }

.user-profile-summary {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 99px;
    cursor: pointer;
}
.user-profile-summary:hover { background: rgba(15, 20, 25, 0.1); }
.user-profile-summary img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.user-details { margin-left: 12px; }
.user-name { font-weight: 700; font-size: 15px; }
.user-city { color: var(--text-muted); font-size: 15px; }

/* MAIN CONTENT */
.main-content {
    flex: 1;
    min-width: 0;
}

.feed-header {
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    height: 53px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    z-index: 5;
}
.feed-header h2 { font-size: 20px; font-weight: 700; }

.search-bar-container { padding: 12px 16px; border-bottom: 1px solid var(--border-color); }
.search-bar-container input {
    width: 100%;
    background: #eff3f4;
    border: none;
    padding: 12px 20px;
    border-radius: 99px;
    font-size: 15px;
}
.search-bar-container input:focus { outline: 2px solid var(--twitter-blue); background: #fff; }

.create-post-placeholder {
    padding: 16px;
    display: flex;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}
.create-post-placeholder img { width: 48px; height: 48px; border-radius: 50%; margin-right: 12px; }
.input-mimic { color: var(--text-muted); font-size: 20px; flex: 1; padding-top: 8px; }

.room-tweet {
    padding: 12px 16px;
    display: flex;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}
.room-tweet:hover { background: #f7f7f7; }
.tweet-avatar { width: 48px; height: 48px; border-radius: 50%; margin-right: 12px; flex-shrink: 0; }
.tweet-content { flex: 1; }
.tweet-meta { font-size: 15px; margin-bottom: 2px; }
.tweet-author { font-weight: 700; }
.tweet-handle { color: var(--text-muted); margin-left: 4px; }
.tweet-dot { color: var(--text-muted); margin: 0 4px; }
.tweet-time { color: var(--text-muted); }

.room-tweet-title { font-size: 15px; font-weight: 400; margin-bottom: 12px; line-height: 1.3; }
.room-tweet-stats {
    display: flex;
    gap: 20px;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

.tweet-actions { display: flex; gap: 8px; }
.btn-tweet-action {
    background: var(--twitter-blue);
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}
.btn-tweet-action.outline { background: #fff; border: 1px solid var(--border-color); color: var(--text-muted); }
.btn-tweet-action.danger { background: #fee; color: #f42; }

/* TABS & SOCIAL */
.feed-tabs { display: flex; border-bottom: 1px solid var(--border-color); }
.tab-btn { flex: 1; padding: 16px; border: none; background: none; cursor: pointer; font-weight: 700; font-size: 15px; color: var(--text-muted); transition: background 0.2s; }
.tab-btn:hover { background: rgba(15, 20, 25, 0.1); }
.tab-btn.active { color: var(--text-main); border-bottom: 4px solid var(--twitter-blue); }

.friend-results-popup { position: absolute; background: #fff; width: 300px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-radius: 8px; z-index: 20; display: none; }
.friend-item { padding: 12px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }

/* SIDEBAR RIGHT */
.sidebar-right {
    width: var(--right-sidebar);
    padding: 12px 20px;
    border-left: 1px solid var(--border-color);
}
.trending-panel {
    background: #f7f9f9;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}
.trending-panel h3 { margin-bottom: 16px; }
.trend-item { padding: 12px 0; border-bottom: 1px solid #eee; font-weight: 700; color: var(--twitter-blue); cursor: pointer; }

/* CHAT ROOM INTERFACE */
.chat-header-twitter {
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    height: 53px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0; background: #fff; z-index: 5;
}
.header-back a { font-size: 24px; text-decoration: none; color: var(--text-main); margin-left: 20px; }
.header-info h3 { font-size: 18px; }
.header-info p { font-size: 13px; color: var(--text-muted); }
.header-more { margin-right: auto; }

.chat-feed { 
    padding: 12px;
    min-height: calc(100vh - 120px);
    padding-bottom: 200px; /* Space for input */
}
.chat-input-area {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 100%;
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    z-index: 100;
}
@media (max-width: 600px) {
    .chat-input-area { width: 100%; }
}
.chat-input-area form { 
    display: flex; 
    width: 100%; 
    align-items: flex-end; 
    gap: 12px; 
}
.chat-input-area img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.chat-input-area textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 20px;
    background: #f8f9fa;
    resize: none;
    font-size: 16px;
    max-height: 150px;
}
.chat-input-area button {
    background: var(--twitter-blue);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 99px;
    font-weight: 700;
    cursor: pointer;
    min-width: 80px;
}
.chat-input-area button:disabled { opacity: 0.5; }

/* MODALS */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    display: none; z-index: 100;
    justify-content: center; align-items: flex-start; padding-top: 80px;
}
.modal.active { display: flex; }
.modal-card { background: #fff; width: 600px; border-radius: 16px; }
.modal-top { padding: 12px; display: flex; justify-content: space-between; align-items: center; }
.modal-inner { padding: 12px 16px 20px; }

/* AUTH BOX */
.auth-page { background: #fff; }
.auth-box { max-width: 600px; margin: 40px auto; padding: 20px; }
.auth-header { text-align: center; margin-bottom: 20px; }
.auth-header .brand-logo { margin-bottom: 12px; }
.input-wrap { margin-bottom: 20px; }
.input-wrap input, .input-wrap select {
    width: 100%;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 4px;
    font-size: 16px;
}
.btn-twitter { width: 100%; background: #000; color: #fff; border: none; padding: 12px; border-radius: 99px; font-weight: 700; font-size: 16px; }
.btn-twitter-sm { background: var(--twitter-blue); color: #fff; border: none; padding: 8px 16px; border-radius: 99px; font-weight: 700; }

@media (max-width: 1000px) {
    .sidebar-right { display: none; }
    .sidebar-left { width: 88px; }
    .nav-label, .user-details { display: none; }
}
@media (max-width: 600px) {
    .sidebar-left { display: none; }
    .chat-input-area { width: 100%; }
}
