:root {
    --bg-main: #fcfbf9;
    /* Soft warm white */
    --bg-card: #ffffff;
    /* Pure white for cards */
    --text-main: #2d2a26;
    /* Deep warm gray */
    --text-muted: #8c8881;
    /* Soft taupe */
    --border-color: #e8e6e1;
    --brand-primary: #b39b82;
    /* Elegant gold/bronze */
    --brand-hover: #9c866f;
    --accent: #d4a373;
    /* Warmer accent */
    --sidebar-width: 250px;

    /* Functional Colors */
    --status-optimo: #e0ece4;
    --status-optimo-text: #417554;
    --status-alerta: #fff4e5;
    --status-alerta-text: #b26a00;
    --status-critico: #fdeded;
    --status-critico-text: #9a2020;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

/* Typography Helpers */
h1,
h2,
h3,
h4 {
    font-weight: 300;
    letter-spacing: 0.5px;
}

p {
    line-height: 1.6;
}

/* ------------------------
   Login Screen
--------------------------- */
.login-container {
    display: flex;
    height: 100vh;
}

.login-form-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: var(--bg-main);
}

.login-image-side {
    flex: 1;
    background: linear-gradient(135deg, #1A1A1A 0%, #2D2A26 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    overflow: hidden;
}

.login-image-side::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('assets/LOGO-ALCHEMY.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 150%;
    opacity: 0.03;
    filter: grayscale(100%);
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 480px;
    color: white;
}

.hero-logo {
    height: 35px;
    margin-bottom: 2rem;
    filter: brightness(0) invert(1);
}

.hero-title {
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.2;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #FFFFFF 0%, #dbf059 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 3rem;
    font-weight: 300;
}

.ai-showcase-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.ai-showcase-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.card-icon {
    width: 48px;
    height: 48px;
    background: rgba(179, 155, 130, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-primary);
    flex-shrink: 0;
}

.card-text h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: white;
}

.card-text p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
}

.card-arrow {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.3s ease;
}

.ai-showcase-card:hover .card-arrow {
    color: white;
}

.login-box {
    width: 100%;
    max-width: 380px;
}

.login-logo {
    margin-bottom: 2rem;
    text-align: center;
}

.login-logo img {
    height: 60px;
}

.login-header {
    margin-bottom: 2.5rem;
    text-align: center;
}

.login-header h1 {
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 400;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 4px;
    font-size: 15px;
    color: var(--text-main);
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(179, 155, 130, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background-color: var(--brand-primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-primary:hover {
    background-color: var(--brand-hover);
}

/* ------------------------
   Dashboard Layout
--------------------------- */
.dashboard-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
}

.sidebar-header img {
    height: 40px;
}

.sidebar-nav {
    flex: 1;
    padding: 2rem 0;
}

.nav-item {
    padding: 12px 2rem;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 15px;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    color: var(--brand-primary);
    background: rgba(179, 155, 130, 0.05);
    border-right: 3px solid var(--brand-primary);
}

.sidebar-footer {
    padding: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--brand-primary);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-main);
}

.topbar {
    height: 70px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.view-container {
    padding: 2.5rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ------------------------
   Dashboard Components
--------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.kpi-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 300;
    color: var(--text-main);
}

.kpi-trend {
    font-size: 13px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.trend-up {
    color: #417554;
}

.trend-down {
    color: #9a2020;
}

/* Charts & Tables */
.section-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 18px;
    font-weight: 400;
    color: var(--text-main);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
    font-weight: 500;
}

td {
    font-size: 14px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-optimo {
    background: var(--status-optimo);
    color: var(--status-optimo-text);
}

.status-alerta {
    background: var(--status-alerta);
    color: var(--status-alerta-text);
}

.status-critico {
    background: var(--status-critico);
    color: var(--status-critico-text);
}

/* ------------------------
   Copilot Assistant Module
--------------------------- */
.routine-builder {
    display: flex;
    gap: 2rem;
}

.builder-controls {
    flex: 1;
}

.builder-preview {
    flex: 1;
    background: #fdfaf6;
    border: 1px solid var(--brand-primary);
    border-radius: 8px;
    padding: 2rem;
}

.btn-secondary {
    padding: 10px 16px;
    background: transparent;
    color: var(--brand-primary);
    border: 1px solid var(--brand-primary);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--brand-primary);
    color: white;
}

/* Floating AI Chat */
.ai-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--text-main);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s;
}

.ai-fab:hover {
    transform: scale(1.05);
}

.ai-panel {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 360px;
    height: 500px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    z-index: 99;
    overflow: hidden;
}

.ai-panel.open {
    display: flex;
}

.ai-header {
    padding: 16px 20px;
    background: var(--text-main);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fcfbf9;
}

.ai-message {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    max-width: 85%;
    line-height: 1.5;
}

.ai-message.bot {
    background: white;
    border: 1px solid var(--border-color);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-message.user {
    background: var(--brand-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: white;
    display: flex;
    gap: 8px;
}

.ai-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    outline: none;
    font-size: 14px;
}

.ai-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* ------------------------
   Responsive Design & Media Queries
--------------------------- */
@media (max-width: 768px) {

    /* Login Responsiveness */
    .login-container {
        flex-direction: column;
    }

    .login-image-side {
        display: none;
        /* Hide image on mobile for priority to form */
    }

    .login-form-side {
        padding: 1.5rem;
    }

    /* Dashboard Responsiveness */
    .dashboard-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        overflow-x: auto;
        /* Allow horizontal scroll for tabs */
    }

    .sidebar-header {
        padding: 1rem;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
    }

    .sidebar-header img {
        height: 25px;
    }

    .sidebar-nav {
        display: flex;
        padding: 0;
        flex-direction: row;
    }

    .nav-item {
        padding: 1rem;
        white-space: nowrap;
        border-right: none;
        border-bottom: 3px solid transparent;
    }

    .nav-item.active {
        border-bottom: 3px solid var(--brand-primary);
        border-right: none;
    }

    .sidebar-footer {
        display: none;
        /* Hide profile summary on mobile header */
    }

    /* Layout Adjustments */
    .view-container {
        padding: 1rem;
    }

    .topbar {
        padding: 0 1rem;
        height: 60px;
    }

    .topbar h2 {
        font-size: 16px !important;
    }

    .topbar button {
        display: none !important;
        /* Hide B2B toggle button on mobile to save space, rely on bottom fab */
    }

    /* Grid Adjustments */
    .kpi-grid {
        grid-template-columns: 1fr;
        /* Stack KPIs vertically */
        gap: 1rem;
    }

    /* Specific Tab Adjustments */
    #tab-chatbot .kpi-grid+div {
        grid-template-columns: 1fr !important;
        /* Stack Chatbot settings and monitor */
    }

    #tab-benefits>div:last-child {
        grid-template-columns: 1fr !important;
        /* Stack Benefits cards */
    }

    .routine-builder {
        flex-direction: column;
    }

    /* Copilot Panels Adjustments */
    .ai-panel {
        width: 100%;
        height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        top: 0 !important;
        border-radius: 0;
        z-index: 1000;
    }

    .ai-fab {
        bottom: 20px;
        right: 20px;
    }
}