@import url('https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap');

*{
    font-family: "Work Sans", serif;
}

:root{
    /* Text */
    --links: #3B3C4A;
    --search: #A1A1AA;
    --topics: #FFFFFF;
    --primary:#181A2A;
    --technology: #4B6BFB;
    --secondary:#97989F;
    --about: #696A75;

    /* Background */
    --search-bg: #52525b14;
    --blog-bg: #FFFFFF;
    --blog-tag: #4b6bfb10;
    --border-line-blog: #E8E8EA;
    --border-line-view: #696A75;
}

.dark-mode{
    /* Text */
    --links: #FFFFFF;
    --search: #A1A1AA;
    --topics: #FFFFFF;
    --primary:#FFFFFF;
    --technology: #4B6BFB;
    --secondary:#97989F;
    --about: #696A75;

    /* Background */
    --search-bg: #242535;
    --blog-bg: #181A2A;
    --blog-tag: #4b6bfb10;
    --border-line-blog: #242535;
    --border-line-view: #696A75;

    background-color: #181A2A;
}

body {
    box-sizing: border-box;
    padding:0;
    margin:0;
    display: flex;
}

.container {
    display: flex;
    width: 100%;
    max-width: 1400px; 
    margin: 0 auto;
}

input[type="text"]{
    outline: none;
}

.toggle-label {
    width: 50px;
    height: 25px;
    border-radius: 15px;
    background: #F3F3F3;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1) inset;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px;
    transform: translate(85px, 300px);
}

.circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    position: absolute;
    left: 5px;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sun, .moon {
    width: 14px;
    height: 14px;
    position: absolute;
    transition: opacity 0.3s;
}

.sun {
    opacity: 1;
}

.moon {
    opacity: 0;
}

input[type="checkbox"]:checked + .toggle-label .circle {
    left: 25px;
    background:var(--search);
}

input[type="checkbox"]:checked + .toggle-label .sun {
    opacity: 0;
}

input[type="checkbox"]:checked + .toggle-label .moon {
    opacity: 1;
}

input[type="checkbox"]:checked + .toggle-label {
    background:var(--search-bg);
}

input[type="checkbox"] {
    display: none;
}

.main-content {
    margin-left: 250px;
    padding: 20px;
    flex-grow: 1;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats {
    flex-wrap: wrap;
    gap: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr; 
}

.stat-item {
    background: var(--blog-bg);
    border: 1px solid var(--border-line-blog);
    padding: 25px 20px;
    border-radius: 12px;
    flex: 1 1 calc(33.333% - 20px);
    display:flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info{
    display:flex;
    flex-direction: column;
    gap:0.7rem;
    color: var(--primary);
}

.stat-img img{
    width: 30px;
    height: 30px;
}

.dark-mode .stat-img img{
    filter:brightness(0) invert(1);
}

.chart h2{
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.vistors{
    color:var(--primary);
    font-size: 1rem;
}

.column{
    display:flex;
    gap: 20px;
}

#visitorChart {
    width: 67%;
}

.latest-post {
   display:flex;
   flex-direction: column;
   gap:1rem;
   width:33%;
}

.latest{
    background: var(--blog-bg);
    border: 1px solid var(--border-line-blog);
    padding:15px;
    width:100%;
    border-radius: 12px;
}

.latest h4{
    color: var(--primary);
}

.latest-blog {
    display: flex;
    flex-direction: column;
    padding-left:20px;
    cursor: pointer;
}

.latest-blog p {
    margin: 0;
    color: var(--primary);
}

.latest-blog span {
    color: var(--secondary);
}

.comments-section {
    width: 100%;
    display:none;
    flex-direction: column;
}

.search-container{
    padding-bottom:40px;
}

.search{
    display:flex;
    align-items: center;
    background: var(--search-bg);
    padding:5px;
    border-radius: 5px;
    width:40%;
    justify-content: center;
    margin:0 auto;
}

.search-input{
    border:none;
    background: none;
    width:100%;
}

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

.search-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

input[type="text"]{
    outline: none;
}

.comment-section, .comment-item {
    display: grid;
    grid-template-columns: 1fr 2fr 2fr 3fr 1fr; 
    align-items: center;
    gap: 10px; 
    padding: 10px 0;
    border-bottom: 1px solid var(--border-line-blog);
    color: var(--primary);
}

.comment-date,
.comment-post,
.comment-user,
.comment-text {
    flex: 1;
    margin-right: 10px;
}

.comment-user {
    display: flex;
    align-items: center;
}

.comment-user img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

.comment-delete, .user-delete {
    background-color: #ff4d4d;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
}

.comment-delete:hover {
    background-color: #ff1a1a;
}

.user-delete:hover {
    background-color: #ff1a1a;
}

.topics-section {
    background: var(--blog-bg);
    border: 1px solid var(--border-line-blog);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    display:none;
    flex-direction: column;
    max-width:100%;
    justify-content: center;
}

.add-topic-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center; 
    flex-wrap: wrap; 
}

.add-topic-form input {
    flex: 1; 
    padding: 10px;
    border: 1px solid var(--border-line-blog);
    border-radius: 5px;
    background: var(--blog-bg);
    color: var(--primary);
}

.add-topic-form button {
    padding: 10px 15px; 
    background-color: var(--technology);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap; 
}

.add-topic-form button:hover {
    background-color: #3a4fbf;
}

.topic-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.topic-name {
    flex: 1;
    color: var(--primary);
}

.edit-topic,
.delete-topic {
    background-color: #4B6BFB;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
}

.edit-topic:hover,
.delete-topic:hover {
    background-color: #3a4fbf;
}

.delete-topic {
    background-color: #ff4d4d;
}

.delete-topic:hover {
    background-color: #ff1a1a;
}

.users-section{
    display:none;
    flex-direction: column;
}

.search-input{
    color:var(--primary);
}

.user-section, .user{
    display: grid;
    grid-template-columns: 1fr 2fr 2fr 3fr 1fr; 
    align-items: center;
    gap: 10px; 
    padding: 10px 0;
    border-bottom: 1px solid var(--border-line-blog);
    color: var(--primary);
}

.users-images img{
    width:40px;
    height:40px;
    border-radius: 50%;
}

.posts-section{
    display:none ;
    flex-direction: column;
}

.post-section, .post{
    display: grid;
    grid-template-columns: 1fr 2fr 2fr 1fr 1fr; 
    align-items: center;
    gap: 10px; 
    padding: 10px 0;
    border-bottom: 1px solid var(--border-line-blog);
    color: var(--primary);
}

.posts-list {
    display: flex;
    flex-direction: column;
}

.post-images img{
    max-width:70%;
    border-radius: 12px;
}

.post-buttons{
    display: flex;
    width:100%;
}

.post-edit, .post-delete{
    background-color: #4B6BFB;
    color: #fff;
    border: none;
    padding:10px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    max-width:100%;
}

.post-edit:hover,
.post-delete:hover {
    background-color: #3a4fbf;
}

.post-delete {
    background-color: #ff4d4d;
}

.post-delete:hover {
    background-color: #ff1a1a;
}

.text-area, #post-body{
    background-color: var(--blog-bg);
    border: 1px solid var(--border-line-blog);
}

.text-input{
    background-color: var(--blog-bg);
    color: var(--primary);
}

.create-post-section {
    background: var(--blog-bg);
    border: 1px solid var(--border-line-blog);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    display:none;
    flex-direction: column;
}

.create-post-section h2{
    margin-bottom: 20px;
    color: var(--primary);
}

.create-post-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.create-post-form input[type="text"],
.create-post-form select{
    padding: 10px;
    border: 1px solid var(--border-line-blog);
    border-radius: 5px;
    width: 100%;
    background: var(--blog-bg);
    color:var(--primary);
}

.create-post-form input[type="file"]{
    color:var(--primary);
}

.create-post{
    padding: 10px 20px;
    background-color: var(--technology);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.create-post:hover {
    background-color: #3a4fbf;
}

/* Make headings inside .format or .format-lg larger */
.format h1, .format-lg h1 {
    font-size: 2.25rem;
    font-weight: bold;
    margin: 1.5rem 0 1rem 0;
}
.format h2, .format-lg h2 {
    font-size: 1.75rem;
    font-weight: bold;
    margin: 1.25rem 0 0.75rem 0;
}
.format h3, .format-lg h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 1rem 0 0.5rem 0;
}
.format h4, .format-lg h4 {
    font-size: 1.25rem;
    font-weight: bold;
    margin: 0.75rem 0 0.5rem 0;
}

/* Add space below images in post content so you can type after the image */
.format img,
.format-lg img,
#post-body img {
    margin-bottom: 1.5rem;
    display: block;
    max-width: 100%;
    height: auto;
}

#post-body,
.ProseMirror {
    padding-bottom: 2.5rem;
    min-height: 200px;
}

/* Blog content heading styles for #blog-body */
/* Ensure all headings in #post-body are styled, so h3/h4 work even if .format is missing */
#post-body h1 {
    font-size: 2.25rem;
    font-weight: bold;
    margin: 1.5rem 0 1rem 0;
}
#post-body h2 {
    font-size: 1.75rem;
    font-weight: bold;
    margin: 1.25rem 0 0.75rem 0;
}
#post-body h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 1rem 0 0.5rem 0;
}
#post-body h4 {
    font-size: 1.25rem;
    font-weight: bold;
    margin: 0.75rem 0 0.5rem 0;
}

/* Add space between image and following text in post body */
#post-body img + p,
#post-body img + h1,
#post-body img + h2,
#post-body img + h3,
#post-body img + h4,
#post-body img + h5,
#post-body img + h6 {
    margin-top: 1.25rem;
}

.mobile-nav{
    display:none;
}

@media(max-width: 920px) {
    .container{
        display:flex;
        flex-direction: column;
        width:100%;
    }

    .mobile-nav{
        display:flex;
    }

    .main-content {
        margin-left: 0;
    }

    .stats {
        flex-direction: column;
        grid-template-columns: 1fr;
    }

    .chart, .column {
        flex-direction: column;
    }

    #visitorChart, .latest-post {
        width: 100%;
    }

    .search-container{
        border-bottom: 1px solid var(--border-line-blog);
        width:100%;
    }

    .search{
        width:100%;
    }

    .comment-container{
        display:flex;
        flex-direction: column;
        align-items: center;
    }

    .comment-section {
        display:none;
    }

    .comments{
        display:flex;
        flex-direction: column;
    }

    .comment-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 10px 0;
        border-bottom: 1px solid var(--border-line-blog);
    }

    .comment-date,
    .comment-post,
    .comment-user,
    .comment-text {
        flex: none;
        width: 100%;
        margin-right: 0;
    }

    .comment-user {
        display: flex;
        align-items: center;
    }

    .comment-user img {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        margin-right: 10px;
    }

    .comment-delete {
        align-self: flex-end;
    }

    .user-section{
        display:none;
    }

    .users-container{
        display:flex;
        flex-direction: column;
    }

    .user{
        display:flex;
        flex-direction: column;
    }

    .posts-section{
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .post-section{
        display:none;
    }

    .post-section, .post{
        grid-template-columns: 1fr; 
        align-items: center;
        gap: 10px; 
        margin:0 auto;
        justify-content: center;

    }

    .post-images img {
        display: block;
        margin: 0 auto;
    }

    .post-buttons{
        justify-content: center;
    }
}