body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    justify-content: center;
    align-items: flex-start; 
    min-height: 100vh;
    margin: 0;
    padding: 100px 20px 40px; 
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease; 
}

/* =========================================
   CONTAINERS (Unified)
   ========================================= */
.login-container, .register-container, .welcome-container, .panel-container, .logout-container, .success-container, .error-container, .profile-container {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* Specific Container Widths & Alignments */
.login-container, .success-container, .error-container { max-width: 350px; text-align: center; }
.register-container, .logout-container, .welcome-container { max-width: 400px; }

/* Panel Container Flex Layout */
.panel-container, .profile-container { max-width: 500px; display: flex; flex-direction: column; align-items: center; }
.panel-container form, .profile-container .profile-details { width: 100%; }

.welcome-container { padding: 40px 60px; text-align: center; }
.logout-container { text-align: center; }

/* =========================================
   TYPOGRAPHY
   ========================================= */
h1, h2, h3 { color: #333; margin-top: 0; text-align: center; width: 100%; }
h1 { margin-bottom: 10px; }
h2 { margin-bottom: 24px; }
.panel-container h2, .profile-container h2 { border-bottom: 2px solid #f0f2f5; padding-bottom: 15px; }

/* Error & Success Messages */
.error-container h3 { color: #cc0000; margin-bottom: 15px; font-size: 22px; }
.success-container h3 { color: #28a745; margin-bottom: 15px; font-size: 22px; }

p, .error-container p, .success-container p { color: #555; font-size: 16px; }
.welcome-container p { margin-bottom: 30px; }
.logout-container p { margin-bottom: 20px; }
.error-container p, .success-container p { margin-bottom: 25px; }

/* =========================================
   FORMS & INPUTS
   ========================================= */
.form-group { margin-bottom: 20px; text-align: left; width: 100%; }
label { display: block; margin-bottom: 8px; font-weight: 600; color: #555; text-align: left; }
input[type="text"], input[type="email"], input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
    transition: all 0.3s ease;
    background-color: #fff;
    color: #333;
}
input:focus { border-color: #0066cc; outline: none; box-shadow: 0 0 5px rgba(0, 102, 204, 0.2); }

/* =========================================
   BUTTONS & LINKS
   ========================================= */
button, .submit-btn, .btn {
    display: block; width: 100%; padding: 12px; background-color: #0066cc; color: #fff;
    border: none; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer;
    transition: background-color 0.3s ease; text-decoration: none; text-align: center;
    box-sizing: border-box; font-family: inherit;
}
button:hover, .submit-btn:hover, .btn:hover { background-color: #005bb5; }

.btn-container { display: flex; flex-direction: column; gap: 10px; justify-content: center; margin-top: 30px; width: 100%; }
@media (min-width: 400px) { .btn-container { flex-direction: row; } }

.welcome-container .btn-container { margin-top: 0; }
.logout-container .btn { margin-top: 10px; padding: 10px 20px; display: inline-block; width: auto; }
.btn-container .btn { flex: 1; width: auto; padding: 10px 20px; }

.logout-btn { background-color: #cc0000 !important; }
.logout-btn:hover { background-color: #a30000 !important; }

.register-link { display: block; text-align: center; margin-top: 20px; color: #0066cc; text-decoration: none; font-size: 14px; }
.register-link:hover { text-decoration: underline; }

.remember-me {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 5px;
    margin-bottom: 20px;
}
.remember-me input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    padding: 0;
    accent-color: #0066cc;
    cursor: pointer;
    display: inline-block;
    flex-shrink: 0;
}
.remember-me label {
    margin: 0;
    padding: 0;
    font-weight: 500;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    display: inline-block;
    flex-shrink: 0;
}


/* Details (User Panel) */
.info-group { margin-bottom: 15px; font-size: 16px; color: #555; text-align: left; width: 100%; }
.info-group strong { color: #333; display: inline-block; width: 100px; }

/* =========================================
   NAVBAR
   ========================================= */
.navbar {
    position: fixed; top: 0; left: 0; width: 100%; background-color: #0066cc; color: white;
    padding: 15px 20px; box-sizing: border-box; display: flex; justify-content: space-between;
    align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1); z-index: 1000; transition: background-color 0.3s ease;
}
.nav-brand { font-size: 20px; font-weight: bold; }
.nav-links { display: flex; align-items: center; gap: 15px; }
.nav-links a { color: white; text-decoration: none; font-size: 16px; transition: opacity 0.3s; }
.nav-links a:hover { opacity: 0.8; }

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.2); border: none; color: white; padding: 6px 12px;
    border-radius: 20px; cursor: pointer; font-size: 14px; font-weight: bold; display: flex;
    align-items: center; gap: 5px; transition: background 0.3s ease; width: auto;
}
.theme-toggle-btn:hover { background: rgba(255, 255, 255, 0.3); }

/* =========================================
   PROFILE PICTURE & FILE UPLOAD
   ========================================= */
.profile-picture-container { position: relative; width: 150px; height: 150px; margin-bottom: 30px; text-align: center; }
.profile-picture-container img {
    width: 150px; height: 150px; border-radius: 50%; object-fit: cover; border: 4px solid #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15); transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    background-color: #f8f9fa; display: block;
}
.profile-picture-container img:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(0, 102, 204, 0.25); }

.file-upload-wrapper { position: relative; overflow: hidden; display: inline-block; width: 100%; margin-top: 5px; }
.file-upload-wrapper input[type=file] { font-size: 100px; position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer; height: 100%; }
.file-upload-btn {
    display: flex; align-items: center; justify-content: center; padding: 10px 15px; background-color: #f8f9fa;
    border: 2px dashed #d1d5db; border-radius: 6px; color: #495057; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all 0.3s ease; text-align: center; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; width: 100%; box-sizing: border-box;
}
.file-upload-wrapper:hover .file-upload-btn { background-color: #e9ecef; border-color: #0066cc; color: #0066cc; }
.file-upload-btn.file-selected { background-color: #e6f2fc; border: 2px solid #0066cc; color: #0066cc; font-weight: 600; }

.progress-container { display: none; width: 100%; background-color: #e9ecef; border-radius: 6px; margin-top: 15px; overflow: hidden; }
.progress-bar { width: 0%; height: 8px; background-color: #28a745; transition: width 0.2s ease; }
.upload-status-text { text-align: center; font-size: 13px; color: #555; margin-top: 5px; }
.upload-success-msg { display: none; text-align: center; font-size: 15px; font-weight: 600; margin-top: 10px; }

/* =========================================
   ANIMATIONS
   ========================================= */
.spinner {
    margin: 20px auto; width: 36px; height: 36px; border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc; border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* =========================================
   TWEETS SECTION
   ========================================= */
.tweets-section {
    width: 100%;
    margin-top: 30px;
    box-sizing: border-box;
}
.tweets-section h3 {
    text-align: left;
    font-size: 18px;
    color: #444;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.tweets-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.tweet-card {
    background: #fdfdfd;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    padding: 18px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
}
.tweet-card:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); 
}
.tweet-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 12px; 
    font-size: 14px; 
}
.tweet-header strong { 
    color: #333; 
    font-size: 15px;
}
.tweet-time { 
    color: #888; 
    font-size: 12px; 
}
.tweet-content { 
    color: #444; 
    font-size: 15px; 
    line-height: 1.6; 
    word-wrap: break-word; 
}
.no-tweets-msg {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 20px;
}

/* =========================================
   MANUAL DARK MODE CLASSES
   ========================================= */
body.dark-mode { background-color: #121212; }

/* Containers */
.dark-mode .login-container, .dark-mode .register-container, .dark-mode .welcome-container, 
.dark-mode .panel-container, .dark-mode .logout-container, .dark-mode .success-container, .dark-mode .error-container, .dark-mode .profile-container {
    background-color: #1e1e1e; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

/* Text Colors */
.dark-mode h1, .dark-mode h2, .dark-mode h3 { color: #e0e0e0; }
.dark-mode p, .dark-mode label, .dark-mode .info-group, .dark-mode .upload-status-text { color: #aaaaaa; }
.dark-mode .info-group strong { color: #e0e0e0; }
.dark-mode .panel-container h2, .dark-mode .profile-container h2 { border-bottom: 2px solid #333333; }
.dark-mode .error-container h3 { color: #ff6666; } /* Brighter red for dark mode readability */
.dark-mode .success-container h3 { color: #4ade80; } /* Brighter green */

/* Navbar */
.dark-mode .navbar { background-color: #1a1a1a; border-bottom: 1px solid #333; }
.dark-mode .theme-toggle-btn { background: rgba(255, 255, 255, 0.1); }
.dark-mode .theme-toggle-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* Inputs */
.dark-mode input[type="text"], .dark-mode input[type="email"], .dark-mode input[type="password"] {
    background-color: #2d2d2d; border-color: #444444; color: #ffffff;
}
.dark-mode input:focus { border-color: #3399ff; box-shadow: 0 0 5px rgba(51, 153, 255, 0.3); }

/* Buttons */
.dark-mode button, .dark-mode .submit-btn, .dark-mode .btn { background-color: #1a75ff; }
.dark-mode button:hover, .dark-mode .submit-btn:hover, .dark-mode .btn:hover { background-color: #005ce6; }
.dark-mode .logout-btn { background-color: #d32f2f !important; }
.dark-mode .logout-btn:hover { background-color: #b71c1c !important; }

/* Links */
.dark-mode .register-link { color: #66b3ff; }
.dark-mode .remember-me label { color: #999; }

/* Profile & Upload */
.dark-mode .profile-picture-container img { border-color: #1e1e1e; background-color: #2d2d2d; }
.dark-mode .file-upload-btn { background-color: #2d2d2d; border-color: #555555; color: #cccccc; border-style: solid; }
.dark-mode .file-upload-wrapper:hover .file-upload-btn { background-color: #3d3d3d; border-color: #66b3ff; color: #66b3ff; }

/* Spinner */
.dark-mode .spinner { border: 4px solid #333333; border-top: 4px solid #3399ff; }


.user-bio-display {
    margin: 15px auto;
    max-width: 80%;
    font-size: 14px;
    color: #555;
    font-style: italic;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    border-left: 3px solid #3498db;
}
.dark-mode .user-bio-display {
    color: #bbb;
    background-color: rgba(255, 255, 255, 0.05);
}
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    font-family: inherit;
    resize: vertical;
}
.dark-mode .form-group textarea {
    background-color: #333;
    color: #eee;
    border-color: #555;
}
.form-group textarea:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

/* Public Profile Button */
.public-profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: #0066cc;
    border: 2px solid #0066cc;
    padding: 8px 20px;
    margin-bottom: 25px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
}
.public-profile-btn:hover {
    background-color: #0066cc;
    color: white;
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(0, 102, 204, 0.2);
}
.public-profile-btn svg {
    margin-right: 6px;
}

.dark-mode .public-profile-btn {
    color: #66b3ff;
    border-color: #66b3ff;
}
.dark-mode .public-profile-btn:hover {
    background-color: #66b3ff;
    color: #121212;
    box-shadow: 0 4px 10px rgba(102, 179, 255, 0.2);
}

/* Tweets Dark Mode */
.dark-mode .tweets-section h3 { border-color: #333333; color: #e0e0e0; }
.dark-mode .tweet-card { background: #252525; border-color: #333333; }
.dark-mode .tweet-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.dark-mode .tweet-header strong { color: #e0e0e0; }
.dark-mode .tweet-time { color: #999; }
.dark-mode .tweet-content { color: #ccc; }

/* Tweet Delete Button */
.delete-tweet-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(204, 0, 0, 0.1);
    color: #cc0000;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s ease;
}
.delete-tweet-btn:hover {
    background-color: #cc0000;
    color: #ffffff;
    transform: scale(1.1);
}
.dark-mode .delete-tweet-btn {
    background-color: rgba(255, 102, 102, 0.15);
    color: #ff6666;
}
.dark-mode .delete-tweet-btn:hover {
    background-color: #ff6666;
    color: #121212;
}


/* =========================================
   FEED & TWO-COLUMN LAYOUT
   ========================================= */
.feed-layout {
    display: flex;
    flex-direction: column-reverse; /* Mobile-first: Sidebar (Login/Profile) at the top */
    gap: 20px;
    width: 100%;
    max-width: 900px;
}
@media(min-width: 768px) {
    .feed-layout {
        flex-direction: row;
        align-items: flex-start;
    }
}
.feed-main {
    flex: 1;
    width: 100%;
}
.feed-sidebar {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
@media(min-width: 768px) {
    .feed-sidebar {
        flex: 0 0 320px;
    }
}
.compose-container {
    background-color: #ffffff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.compose-container h2 {
    text-align: left;
    margin-bottom: 15px;
    font-size: 20px;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 10px;
}
.compose-container textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    font-size: 16px;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.compose-container textarea:focus {
    border-color: #0066cc;
    outline: none;
    box-shadow: 0 0 5px rgba(0, 102, 204, 0.3);
}
.tweet-btn {
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 24px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.tweet-btn:hover {
    background-color: #005bb5;
}

/* Dark Mode Defaults */
.dark-mode .compose-container { background-color: #1e1e1e; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); }
.dark-mode .compose-container h2 { border-color: #333333; color: #e0e0e0; }
.dark-mode .compose-container p { color: #aaaaaa; }
.dark-mode .compose-container textarea { background-color: #2d2d2d; color: #ffffff; border-color: #444444; }
.dark-mode .compose-container textarea:focus { border-color: #3399ff; box-shadow: 0 0 5px rgba(51, 153, 255, 0.3); }
.dark-mode .tweet-btn { background-color: #1a75ff; color: #fff; }
.dark-mode .tweet-btn:hover { background-color: #005ce6; }


/* =========================================
   ALL USERS DIRECTORY
   ========================================= */
.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    margin-top: 20px;
}
.user-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.user-card {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.user-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08);
    border-color: #0066cc;
}
.user-avatar-initial {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #0066cc;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 12px;
    box-shadow: 0 4px 10px rgba(0, 102, 204, 0.2);
}
.user-avatar-image {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid #fff;
    background-color: #f8f9fa;
}
.user-card-info {
    display: flex;
    flex-direction: column;
}
.user-card-name {
    color: #333;
    font-size: 16px;
    margin-bottom: 4px;
}
.user-card-username {
    color: #888;
    font-size: 13px;
}

/* All Users Dark Mode */
.dark-mode .user-card {
    background: #252525;
    border-color: #333333;
}
.dark-mode .user-card:hover { border-color: #66b3ff; box-shadow: 0 6px 15px rgba(102, 179, 255, 0.15); }
.dark-mode .user-card-name { color: #e0e0e0; }
.dark-mode .user-card-username { color: #999; }

/* =========================================
   MOBILE & RESPONSIVE TWEAKS
   ========================================= */
@media (max-width: 767px) {
    body { padding: 90px 10px 30px; }
    
    .navbar {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .nav-brand {
        font-size: 18px;
    }
    .nav-links {
        gap: 12px;
    }
    .nav-links a {
        font-size: 14px;
    }

    .login-container, .register-container, .welcome-container, .panel-container, 
    .logout-container, .success-container, .error-container, .profile-container, 
    .compose-container {
        padding: 25px 15px !important;
    }
    
    .welcome-container h1 { font-size: 20px !important; }
    
    .tweet-card { padding: 15px; }
    .tweet-header { flex-direction: column; align-items: flex-start; gap: 4px; }
    .tweet-time { font-size: 11px; }
    
    .users-grid { gap: 15px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    
    input[type="text"], input[type="email"], input[type="password"], textarea {
        font-size: 16px !important; /* Prevents auto-zoom on mobile inputs */
    }
}

/* Toast Notifications */
#toast {
    visibility: hidden;
    min-width: 250px;
    margin-left: -125px;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 16px;
    position: fixed;
    z-index: 9999;
    left: 50%;
    bottom: 30px;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.5s, bottom 0.5s, visibility 0.5s;
}

#toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

#toast.toast-success {
    background-color: #28a745;
}

#toast.toast-error {
    background-color: #dc3545;
}
