/* Font Definitions */
@font-face {
    font-family: 'Product Sans';
    src: url('ProductSans-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'Product Sans';
    src: url('ProductSans-Light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
}

:root {
    --color-primary: #cF0000;
    --color-secondary: #FFFFFF;
    --color-dark-accent: #333; /* Dark gray as a secondary color option for text/elements */
    --sidebar-width: 25%;
    --header-height: 8vh;
    --mobile-sidebar-width: 280px; /* NEW: Define mobile sidebar width */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Product Sans', Montserrat, Futura, sans-serif;
}

body {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden; /* Added to prevent horizontal scroll when sidebar is offscreen/moved */
}

/* 1. Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--color-primary);
    color: var(--color-secondary);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
    overflow-y: auto; /* Allow menu scrolling if content is long */
}

#sidebar .logo {
    /* font-size: 2.5em; */
    /* font-weight: bold; */
    text-align: center;
    padding: 30px 20px;
    margin-bottom: 20px;
    /* letter-spacing: 1px; */
}

#sidebar .logo img {
    max-width: 100%;
    height: auto;
    max-height: 62px;
    vertical-align: middle; /* Ensures image behaves well inside the centered div */
}

/* Navigation Menu Styling */
#sidebar nav {
    flex-grow: 1;
    padding-left: 10px;
    font-size: 0.9em;
}

#sidebar ul {
    list-style: none;
}

#sidebar a {
    text-decoration: none;
    color: var(--color-secondary);
    display: block;
    padding: 8px 15px;
    /* font-weight: 400; */ /* Adjusted to Regular (400) from 200 */
    /* transition: background-color 0.4s ease-in-out, color 0.4s ease-in-out; */ /* Adjusted transition for subtlety, duration increased */
    cursor: pointer;
    font-size: 18px;
    border-radius: 0;
    line-height: 14px;
}

#sidebar a:hover {
    /* background-color: rgba(255, 255, 255, 0.1); */
}

a {}

/* Top Level Items Styling */
.menu-item > a {
    position: relative;
    padding-left: 30px; /* Space for custom bullet */
    margin-bottom: 5px;
    border-radius: 0px;
    font-weight: 300; /* NEW: default top-level items use light */
}

.menu-item > a::before {
    content: "■"; /* Solid square bullet */
    color: var(--color-secondary);
    position: static;
    left: 5px;
    font-size: 20px;
    line-height: 0;
    top: 50%;
    transform: translateY(-50%);
    padding-right: 5px;
    transition: color 0.3s; /* Added transition for bullet color */
}

/* Sub-list styling */
.menu-item ul {
    list-style: none;
    margin-left: 0;
    padding-left: 20px; /* Indentation for submenus */
    padding-top: 6px;
    
    /* Accordion initial state */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

/* Open state applied to the parent LI */
li.menu-item-active > ul {
    max-height: 500px; /* Sufficient height for smooth expansion */
    margin-top: -10px;
    margin-bottom: 12px;
}

.menu-item ul li a {
    font-weight: 300; /* Light weight for sub-items */
    padding: 5px 15px 5px 30px; /* Standardized left padding for sub-item bullets */
    border-radius: 0px;
    position: relative; /* Enable positioning of sub-item bullets */
}

/* Bullet styling for sub-items (Level 2 and deeper) */
.menu-item ul li a::before {
    content: "■";
    color: var(--color-secondary);
    /* position: absolute; */
    left: 10px;
    font-size: 0.6em; /* Smaller bullet */
    line-height: 0;
    top: 50%;
    transform: translateY(-50%);
    transition: color 0.3s; /* Added transition for bullet color */
    margin: 0px 4px 0px 0px;
}

/* Specific styling for Level 2 items: use hyphen '-' */
/* Targetting .menu-item > ul > li > a (Level 2 menu items) */
.menu-item > ul > li > a::before {
    content: "-";
    font-size: 1em;
    left: 10px;
    margin-right: 5px;
}

/* Sub-Sub-list styling (Estoque) */
.menu-item ul ul {
    margin-left: 0;
    padding-left: 15px;
    margin-top: -5px;
}

.menu-item ul ul li a {
    padding: 3px 15px 3px 30px; /* Ensure 30px left padding is maintained for deeper links */
}


/* Active State Styling */
/* Parent active state (Open accordion link, defined by menu-item-active) */
li.menu-item-active > a,
li.menu-item-active > a::before {
    background-color: var(--color-secondary) !important;
    color: var(--color-primary) !important;
    font-weight: 400; /* NEW: parent/category becomes regular when active */
}

/* Specific selected sub-item */
.menu-item ul li.menu-item-selected a {
    background-color: transparent; /* Keep red background */
    font-weight: 400; /* Selected sub-item uses regular weight */
}

/* Selected sub-item bullet color */
.menu-item ul li.menu-item-selected a::before {
    color: var(--color-secondary); /* Keep bullet white */
}

/* Collapsible Indicator */
.collapsible-indicator {
    float: right;
    font-weight: 300; /* Use light font weight */
    font-size: 27px;
    line-height: .4;
    transition: transform 0.3s ease-in-out;
}

/* Indicator rotation when the parent LI has the 'menu-item-active' class */
.menu-item.menu-item-active > a .collapsible-indicator {
    transform: rotate(45deg); /* + rotates to X */
}

/* Sidebar Footer */
#sidebar-footer {
    text-align: center;
    padding: 15px 0 10px;
    font-size: 0.8em;
    opacity: 0.8;
    margin-top: auto; /* Push to bottom */
}

.menu-tools { display: flex; justify-content: flex-end; padding: 0 12px 10px; }
#menu-refresh { background: transparent; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 6px; }
#menu-refresh:hover { background: rgba(255,255,255,0.12); }
#menu-refresh.spin svg { animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.logout-item {
    padding: 10px 16px;
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.logout-item a {
    display: block;
    color: var(--color-secondary);
    text-decoration: none;
    font-weight: 400;
    padding: 10px 12px;
    border-radius: 4px;
    background: transparent;
    transition: background-color 0.15s, color 0.15s;
}

.logout-item a:hover {
    background-color: rgba(255,255,255,0.08);
    color: var(--color-secondary);
}

/* Sidebar mobile close X button */
#sidebar-close {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: 0;
    color: var(--color-secondary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.15s, transform 0.12s;
}
#sidebar-close:hover { background: rgba(255,255,255,0.06); transform: scale(1.05); }

/* Show close button only on small screens and when sidebar is open */
@media (max-width: 900px) {
    #sidebar-close { display: block; }
    /* keep it visible only when sidebar overlay is shown */
    #sidebar:not(.open) #sidebar-close { display: none; }
}


/* 2. Main Content Area */
#main-content-area {
    width: calc(100% - var(--sidebar-width));
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
#header {
    height: var(--header-height);
    display: flex;
    flex-shrink: 0;
    align-items: center; /* Ensure vertical centering of items */
    background: #4c4c4c;
    margin-left: 2px;
}

/* Menu Toggle Button (New - Desktop Hidden) */
#menu-toggle {
    display: none; /* Hidden by default on desktop */
    background: none;
    border: none;
    color: var(--color-secondary);
    font-size: 2em;
    padding: 0 15px;
    cursor: pointer;
    height: 100%;
    align-items: center;
    justify-content: center;
    background-color: var(--color-primary); 
    flex-shrink: 0;
}

/* Title Block (Left) */
#header-title {
    /* background-color: var(--color-primary); */
    color: var(--color-secondary);
    display: flex;
    align-items: center;
    padding: 0 30px;
    font-size: 29px;
    font-weight: 100;
    min-width: 300px; /* Ensure title block is substantial */
    margin: 0 0 0 3px;
    line-height: 22px;
}

/* User Block (Right) */
#header-user {
    /* background-color: var(--color-primary); */
    color: var(--color-secondary);
    flex-grow: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 30px;
    font-size: 17px;
    font-weight: 100;
    /* font-style: italic; */
}

.user-avatar-placeholder {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: var(--color-secondary);
    margin-left: 15px;
    flex-shrink: 0;
}

/* Content Panel */
#content-panel {
    flex-grow: 1;
    background-color: var(--color-secondary);
    padding: 20px;
    color: var(--color-dark-accent); /* Dark gray text for contrast */
}

/* Breadcrumbs Styling */
#breadcrumbs-container {
    padding: 9px 12px; /* Matching horizontal padding of header/content */
    background-color: #fff; /* Light gray background */
    /* color: #669; */
    font-size: 15px;
    /* border-bottom: 1px solid #ddd; */
    flex-shrink: 0; /* Prevents container from shrinking if main content is large */
    border-bottom: 3px solid #e4e4e7;
}

.breadcrumb-list {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    background: #fff;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item a {
    color: var(--color-dark-accent);
    text-decoration: none;
    padding: 0 5px;
    font-weight: 300; /* Light weight for path elements */
    transition: color 0.2s;
}

.breadcrumb-item a:hover {font-weight: 600;}

.breadcrumb-separator {
    /* margin: 0 5px; */
    color: var(--color-dark-accent);
}

.breadcrumb-item .current-page {
    font-weight: 400; /* Regular weight for the current item */
    color: var(--color-dark-accent); /* Darker color for the current item */
    padding: 0 5px;
}

#content-panel p {
    font-size: 1.1em; /* Adjusted default size for general text */
    font-weight: 300;
}

/* NEW: Dashboard Layout Styling (for Visão Geral) */
.dashboard-layout {
    display: grid;
    gap: 20px;
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
    zoom: 0.7;
}

/* Card Model Improvement */
.widget-card {
    background-color: #ffffff; /* White background for pop */
    border: 1px solid #ddd;
    padding: 0;
    border-radius: 0px; 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); 
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.widget-card-header {
    background-color: var(--color-primary);
    color: var(--color-secondary);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.widget-card h3 {
    color: var(--color-secondary); /* Title text in header is white */
    margin-bottom: 0;
    font-weight: 400;
    font-size: 1.4em;
    border-bottom: none;
    padding-bottom: 0;
}

.widget-card-content {
    padding: 20px;
    flex-grow: 1;
}

/* Optional: Style to highlight a primary metric (if AI uses a dedicated element) */
.widget-card-content .metric-value {
    display: block;
    font-size: 2.2em;
    font-weight: 400;
    color: var(--color-primary);
    margin: 10px 0 15px;
}

/* Ensure p tag inside widget doesn't inherit oversized font from #content-panel p */
.widget-card-content p {
    font-size: 1em;
    font-weight: 300;
    line-height: 1.4;
    margin-top: 5px;
    color: var(--color-dark-accent);
}

/* --- Modal Styling --- */

.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 2000; /* Sit on top of everything */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    padding-top: var(--header-height); /* Space from the top, pushing content down slightly */
}

.modal-content {
    background-color: #fefefe;
    margin: 15vh auto 0 auto; /* Centered, starting lower than padding-top */
    padding: 30px;
    border: 1px solid #ddd;
    width: 90%; /* Default width */
    max-width: 500px; /* Max width */
    border-radius: 0px;
    position: relative;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}

.close-button:hover,
.close-button:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

/* Modal Form Styling */
.modal-content h2 {
    color: var(--color-primary);
    margin-bottom: 25px;
    font-weight: 400;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 400;
    color: var(--color-dark-accent);
    font-size: 0.9em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 0px;
    font-size: 1em;
    font-weight: 300;
}

.form-group small {
    color: #666;
    font-size: 0.8em;
    margin-top: 5px;
    display: block;
}

.save-button {
    background-color: var(--color-primary);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 0px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 400;
    margin-top: 15px;
    transition: background-color 0.2s;
    width: 100%;
}

.save-button:hover {
    background-color: #d60000; /* Slightly darker red */
}

/* NEW: Profile Photo Group inside Modal */
.profile-photo-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #eee;
}

.profile-photo-group label {
    margin-bottom: 10px;
    font-size: 1em;
    font-weight: 400;
}

.current-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%; /* Ensuring circular shape */
    margin-bottom: 10px;
    cursor: pointer;
    background-color: #f0f0f0; 
    border: 3px solid var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-secondary);
    /* For image preview handling: */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.profile-photo-group input[type="file"] {
    display: none; /* Hide default file input */
}

/* Styling for the small text instruction */
.profile-photo-group small {
    cursor: pointer;
    text-decoration: underline;
    color: var(--color-primary);
}

/* Loading placeholder full-center utility for content panel */
.loading-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: italic;
    font-weight: 300;
    color: var(--color-dark-accent);
}


/* --- Responsive Layout Adjustments (<= 900px) --- */
@media (max-width: 900px) {
    
    :root {
        /* Override inline sidebar width for layout calculation */
        --sidebar-width: 0; 
    }
    
    body {
        position: relative; /* Context for fixed sidebar */
    }

    /* Sidebar becomes a fixed overlay */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--mobile-sidebar-width); /* Use fixed pixel width */
        z-index: 1000;
        /* Start off screen */
        transform: translateX(calc(-1 * var(--mobile-sidebar-width))); 
        transition: transform 0.3s ease-out;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.4); /* Stronger shadow for overlay */
    }
    
    #sidebar.open {
        transform: translateX(0);
        height: 100%;
    }
    
    /* Main Content Area takes full width */
    #main-content-area {
        width: 100%; 
        min-width: 0;
    }

    /* Header adjustments */
    #header {
        position: sticky;
        top: 0;
        z-index: 500;
        background: #4c4c4c;
    }

    /* Show toggle button */
    #menu-toggle {
        display: flex; /* Show the hamburger menu */
        width: calc(var(--header-height) * 1.0); /* Make button size substantial */
        justify-content: center;
        padding: 0;
        border-right: 2px solid;
    }
    
    #header-title {
        min-width: unset;
        font-size: 31px;
        padding: 0 15px;
        flex-grow: 1;
        margin: 0 0 0 6px; /* Remove 3px margin */
        font-weight: 100;
    }
    
    #header-user {
        font-size: 1em;
        padding: 0 15px;
        flex-shrink: 0;
    }

    /* Content and breadcrumbs padding adjustment for consistency */
    #breadcrumbs-container, #content-panel {
        padding-left: 15px;
        padding-right: 15px;
    }

    #content-panel {
    padding:0px
    }

}

/* --- Mobile Specific adjustments (<= 600px) --- */
@media (max-width: 600px) {
    #header-title {
        font-size: 0;
    }
    
    /* Hide 'Boa tarde, Usuário!' text on small screens */
    #header-user {
        font-size: 20px;
        padding: 0 10px;
        display: flex;
    }

    .user-avatar-placeholder {
        margin-left: 0; /* Ensures avatar hugs the edge */
    }
    
    .modal-content {
        margin-top: 10vh; /* Adjust modal placement on small screens */
    }
}

/* Ensure the inline logout link in header looks subtle and aligned */
#header-logout {
    color: var(--color-secondary);
    text-decoration: none;
    font-weight: 400;
    background: transparent;
    padding: 4px 8px;
    border-radius: 4px;
}
#header-logout:hover {
    background: rgba(255,255,255,0.08);
}

/* Avatar in header (already has .user-avatar-placeholder styles) ensure consistent size */
#header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%; 
    background-color: var(--color-secondary);
    border: 2px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
    background-size: 38px;
    background-position: center;
    background-repeat: no-repeat;
} 