/* =========================================
   VARIABLES & THEMING
   ========================================= */
:root {
  --color-primary: #43c659;
  --color-danger: #ff7782;
  --color-success: #2cb3f7;
  --color-warning: #ffbb55;
  --color-white: #fff;
  --color-info-dark: #7d8da1;
  --color-info-light: #dce1eb;
  --color-dark: #363949;
  --color-light: rgba(132, 139, 200, 0.18);
  --color-primary-variant: #111e88;
  --color-dark-variant: #677483;
  --color-background: #f6f6f9;
  --card-border-radius: 2rem;
  --border-radius-1: 0.4rem;
  --border-radius-2: 0.8rem;
  --border-radius-3: 1.2rem;
  --card-padding: 1.8rem;
  --padding-1: 1.2rem;
  --box-shadow: 0 2rem 3rem var(--color-light);
}

.dark-theme-variables {
    --color-primary: #37ed5f;
    --color-danger: #ff4d4d;
    --color-success: #72e0ff;
    --color-warning: #ffb020;
    --color-background: #0d0f12;
    --color-white: #16181d;      
    --color-dark: #ffffff;      
    --color-dark-variant: #9ca6b5;
    --color-light: rgba(0, 0, 0, 0.7);
    --box-shadow: 0 2rem 3rem var(--color-light);
}

/* =========================================
   GLOBAL RESET & TYPOGRAPHY
   ========================================= */
*{ margin: 0; padding: 0; outline: 0; appearance: none; border: 0; text-decoration: none; list-style: none; box-sizing: border-box; }
html{ font-size: 14px; }
body{ width: 100vw; height: 100vh; font-family: 'Poppins', sans-serif; font-size: 0.88rem; background: var(--color-background); overflow-x: hidden; color: var(--color-dark); }
a{ color: var(--color-dark); }
img{ display: block; width: 100%; }

h1{ font-weight: 800; font-size: 1.8rem; }
h2{ font-size: 1.4rem; }
h3{ font-size: 0.87rem; }
h4{ font-size: 0.8rem; }
h5{ font-size: 0.77rem; }
small{ font-size: 0.75rem; }

.text-muted{ color: var(--color-info-dark); }
p{ color: var(--color-dark-variant); }
b{ color: var(--color-dark); }
.primary{ color: var(--color-primary); }
.danger{ color: var(--color-danger); }
.success{ color: var(--color-success); }
.warning{ color: var(--color-warning); }

/* =========================================
   LAYOUT & CONTAINER
   ========================================= */
.container{ display: grid; width: 95%; margin: 0 auto; gap: 1.5rem; grid-template-columns: 14rem auto 23rem; transition: all 300ms ease;}
main{ margin-top: 1.4rem; }

/* =========================================
   STICKY & COLLAPSIBLE SIDEBAR
   ========================================= */
aside{ height: 100vh; position: sticky; top: 0; z-index: 10; transition: all 300ms ease;}
aside .top{ display: flex; align-items: center; justify-content: space-between; margin-top: 1.4rem; position: relative;}
aside .logo { display: flex; gap: 0.8rem; }
aside .logo img{ width: 3.5rem; height: auto; }
aside .close{ display: none; }

aside .sidebar{ display: flex; flex-direction: column; height: 86vh; position: relative; top: 3rem; }
aside h3{ font-weight: 500; }
aside .sidebar a{ display: flex; color:var(--color-info-dark); margin-left: 2rem; align-items: center; gap: 1rem; position: relative; height: 3.7rem; transition: all 300ms ease; }
aside .sidebar a span{ font-size: 1.6rem; transition: all 300ms ease; }
aside .sidebar a:last-child{ position: absolute; bottom: 2rem; width: 100%; }
aside .sidebar a.active{ color: var(--color-primary); background: var(--color-light); margin-left: 0; }
aside .sidebar a.active::before{ content: ''; width: 6px; height: 100%; background: var(--color-primary); }
aside .sidebar a.active span{ color: var(--color-primary); margin-left: calc(1rem - 6px); }
aside .sidebar a:hover{ color: var(--color-primary); }
aside .sidebar a:hover span{ margin-left: 0.5rem; }

/* Toggle Button */
.sidebar-toggle { display: flex; align-items: center; justify-content: center; background: var(--color-primary); color: var(--color-white); border-radius: 50%; cursor: pointer; width: 2rem; height: 2rem; position: absolute; right: -1rem; top: 3rem; opacity: 0; transition: all 300ms ease; z-index: 20; box-shadow: var(--box-shadow); }
aside:hover .sidebar-toggle { opacity: 1; }

/* Collapsed State Globals */
body.collapsed-sidebar aside .logo h2 { display: none; }
body.collapsed-sidebar aside .sidebar h3 { display: none; }
body.collapsed-sidebar aside .sidebar a { width: 5.6rem; justify-content: center; margin-left: 0; }
body.collapsed-sidebar aside .sidebar a span { margin-left: 0; }
body.collapsed-sidebar .sidebar-toggle { transform: rotate(180deg); }
body.collapsed-sidebar .container { grid-template-columns: 5.6rem auto 23rem; }

/* =========================================
   RIGHT HEADER
   ========================================= */
.right{ margin-top: 1.4rem; }
.right .top{ display: flex; justify-content: end; gap: 2rem; align-items: center;}
.right .top button{ display: none; }
.right .theme-toggler{ background-color: var(--color-light); display: flex; justify-content: space-between; align-items: center; height: 1.6rem; width: 4.2rem; cursor: pointer; border-radius: var(--border-radius-1); }
.right .theme-toggler span{ font-size: 1.2rem; width: 50%; height: 100%; display: flex; align-items: center; justify-content: center; }
.right .theme-toggler span.active{ background-color: var(--color-primary); color: white; border-radius: var(--border-radius-1); }
.right .top .profile{ display: flex; gap: 2rem; text-align: center; align-items: center; }
.profile-photo{ width: 2.8rem; height: 2.8rem; border-radius: 50%; overflow: hidden; }

/* =========================================
   GLOBAL MEDIA QUERIES
   ========================================= */
@media screen and (max-width: 1200px){
    .container{ width: 94%; grid-template-columns: 7rem auto 23rem; }
    aside .logo h2{ display: none; }
    aside .sidebar h3{ display: none; }
    aside .sidebar a{ width: 5.6rem; }
    aside .sidebar a:last-child{ position: relative; margin-top: 1.8rem; }
}

@media screen and (max-width: 768px){
    .container{ width: 100%; grid-template-columns: 1fr; }
    aside{ position: fixed; left: -100%; background: var(--color-white); width: 18rem; z-index: 3; box-shadow: 1rem 3rem 4rem var(--color-light); height: 100vh; padding-right: var(--card-padding); display: none; animation: showMenu 400ms ease forwards; }
    @keyframes showMenu{ to{ left: 0; } }
    aside .logo{ margin-left: 1rem; }
    aside .logo h2, aside .sidebar h3{ display: inline; }
    aside .sidebar a{ width: 100%; height: 3.4rem; }
    aside .sidebar a:last-child{ position: absolute; bottom: 5rem; }
    aside .close{ display: inline-block; cursor: pointer; }
    
    /* Hide the circular toggle button on mobile */
    .sidebar-toggle { display: none !important; }
    
    main{ margin-top: 6rem; padding: 0 1rem; }
    .right{ width: 100%; margin: 0; }
    
    /* =========================================
       FIXED MOBILE NAVBAR (Perfectly Aligned)
       ========================================= */
    .right .top { 
        position: fixed; 
        top: 0; 
        left: 0; 
        right: 0; /* Forces it to perfectly snap to the edges without overflowing */
        display: flex;
        justify-content: flex-start; /* Resets from desktop's flex-end */
        align-items: center; 
        padding: 0 1.2rem; 
        height: 4.6rem; 
        background: var(--color-white); 
        margin: 0; 
        z-index: 1000; 
        box-shadow: 0 1rem 1rem var(--color-light); 
        box-sizing: border-box;
    }

    /* Menu button pinned to the left */
    .right .top button { 
        display: inline-block; 
        background: transparent; 
        color: var(--color-dark); 
        cursor: pointer; 
    }
    .right .top button span { 
        font-size: 2rem; 
    }

    /* Toggler and Profile grouped on the right */
    .right .top .theme-toggler { 
        width: 4.4rem; 
        height: 1.8rem;
        position: static; 
        margin-left: auto;     /* Pushes toggler and profile to the far right */
        margin-right: 1rem;    /* Space between toggler and profile */
        flex-shrink: 0;        /* Prevents squishing */
    }

    .right .profile {
        display: flex;
        align-items: center;
        gap: 0.6rem; 
    }

    /* Scale the "Hello, Owner" text to fit on small screens */
    .right .profile .info { display: block; text-align: right; }
    .right .profile .info p { font-size: 0.8rem; line-height: 1.2; margin: 0; white-space: nowrap; }
    
    .profile-photo { width: 2.3rem; height: 2.3rem; flex-shrink: 0; }
}

/* =========================================
   CUSTOM SCROLLBARS
   ========================================= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-background); }
::-webkit-scrollbar-thumb { background: var(--color-info-dark); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }