/* ============================================
   GLOBAL STYLES - Layout, Header, Footer, Nav
   ============================================ */

/* === CSS Variables (Design Tokens) === */
:root {
    --bg-main: #e2e2e2;
    --bg-card: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
    --primary-color: #3182ce;
    --primary-hover: #2b6cb0;
    --primary-light: #ebf8ff;
    --border-color: #e2e8f0;
    --sidebar-bg: #ffffff;
    --sidebar-text: #4a5568;
    --sidebar-hover: #edf2f7;
    --header-bg: #cacaca;
    --danger-color: #e53e3e;
    --danger-hover: #c53030;
    --secondary-color: #38a169;
    --secondary-hover: #2f855a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-main: "Inter", "Roboto", "Segoe UI", Arial, sans-serif;
}

/* === Reset === */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

body {
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

/* === Typography === */
h1, h2, h3, h4, h5 {
    color: var(--text-main);
    margin-bottom: 20px;
    font-weight: 600;
}

h1 {
    text-align: center;
    margin-top: 20px;
}

p {
    font-size: 16px;
    color: var(--text-muted);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* === Global Utility Classes === */
.page-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 40px;
    box-sizing: border-box;
    flex: 1 0 auto;
    background-color: var(--bg-main);
    min-height: calc(100vh - 80px);
}

.page-title {
    color: var(--primary-color);
    margin-bottom: 30px;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
    font-size: 1.4rem;
}

.text-primary {
    color: var(--primary-color) !important;
}

.nav-links {
    display: none !important;
}

/* === Main Layout === */
.main-wrapper {
    display: flex;
    flex: 1 0 auto;
    width: 100%;
    min-width: 0;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 20px;
    margin-left: 300px;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.public-layout .main-content {
    margin-left: 0 !important;
}

.app-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    overflow-x: hidden;
}

/* === Top Navbar === */
.top-navbar {
    background-color: var(--header-bg);
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    width: 100%;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 1001;
}

.top-nav-left {
    display: flex;
    align-items: center;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
    margin-right: 15px;
    padding: 0;
}

.top-nav-left img.logo-image {
    max-height: 40px;
    width: auto;
    margin: 0;
}

.top-nav-right {
    display: flex;
    align-items: center;
    gap: 25px;
}

.top-navbar a {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.top-navbar a:hover,
.top-navbar a.active {
    color: var(--primary-color);
    font-weight: 700;
}

.top-nav-company form {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    width: auto;
}

.top-nav-company select {
    margin: 0;
    padding: 8px 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}

/* === Mobile Navbar === */
.mobile-navbar {
    display: none;
    background: var(--header-bg);
    color: var(--text-main);
    padding: 15px 20px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 18px;
    cursor: pointer;
}

/* === Sidebar === */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 999;
    box-shadow: var(--shadow-sm);
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 20px;
    background-color: var(--sidebar-bg);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    color: var(--text-main);
    margin: 0;
    font-size: 22px;
}

.company-switcher {
    padding: 15px;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.company-switcher form {
    margin: 10px 0 0 0;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.company-switcher select {
    margin-bottom: 0;
    padding: 8px;
    border-radius: var(--radius-md);
    width: 100%;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
}

/* === Sidebar Menu === */
.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.menu-item {
    border-bottom: 1px solid var(--border-color);
}

.menu-category-btn {
    width: 100%;
    text-align: left;
    background: none;
    color: var(--sidebar-text);
    border: none;
    padding: 15px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.menu-category-btn:hover {
    background-color: var(--sidebar-hover);
    color: var(--primary-color);
}

.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: var(--bg-main);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.submenu.open {
    max-height: 500px;
}

.submenu li a {
    display: block;
    padding: 12px 20px 12px 40px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    margin: 0;
    border: none;
    text-align: left;
    transition: all 0.2s;
}

.submenu li a:hover,
.submenu li a.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    font-weight: 500;
}

.sidebar-footer {
    padding: 20px;
    background-color: var(--sidebar-bg);
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.btn-sair {
    display: block;
    padding: 10px;
    background-color: var(--danger-color);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    margin: 0;
    border: none;
    transition: background-color 0.2s;
}

.btn-sair:hover {
    background-color: var(--danger-hover);
}

/* === Home Header / Sidebar Premium === */
.home-header-premium {
    background-color: var(--header-bg);
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
    border-right: 1px solid var(--border-color);
    width: 300px;
    flex-shrink: 0;
    box-sizing: border-box;
    gap: 30px;
}

.header-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 30px;
}

.header-nav ul li a {
    text-decoration: none;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 500;
    transition: color 0.3s;
    margin: 0;
    padding: 5px 0;
}

.header-nav ul li a:hover,
.header-nav ul li a:active,
.header-nav ul li a.active {
    color: var(--primary-color);
    font-weight: 700;
}

/* === Home Body === */
.home-body {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin: 30px auto;
    padding: 40px;
    max-width: 1200px;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1 0 auto;
}

/* === Footer === */
.home-footer-premium {
    background-color: var(--header-bg);
    color: var(--text-muted);
    padding: 11px 40px;
    font-size: 0.9em;
    margin-top: auto;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.home-footer-premium p {
    margin: 0;
}

.footer-bottom {
    text-align: center;
    color: var(--text-muted);
    width: 100%;
    margin: 0;
    padding: 0;
}

/* === Scroll to Top Button === */
#btnScrollToTop {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-size: 24px;
    border: none;
    outline: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: background-color 0.3s, transform 0.3s;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    line-height: normal;
}

#btnScrollToTop:hover {
    background-color: var(--primary-hover);
    transform: translateY(-3px);
}

/* === Custom Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #a0aec0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #a0aec0 var(--bg-main);
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    body {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    .mobile-navbar {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 15px;
        max-width: 100%;
        width: 100%;
        overflow-x: hidden;
    }

    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    h3 {
        font-size: 1.0rem;
    }

    .top-navbar {
        padding: 15px 20px;
        max-width: 100%;
    }

    .top-navbar a {
        font-size: 13px;
    }

    .mobile-menu-btn {
        display: block;
    }

    .top-nav-right {
        display: none !important;
    }

    .home-header-premium {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        height: 100vh;
        z-index: 2000;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
    }

    .home-header-premium.open {
        left: 0;
    }

    .menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1500;
    }

    .menu-overlay.open {
        display: block;
    }

    .main-content,
    .home-body,
    .page-container {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .page-container {
        padding: 15px !important;
    }

    .home-body {
        padding: 20px !important;
        margin-left: 10px !important;
        margin-right: 10px !important;
    }

    .home-body p {
        font-size: 1rem;
    }

    .app-container {
        max-width: 100%;
        width: 100%;
        overflow-x: hidden;
    }
}