/* =============================================
   APP CSS — COMPONENTES E LAYOUT (SPA)
   ============================================= */

@font-face {
    font-family: 'FE-Schrift';
    src: url('../fonts/FE-Schrift.ttf') format('truetype');
}

/* LAYOUT PRINCIPAL */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* SIDEBAR MINI */
.sidebar {
    width: 250px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 50;
    position: relative;
}

.sidebar.collapsed {
    width: 72px;
    /* NÃO usar overflow:hidden aqui — esconderia o botão toggle que fica em right:-16px */
}

.sidebar-logo {
    padding: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    height: 72px;
}

.sidebar-logo img {
    height: 32px;
    width: auto;
    transition: all 0.3s ease;
}

.sidebar-logo .logo-mini {
    display: none;
}

.sidebar.collapsed .sidebar-logo .logo-full {
    display: none;
}

.sidebar.collapsed .sidebar-logo .logo-mini {
    display: block;
    height: 38px;
}

/* SIDEBAR TOGGLE (Alça Retangular na Borda) */
.sidebar-toggle {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 50px;
    border-radius: 0 8px 8px 0;
    background-color: var(--primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-on-primary);
    transition: all 0.2s ease;
    z-index: 60;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.sidebar-toggle:hover {
    background-color: var(--primary-dark);
    width: 20px;
    right: -20px;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-4) var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    overflow-y: auto;
    overflow-x: hidden; /* Evita barra horizontal quando colapsado */
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-3);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: 500;
    width: 100%;
    text-align: left;
}

.sidebar-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.sidebar-item.active {
    background-color: var(--primary);
    color: var(--text-on-primary);
}

.sidebar-item i {
    width: 24px;
    height: 24px;
    margin-right: var(--space-3);
    flex-shrink: 0;
}

.sidebar.collapsed .sidebar-item i {
    margin-right: 0;
}

.sidebar.collapsed .sidebar-label {
    display: none;
}

/* Rótulos de seção do menu (Operacional, Gestão, Integrações) */
.sidebar-section-label {
    padding: 14px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease, height 0.2s ease, padding 0.2s ease;
}

/* Esconde os rótulos de seção quando o menu está colapsado */
.sidebar.collapsed .sidebar-section-label {
    opacity: 0;
    height: 0;
    padding: 0;
    pointer-events: none;
}

.sidebar-footer {
    padding: var(--space-4) var(--space-2);
    border-top: 1px solid var(--border-color);
}

.sidebar-logout {
    color: var(--error);
}
.sidebar-logout:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

/* APP CONTENT (Header + Main) */
.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Impede overflow no flex child */
}

/* HEADER */
.app-header {
    height: 72px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    transition: background-color 0.2s;
}

.user-profile:hover {
    background-color: var(--bg-base);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent);
    color: var(--text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

/* MAIN CONTENT AREA */
.page-content {
    padding: var(--space-6);
    flex: 1;
    overflow-y: auto;
}

/* CARDS */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* BOTOES */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-on-primary);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-accent {
    background-color: var(--accent);
    color: var(--text-on-accent);
}
.btn-accent:hover {
    background-color: var(--accent-dark);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    background-color: var(--bg-base);
}

/* =============================================
   FORMULÁRIOS
   ============================================= */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text-primary);
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 700;
    text-transform: uppercase;
}

.form-control:focus {
    outline: none;
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(10, 56, 126, 0.1); /* Azul Mercosul glow */
}

.form-control::placeholder {
    color: #9ca3af;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}
